Created
November 12, 2013 16:42
-
-
Save averagesecurityguy/7434228 to your computer and use it in GitHub Desktop.
Script to get redirect body sizes.
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
#!/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