Skip to content

Instantly share code, notes, and snippets.

@nullenc0de
Created November 21, 2022 15:17
Show Gist options
  • Save nullenc0de/c68ab56f9d2d0debdbd01d3113daeec6 to your computer and use it in GitHub Desktop.
Save nullenc0de/c68ab56f9d2d0debdbd01d3113daeec6 to your computer and use it in GitHub Desktop.
pip3 install asyncio and pip3 install import aiohttp
import asyncio
import aiohttp
import time
import sys
import argparse
import os
parser = argparse.ArgumentParser(description='Directory Bruteforce')
parser.add_argument('-u', '--url', help='URL to bruteforce', required=True)
parser.add_argument('-w', '--wordlist', help='Wordlist to use', required=True)
parser.add_argument('-t', '--threads', help='Number of threads to use', required=False, default=10)
parser.add_argument('-v', '--verbose', help='Verbose output', required=False, action='store_true')
args = parser.parse_args()
url = args.url
wordlist = args.wordlist
threads = int(args.threads)
verbose = args.verbose
if not os.path.isfile(wordlist):
print('[!] Wordlist does not exist')
sys.exit(1)
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
tasks = []
with open(wordlist, 'r') as f:
for line in f:
line = line.strip()
if line == '':
continue
tasks.append(fetch(session, url + '/' + line))
responses = await asyncio.gather(*tasks)
for response in responses:
if verbose:
print(response)
if '404' not in response:
print('[+] Found: ' + url + '/' + line)
if __name__ == '__main__':
start = time.time()
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
end = time.time()
print('[*] Completed in ' + str(end - start) + ' seconds')
@pudsec
Copy link

pudsec commented Nov 22, 2022

threads isn't used anywhere?

@nullenc0de
Copy link
Author

nullenc0de commented Nov 22, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment