Skip to content

Instantly share code, notes, and snippets.

@averagesecurityguy
Created November 12, 2013 16:42
Show Gist options
  • Save averagesecurityguy/7434228 to your computer and use it in GitHub Desktop.
Save averagesecurityguy/7434228 to your computer and use it in GitHub Desktop.
Script to get redirect body sizes.
#!/usr/bin/env python
import requests
import sys
def get_redirect(url):
# Access the URL and process the set-cookie header value.
try:
resp = requests.get(url, timeout=10, allow_redirects=False)
except:
print '[-] Could not access {0}'.format(url)
return None
status = resp.status_code
if (status == 301) or (status == 302):
s = '{0} {1} {2}\n'.format(url, status, len(resp.content))
outfile.write(s)
outfile.flush()
if __name__ == '__main__':
if len(sys.argv) != 2:
print 'Usage: redirect_sizes.py url_file'
sys.exit()
filename = sys.argv[1]
outfile = open('redirects_' + filename, 'w')
for line in open(filename):
url = 'http://' + line.rstrip('\r\n')
get_redirect(url)
outfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment