-
-
Save srand2/f36af751e560c7da7bd0dbf71e0beb54 to your computer and use it in GitHub Desktop.
pip3 install asyncio and pip3 install import aiohttp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment