Advertisement
Guest User

Direcory Brute Forcer

a guest
Mar 14th, 2016
1,071
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #! /usr/bin/python
  2.  
  3. try:
  4.     import sys
  5.     import socket
  6.     import requests
  7.  
  8.     rhost = sys.argv[1]
  9.     wordlist = sys.argv[2]
  10.  
  11.     print '[*] Checking RHOST... ',
  12.     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  13.     try:
  14.         status = s.connect_ex((rhost, 80))
  15.         s.close()
  16.         if status == 0:
  17.             print '[DONE]'
  18.             pass
  19.         else:
  20.             print '[FAIL]'
  21.             print '[!] Error: Cannot Reach RHOST %s\n' %(rhost)
  22.             sys.exit(1)
  23.     except socket.error:
  24.         print '[FAIL]'
  25.         print '[!] Error: Cannot Reach RHOST: %s\n' %(rhost)
  26.         sys.exit(1)
  27.  
  28.     print '[*] Parsing Wordlist... ',
  29.     try:
  30.         with open(wordlist) as file:
  31.             to_check = file.read().strip().split('\n')
  32.         print '[DONE]'
  33.         print '[*] Total Paths to Check: %s' %(str(len(to_check)))
  34.     except IOError:
  35.         print '[FAIL]'
  36.         print '[!] Error: Failed to Read Specified File\n'
  37.         sys.exit(1)
  38.    
  39.     def checkpath(path):
  40.         try:
  41.             response = requests.get('http://' + rhost + '/' + path).status_code
  42.         except Exception:
  43.             print '[!] Error: An Unexpected Error Occured'
  44.             sys.exit(1)
  45.         if response == 200:
  46.             print '[*] Valid Path Found: /%s' %(path)
  47.    
  48.     print '\n[*] Beginning Scan...\n'
  49.     for i in range(len(to_check)):
  50.         checkpath(to_check[i])
  51.     print '\n[*] Scan Complete!'
  52. except KeyboardInterrupt:
  53.     print '\n[!] Error: User Interrupted Scan'
  54.     sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement