Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- """
- #!/bin/bash/python
- #Library
- from string import ascii_lowercase
- import itertools, os, sys, time, requests, getopt, socket
- #pre-defined variable
- arg_start = 1
- arg_end = 10
- file_name = "result.txt"
- word_list = "wordlist.lst"
- url = ""
- menu = -1
- guess = ""
- option = -1
- ext = ""
- #coloring
- class color:
- VIOLET = '\033[95m'
- BLUE = '\033[94m'
- YELLOW = '\033[93m'
- GREEN = '\033[92m'
- RED = '\033[91m'
- UNDERLINE = '\033[4m'
- BOLD = '\033[1m'
- NORMAL = '\033[0m'
- #splash screen
- def splash_screen():
- print (color.GREEN + color.BOLD + "\t\t ____ _ _ _ _ ")
- print ("\t\t| _ \(_)_ __ | | | |_ _ _ __ | |_ ___ _ __ ")
- print ("\t\t| | | | | '__| _____ | |_| | | | | '_ \| __/ _ \ '__|")
- print ("\t\t| |_| | | | |_____| | _ | |_| | | | | || __/ | ")
- print ("\t\t|____/|_|_| |_| |_|\__,_|_| |_|\__\___|_| v2 ")
- print ("\t\tApoll0 " + color.NORMAL)
- print ("\t\t\t\t\t\t\t\t " + color.BOLD + "By:" + color.UNDERLINE + "D4RK1T5UN3" + color.NORMAL + color.RED)
- print ('-' * 80)
- print (color.BLUE + '\t0x00 Input URL with "http://" or "https://"')
- print ('\t0x01 Input URL without "/" behind')
- print ('\t0x02 Input URL like this "http://localhost" or "https://facebook.com"')
- print ('\t0x03 DO NOT input URL like this "localhost" or "facebook.com/"')
- print ('\t0x04 Dir-Hunter speed depends on your connection speed')
- print ('\t0x05 "CTRL + C" for reset || "CTRL + Z" for stop')
- print ('\t0x06 HAPPY HUNTING' + color.NORMAL + color.RED)
- print ('-' * 80 + color.NORMAL)
- #usage
- def usage():
- print('python dirhunter.py [options] [value]')
- print(color.BOLD + 'OPTIONS' + color.NORMAL)
- print('-s | --start')
- print('\tif value is 2, so bruteforce will start from "aa"')
- print('-e | --end')
- print('\tif value is 3, so bruteforce will ends in "aaa"')
- print('-o | --out')
- print('\tif value is "a.txt", will make an output named "a.txt"')
- print('-h | --help')
- print('\twill show this help')
- print('-u | --url')
- print('\tif value is http://localhost, url will set on value ')
- print('-w | --wordlist')
- print('\tif value is "b.txt", will use "b.txt" as a wordlist')
- print('-m | --menu')
- print('\t1\t\tBruteforce Directory')
- print('\t2\t\tBruteforce Subdomain')
- print('\t3\t\tDictionary Attack Directory')
- print('\t4\t\tDictionary Attack SubDomain')
- print('\t7\t\tBruteforce file')
- print('\t8\t\tRandom Guess')
- #word generator
- def iter_all_strings():
- size = arg_start
- while size <= arg_end:
- for directory in itertools.product(ascii_lowercase, repeat=size):
- yield "".join(directory)
- size += 1
- #clear
- def clear():
- for i in range(0,25):
- print()
- #checking robots.txt
- def check_robot():
- if requests.get(url + "/robots.txt").status_code == 200:
- return "True"
- else:
- return "None"
- #Reading robots.txt
- def read_robot():
- if check_robot() == "True":
- print(color.GREEN + "Robots.txt here" + color.NORMAL)
- print(requests.get(url + "/robots.txt").text)
- print(color.RED + '-' * 80 + color.NORMAL)
- #getting_ip
- def getting_ip():
- domain = url.split('://')
- domain = domain[1]
- domain = domain.split('/')
- domain = domain[0]
- return socket.gethostbyname(domain)
- #getting_domain
- def getting_domain():
- domain = url.split('://')
- domain = domain[1]
- return domain
- #checking_luck
- def checking_luck():
- try:
- if requests.get(url+ "/" + guess).status_code == 200:
- print(" [*] "+color.GREEN+url+ "/" + guess+" "+color.BOLD+"\t\tFOUND"+color.NORMAL)
- file.write(url+ "/" + guess + "\n")
- else:
- print(" [*] "+color.RED+url+ "/" + guess+" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- #if requests.get("http://" + guess + "." + getting_domain()).status_code == 200:
- # print(" [*] "+color.GREEN+"http://" + guess + "." + getting_domain() +" "+color.BOLD+"\tFOUND"+color.NORMAL)
- # file.write("http://" + guess + "." + getting_domain()+"\n")
- #else:
- # print(" [*] "+color.GREEN+"http://" + guess + "." + getting_domain() +" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- if requests.get(url+ "/" + guess+".php").status_code == 200:
- print(" [*] "+color.GREEN+url+ "/" + guess+".php"+" "+color.BOLD+"\tFOUND"+color.NORMAL)
- file.write(url+ "/" + guess+".php\n")
- else:
- print(" [*] "+color.RED+url+ "/" + guess+".php"+" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- if requests.get(url+ "/" + guess+".html").status_code == 200:
- print(" [*] "+color.GREEN+url+ "/" + guess+".html"+" "+color.BOLD+"\tFOUND"+color.NORMAL)
- file.write(url+ "/" + guess+".html\n")
- else:
- print(" [*] "+color.RED+url+ "/" + guess+".html"+" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- if requests.get(url+ "/" + guess+".jsp").status_code == 200:
- print(" [*] "+color.GREEN+url+ "/" + guess+".jsp"+" "+color.BOLD+"\tFOUND"+color.NORMAL)
- file.write(url+ "/" + guess+".jsp\n")
- else:
- print(" [*] "+color.RED+url+ "/" + guess+".jsp"+" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- if requests.get(url+ "/" + guess+".aspx").status_code == 200:
- print(" [*] "+color.GREEN+url+ "/" + guess+".aspx"+" "+color.BOLD+"\tFOUND"+color.NORMAL)
- file.write(url+ "/" + guess+".aspx\n")
- else:
- print(" [*] "+color.RED+url+ "/" + guess+".aspx"+" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- if requests.get(url+ "/" + guess+".txt").status_code == 200:
- print(" [*] "+color.GREEN+url+ "/" + guess+".txt"+" "+color.BOLD+"\tFOUND"+color.NORMAL)
- file.write(url+ "/" + guess+".txt\n")
- else:
- print(" [*] "+color.RED+url+ "/" + guess+".txt"+" "+color.BOLD+"\tNOT FOUND"+color.NORMAL)
- except:
- sys.exit(2)
- #getting_cms
- def getting_cms():
- return
- #setting info
- def set_info():
- print(color.RED + '-' * 80 + color.NORMAL)
- print("Bruteforce will starts from " + str(arg_start) + " character(s)")
- print("Bruteforce will ends at " + str(arg_end) + " character(s)")
- print("Output file is " + file_name)
- print("Wordlist file is " + word_list)
- print(color.RED + '-' * 80 + color.NORMAL)
- #web info
- def web_info():
- print (color.GREEN + color.BOLD + "\t\t ____ _ _ _ _ ")
- print ("\t\t| _ \(_)_ __ | | | |_ _ _ __ | |_ ___ _ __ ")
- print ("\t\t| | | | | '__| _____ | |_| | | | | '_ \| __/ _ \ '__|")
- print ("\t\t| |_| | | | |_____| | _ | |_| | | | | || __/ | ")
- print ("\t\t|____/|_|_| |_| |_|\__,_|_| |_|\__\___|_| v2 ")
- print ("\t\tApoll0 " + color.NORMAL)
- print(color.RED + '-' * 80 + color.NORMAL)
- print(color.GREEN + "Target : " + color.NORMAL + url)
- print(color.GREEN + "IP : " + color.NORMAL + getting_ip())
- print(color.GREEN + "CMS : " + color.NORMAL )
- print(color.GREEN + "Robots.txt : " + color.NORMAL + check_robot())
- print(color.RED + '-' * 80 + color.NORMAL)
- read_robot()
- #getting argument
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'hs:e:o:u:w:m:', ['help','start=', 'end=', 'out=', 'url=', 'wordlist=', 'menu='])
- except getopt.GetoptError:
- splash_screen()
- usage()
- sys.exit(2)
- for opt,arg in opts:
- if opt in ('-h', '--help'):
- splash_screen()
- usage()
- sys.exit(2)
- elif opt in ('-s', '--start'):
- arg_start = int(arg)
- elif opt in ('-e', '--end'):
- arg_end = int(arg)
- elif opt in ('-o', '--out'):
- file_name = arg
- elif opt in ('-u', '--url'):
- url = arg
- elif opt in ('-w', '--wordlist'):
- word_list = arg
- elif opt in ('-m', '--menu'):
- menu = int(arg)
- #checking length
- if arg_start > arg_end:
- arg_end = arg_start + 2
- #Main Program
- while True:
- file = open(file_name, "w")
- file.close()
- clear()
- splash_screen()
- if url == "":
- try:
- url = input('[+] Input URL -- > ')
- except:
- sys.exit(2)
- try:
- response= requests.get(url).status_code
- except:
- sys.exit(2)
- if response == 200:
- print("Getting Info. . ")
- while True:
- clear()
- web_info()
- print(color.BLUE + "[1] Bruteforce Directory", end = '\t\t')
- print("[2] Bruteforce Subdomain")
- print("[3] Dictionary Attack Directory", end = '\t\t')
- print("[4] Dictionary Attack Subdomain")
- print("[5] Adding words to wordlist", end = '\t\t')
- print("[6] View wordlist")
- print("[7] Bruteforce file", end = '\t\t\t')
- print("[8] Random Guess")
- print("[9] Settings", end = '\t\t\t\t')
- print("[0] Change Target" + color.NORMAL)
- try:
- while menu < 0 or menu > 9:
- menu = eval(input("Choose --> "))
- except:
- file.close()
- sys.exit(2)
- if menu == 1:
- clear()
- web_info()
- print("Starting. . .")
- file = open(file_name, "a")
- try:
- for directory in iter_all_strings():
- link = url + '/' + directory
- print(link, end = '\r')
- if requests.get(link).status_code == 200:
- print(" [*] " + color.GREEN + link + " " + color.BOLD + "\tFOUND" + color.NORMAL)
- file.write(link + '\n')
- elif requests.get(link).status_code == 403:
- print(" [*] " + color.RED + link + " " + color.BOLD + "\tFORBIDDEN" + color.NORMAL)
- except:
- print("\nEnd of Bruteforce in '"+ directory+"'")
- print("\n" + color.BOLD + color.GREEN + 'directory has stored in ' + file_name + color.NORMAL)
- try:
- input()
- except:
- file.close()
- sys.exit(2)
- file.close()
- menu = -1
- elif menu == 2:
- clear()
- web_info()
- print("Soon")
- input()
- # print("Starting. . .")
- # file = open(file_name, "a")
- # try:
- # for directory in iter_all_strings():
- # link = "http://" + directory + "." + getting_domain()
- # print(link, end = '\r')
- # if requests.get(link).status_code == 200:
- # print(" [*] " + color.GREEN + link + " " + color.BOLD + "\tFOUND" + color.NORMAL)
- # file.write(link + '\n')
- # elif requests.get(link).status_code == 403:
- # print(" [*] " + color.RED + link + " " + color.BOLD + "\tFORBIDDEN" + color.NORMAL)
- # except:
- # print("\nEnd of Bruteforce in '"+ directory+"'")
- # print("\n" + color.BOLD + color.GREEN + 'directory has stored in ' + file_name + color.NORMAL)
- # try:
- # input()
- # except:
- # file.close()
- # sys.exit(2)
- # file.close()
- menu = -1
- elif menu == 3:
- clear()
- web_info()
- print("Starting. . .")
- file = open(file_name, "a")
- try:
- wl = open(word_list, "r")
- except:
- print("No File")
- input()
- menu = -1
- break
- words = wl.read().split('\n')
- try:
- for word in words:
- link = url + '/' + word
- if requests.get(link).status_code == 200:
- print(" [*] " + color.GREEN + link + " " + color.BOLD + "\tFOUND" + color.NORMAL)
- file.write(link + '\n')
- elif requests.get(link).status_code == 403:
- print(" [*] " + color.RED + link + " " + color.BOLD + "\tFORBIDDEN" + color.NORMAL)
- except:
- print("\nEnd of Bruteforce in '"+ directory+"'")
- print("\n" + color.BOLD + color.GREEN + 'directory has stored in ' + file_name + color.NORMAL)
- try:
- input()
- except:
- file.close()
- wl.close()
- sys.exit(2)
- print("End.")
- file.close()
- wl.close()
- try:
- input()
- except:
- sys.exit(2)
- menu = -1
- elif menu == 4:
- clear()
- web_info()
- print("Soon")
- input()
- menu = -1
- elif menu == 5:
- clear()
- web_info()
- try:
- temp_wl = input("Add word : ")
- except:
- sys.exit(2)
- wl = open(word_list, "a")
- wl.write(temp_wl + '\n')
- wl.close()
- menu = -1
- elif menu == 6:
- clear()
- number_of_words=0
- try:
- wl = open(word_list, "r")
- except:
- print("No File")
- input()
- menu = -1
- break
- try:
- for string in wl.read():
- if string != '\n':
- print(string, end ='')
- elif string == '\n':
- print()
- else:
- print(string)
- time.sleep(0.01)
- except:
- print()
- try:
- a = open(word_list, "r")
- b = a.read().split('\n')
- a.close()
- for c in b:
- number_of_words += 1
- except:
- print()
- print(color.RED + '-' * 80 + color.NORMAL + "\nEnd of File. . .")
- print("Total " + str(number_of_words-1) + " words in wordlist")
- try:
- input()
- except:
- sys.exit(2)
- wl.close()
- menu = -1
- elif menu == 7:
- clear()
- web_info()
- while ext != "php" and ext != "html" and ext != "jsp" and ext != "txt" and ext != "aspx":
- try:
- ext = input("What extension [php | html | jsp | aspx | txt]? ")
- except:
- sys.exit(2)
- file = open(file_name, "a")
- try:
- for directory in iter_all_strings():
- link = url + '/' + directory + '.' + ext
- print(link, end = '\r')
- if requests.get(link).status_code == 200:
- print(" [*] " + color.GREEN + link + " " + color.BOLD + "\tFOUND" + color.NORMAL)
- file.write(link + '\n')
- elif requests.get(link).status_code == 403:
- print(" [*] " + color.RED + link + " " + color.BOLD + "\tFORBIDDEN" + color.NORMAL)
- except:
- print("\nEnd of Bruteforce in '"+ directory+"'")
- print("\n" + color.BOLD + color.GREEN + 'directory has stored in ' + file_name + color.NORMAL)
- try:
- input()
- except:
- file.close()
- sys.exit(2)
- file.close()
- menu = -1
- elif menu == 8:
- clear()
- web_info()
- try:
- guess = input("Give 1 keyword = ")
- except:
- file.close()
- sys.exit(2)
- print("Checking your luck. . .")
- file = open(file_name, "a")
- checking_luck()
- print("End. ")
- try:
- input()
- except:
- file.close()
- sys.exit(2)
- file.close()
- menu = -1
- elif menu == 9:
- while option != 0:
- clear()
- set_info()
- print(color.BLUE + "[1] start number of bruteforce")
- print("[2] end number of bruteforce")
- print("[3] output file")
- print("[4] wordlist file")
- print("[5] Default")
- print("[0] Back to menu" + color.NORMAL)
- try:
- while option < 0 or option > 5:
- option = eval(input("Reset number? "))
- except:
- file.close()
- sys.exit(2)
- if option != 0 and option != 5:
- try:
- new_option = input("Replace with? ")
- except:
- file.close()
- sys.exit(2)
- if option == 1:
- try:
- arg_start = int(new_option)
- except:
- file.close()
- sys.exit(2)
- elif option == 2:
- try:
- arg_end = int(new_option)
- except:
- file.close()
- sys.exit(2)
- elif option == 3:
- file_name = new_option
- elif option == 4:
- word_list = new_option
- elif option == 5:
- arg_start = 1
- arg_end = 10
- file_name = "result.txt"
- word_list = "wordlist.lst"
- elif option == 0:
- menu = -1
- option = -1
- break
- if arg_start > arg_end:
- arg_end = arg_start + 2
- option = -1
- elif menu == 0:
- url = ""
- menu = -1
- break
Add Comment
Please, Sign In to add comment