Skip to content

Instantly share code, notes, and snippets.

@parmanand99
Forked from mhmdiaa/waybackurls.py
Last active May 22, 2021 12:35
Show Gist options
  • Save parmanand99/ee2359a88edefa9b71b814875805e7fe to your computer and use it in GitHub Desktop.
Save parmanand99/ee2359a88edefa9b71b814875805e7fe to your computer and use it in GitHub Desktop.
import requests
import sys
import json
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)
json_urls = json.dumps(urls)
if urls:
filename = '%s-waybackurls.txt' % host
with open(filename, 'w') as f:
f.write(json_urls)
print("/n")
print('[*] Saved results to %s' % filename)
f1=open(filename,"r+")
input=f1.read()
input=input.replace(',','\n')
f2=open(filename,"w+")
f2.write(input)
f1.close()
f2.close()
else:
print('[-] Found nothing')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment