🤬
  • ■ ■ ■ ■ ■ ■
    Projects/Directory_BruteForcer/DBF.py
     1 +from threading import Thread
     2 +import time,requests,sys,os.path
     3 +
     4 +def usage():
     5 + print("----------USAGE INSTRUCTION ---------")
     6 + print(f"{sys.argv[0]} URL WORDLIST NUMBER_OF_THREADS(Default is 10)\n")
     7 + sys.exit()
     8 +
     9 +def prepare(myList,numOfChunks):
     10 + for i in range(0, len(myList), numOfChunks):
     11 + yield myList[i:i + numOfChunks]
     12 +
     13 +def brute(myList,url):
     14 + start=time.perf_counter()
     15 + for lists in myList:
     16 + threads.append(Thread(target=worker,args=(lists,url),daemon=True))
     17 + for thread in threads:
     18 + try:
     19 + thread.start()
     20 + except KeyboardInterrupt:
     21 + print("\nReceived Keyboard Interrupt , Terminating threads\n")
     22 + sys.exit()
     23 + for thread in threads:
     24 + try:
     25 + thread.join()
     26 + except KeyboardInterrupt:
     27 + print("\nReceived Keyboard Interrupt , Terminating threads\n")
     28 + sys.exit()
     29 + finish=time.perf_counter()
     30 + print(f"\n\n\t\t Checked {total_len} Directories in {round(finish-start,2)} Seconds\n")
     31 +
     32 +def worker(lists,url):
     33 + try:
     34 + for word in lists:
     35 + if word.startswith("/"):
     36 + word=word[1:]
     37 + url2=url+"/"+word.strip()
     38 + r=requests.get(url2)
     39 + if str(r.status_code) in match:
     40 + print(f"/{word.strip():<40} [ Status: {r.status_code} Length:{len(r.content)} ]")
     41 + except KeyboardInterrupt:
     42 + print("\nReceived Keyboard Interrupt , Terminating threads\n")
     43 + sys.exit()
     44 + except Exception as e:
     45 + print(f"\nAn error Occurred : {e}\n")
     46 + sys.exit()
     47 +
     48 +if __name__ == "__main__":
     49 + try:
     50 + match=['200','301','302','401','403','429'] #change this to filter responses
     51 + try:
     52 + if sys.argv[1]:
     53 + url=sys.argv[1]
     54 + if sys.argv[2]:
     55 + wordlist=sys.argv[2]
     56 + try:
     57 + if sys.argv[3]:
     58 + numOfThreads=int(sys.argv[3])
     59 + except:
     60 + numOfThreads=10
     61 + except:
     62 + usage()
     63 + if os.path.isfile(wordlist)==False:
     64 + print(f"The file {wordlist} doesn't exist")
     65 + sys.exit()
     66 + with open(wordlist,'r') as w:
     67 + myList=w.readlines()
     68 + total_len=len(myList)
     69 + final=[]
     70 + threads=[]
     71 + if numOfThreads>total_len or numOfThreads<0:
     72 + print("\nToo High Value for Threads with Respect to Input Word-list\n")
     73 + sys.exit(1)
     74 + numOfChunks=len(myList)//numOfThreads
     75 + if url.endswith("/"):
     76 + url=url[0:-1]
     77 + print(f'''
     78 + ======================================
     79 + URL --> {url}
     80 + Word-list --> {wordlist}
     81 + Threads --> {numOfThreads}
     82 + Status Codes --> {','.join([w for w in match])}
     83 + ======================================
     84 + \n\n
     85 + ''')
     86 + print("------- Started Brute forcing Directories -------\n")
     87 + myList_new=prepare(myList,numOfChunks)
     88 + brute(myList_new,url)
     89 + except Exception as e:
     90 + print(f"\nAn error Occurred : {e}\n")
     91 + sys.exit()
     92 + 
  • ■ ■ ■ ■ ■ ■
    Projects/Directory_BruteForcer/README.md
     1 +# Multi Threaded Directory Brute Forcer
     2 +
     3 +This is a Multi Threaded non-recursive Directory Bruteforcing tool written in Python.
     4 +
     5 +## :information_source: Technologies used
     6 +
     7 +* Python
     8 +
     9 +## :information_source: How to use?
     10 +```bash
     11 +# Clone the repository
     12 +$ git clone https://github.com/kurogai/100-redteam-projects
     13 +
     14 +# Enter the repository
     15 +$ cd 100-redteam-projects/Directory_BruteForcer
     16 +
     17 +# Open a terminal and run
     18 +$ python3 DBF.py https://example.com wordlist.txt 100
     19 +
     20 +```
     21 +## Developer
     22 +<p align="center">
     23 +<a href="https://github.com/MayankPandey01" target="blank"><img align="center" src="https://avatars.githubusercontent.com/u/29165227?s=96&v=4" alt="Mayank" height="120" width="120" /></a>
     24 +<a href="https://www.twitter.com/Mayank_pandey01" target="blank"><img align="center" src="https://1000logos.net/wp-content/uploads/2021/04/Twitter-logo.png" alt="Mayank" height="120" width="120" /></a>
     25 +</p>
     26 + 
  • ■ ■ ■ ■
    README.md
    skipped 47 lines
    48 48  [11] | Simple port scanner | :heavy_check_mark:
    49 49  [12] | Port scanner with OS fingerprint using TTL (Time To Live) | :x:
    50 50  [13] | Port scanner with port footprint (HTTP? DNS? FTP? IRC?) | :x:
    51  -[14] | Simple Web Directory brute-forcer (Threaded) | :x:
     51 +[14] | Simple Web Directory brute-forcer (Threaded) | :heavy_check_mark:
    52 52  [15] | Recursive Web Directory brute-forcer (Threaded peer recursion) | :x:
    53 53  [16] | Web Login bruteforce tool | :x:
    54 54  [17] | FTP Login bruteforce tool | :x:
    skipped 110 lines
Please wait...
Page is in error, reload to recover