Created
June 7, 2022 23:19
-
-
Save skelsec/c237221aca323d6891278c74a9d84ddc to your computer and use it in GitHub Desktop.
burp bapp downloader
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
""" | |
Yet again I have to test webapps in a restricted envrionment with no internet access. | |
This script will download all avilable BAPPs from the Burp BAPP store so you can install them offline. | |
It also creates a small info.txt file that matches the app names to the actual file names. | |
""" | |
import requests | |
import re | |
from tqdm import tqdm | |
atagre = re.compile(r'<(\S+).*?class="(?:\bbapp-label\b.?)" href="(.*)".*?>(.+?)<') | |
BAPP_STORE_URL = 'https://portswigger.net/bappstore' | |
BAPP_CDN_URL = 'https://portswigger-cdn.net/bappstore/bapps/download/' | |
NAME_HREF_LOOKUP = {} | |
print('[+] Fetching module list from %s ...' % BAPP_STORE_URL) | |
res = requests.get(BAPP_STORE_URL) | |
if res.status_code != 200: | |
print('[-] Failed fetching module list! Status code: %s' % res.status_code) | |
#raise Exception('BAPP LIST request error! Unexpected status code %s' % res.status_code) | |
sys.exit() | |
print('[+] Parsing results...') | |
for _, href, name in atagre.findall(res.text): | |
NAME_HREF_LOOKUP[name] = href[11:] | |
print('[+] Obtained %s entries!' % len(NAME_HREF_LOOKUP)) | |
print('[+] Fetching BAPP files...') | |
pbar = tqdm(NAME_HREF_LOOKUP, total = len(NAME_HREF_LOOKUP)) | |
for name in pbar: | |
pbar.set_description("Processing %s" % name[:30].ljust(30)) | |
bapp_file_url = BAPP_CDN_URL+NAME_HREF_LOOKUP[name]+'/3' #not sure about the /3 | |
res = requests.get(bapp_file_url) | |
if res.status_code != 200: | |
print('[-] Failed fetching BAPP "%s"! Status code: %s' % (name, res.status_code)) | |
continue | |
try: | |
with open(NAME_HREF_LOOKUP[name]+'.bapp', 'wb') as f: | |
f.write(res.content) | |
except Exception as e: | |
print('[-] Failed writing BAPP "%s.bapp"! Reason: %s' % (NAME_HREF_LOOKUP[name], e)) | |
continue | |
pbar.set_description("Finished!") | |
pbar.refresh() | |
print('[+] Creating info file...') | |
with open('info.txt', 'w') as f: | |
for name in NAME_HREF_LOOKUP: | |
f.write('%s : %s\r\n' % (name, NAME_HREF_LOOKUP[name]+'.bapp')) | |
print('[+] Info file created!') | |
print('[+] All done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment