-
-
Save Lopseg/23b8ebd518ac160b9af7c16b4e411d2c to your computer and use it in GitHub Desktop.
Lopseg forked version of waybackurls.py
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/python2 | |
import requests | |
import sys | |
import json | |
import os | |
all_urls = [] | |
urls_wparams = [] | |
def create_report(all_data,parameters): | |
report = """ | |
<html> | |
<body> | |
<p><h1>WAYBACKURL REPORT FOR: %s </1></p> | |
<h2>Urls with parameters</h2> | |
<div> | |
<table> | |
<tr> | |
%s | |
</tr> | |
</table> | |
</div> | |
<h2>Urls without parameters</h2> | |
<div> | |
<table> | |
<tr> | |
%s | |
</tr> | |
</table> | |
</div> | |
</body> | |
</html> | |
""" % (sys.argv[1],all_data,parameters) | |
return report | |
def waybackurls(host, with_subs): | |
if with_subs: | |
url = 'http://web.archive.org/cdx/search/cdx?url=*.%s/*&output=json&fl=original&collapse=urlkey' % host | |
else: | |
url = 'http://web.archive.org/cdx/search/cdx?url=%s/*&output=json&fl=original&collapse=urlkey' % host | |
r = requests.get(url) | |
results = r.json() | |
return results[1:] | |
if __name__ == '__main__': | |
argc = len(sys.argv) | |
if argc < 2: | |
print('Usage:\n\tpython3 waybackurls.py <url> <include_subdomains:optional>') | |
sys.exit() | |
host = sys.argv[1] | |
with_subs = False | |
if argc > 3: | |
with_subs = True | |
urls = waybackurls(host, with_subs) | |
if urls: | |
filename = '%s-waybackurls.html' % host | |
with open(filename, 'w') as f: | |
for line in urls: | |
if "?" in str(line)[3:-2]: | |
urls_wparams.append("<tr><td><a href='"+str(line)[3:-2]+"' target='_blank' rel='noopener noreferrer'>"+str(line)[3:-2]+"</a></td></tr>") | |
continue | |
all_urls.append("<tr><td><a href='"+str(line)[3:-2]+"' target='_blank' rel='noopener noreferrer'>"+str(line)[3:-2]+"</a></td></tr>") | |
f.write(create_report(''.join(urls_wparams),''.join(all_urls))) | |
print('[*] Saved results to %s' % filename) | |
else: | |
print('[-] Found nothing') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment