Last active
September 16, 2016 20:14
-
-
Save maldevel/a19cc1a959023f40518c48a95448c3b9 to your computer and use it in GitHub Desktop.
Make Multiple Burp HTTP Requests
This file contains 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 requests | |
import os | |
proxies = { | |
'http': 'http://127.0.0.1:8080', | |
'https': 'http://127.0.0.1:8080', | |
} | |
protocol = 'https' | |
xsrf = 'xsrf-token' | |
auth_cookie = 'sessionid=blah-blah-blah' | |
dir_requests = '/path/to/requests' | |
headers = {} | |
method = '' | |
uri = '' | |
post_data = '' | |
for ff in os.listdir(dir_requests): | |
if ff.endswith(".txt"): | |
print '\n\n----------\nProcessing file {}\n'.format(ff) | |
with open(ff) as f: | |
index = 0 | |
for line in f: | |
if index == 0: | |
first_line = line | |
if ' ' not in first_line: | |
raise Exception('You had one job!') | |
first_line = first_line.split(' ') | |
method = first_line[0].lower() #GET POST etc | |
uri = first_line[1] | |
index = 1 | |
if ':' in line: | |
words = line.split(':', 1) | |
headers[words[0].strip()] = words[1].strip() | |
if line.strip() == '': | |
post_data = f.next() | |
url = '{}://{}{}'.format(protocol, headers['Host'], uri) | |
headers['Cookie'] = auth_cookie | |
headers['X-XSRF-TOKEN'] = xsrf | |
r = getattr(requests, method)(url, proxies=proxies, verify=False, headers=headers, data=post_data) | |
print 'HTTP/1.1 {} {}'.format(r.status_code, requests.status_codes._codes[r.status_code][0].upper()) | |
for header, value in r.headers.iteritems(): | |
print '%s: %s' % (header, value) | |
print '' | |
print r.content | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment