Incredibly fast crawler designed for OSINT.
Abilitiy to use archive.org's URLs as seeds
Somdev Sangwan05182aea1335
diff --git a/README.md b/README.mdindex 21f2eb7..d48952f 100644--- a/README.md+++ b/README.md@@ -17,9 +17,6 @@ Photon is a lightning fast web crawler which extracts URLs, files, intel & endpo## Main Features-The extensive range of [options](https://github.com/s0md3v/Photon/wiki/Usage) provided by Photon lets you crawl the web exactly the way you want, which is a cool thing on its own.-However, the features of Photon that make it awesome are follows:-#### Data ExtractionPhoton extracts the following data while crawling by default:@@ -34,7 +31,9 @@ Photon extracts the following data while crawling by default:The extracted information is saved in an organized manner.\-#### Intelligent Multithreading+#### Genius+Crawling can be resource intensive but Photon has some tricks up it's sleeves. You can fetch URLs archived by [archive.org](https://archive.org/) to be used as seeds by using `--wayback` option.\+Liked the idea? The extensive range of [options](https://github.com/s0md3v/Photon/wiki/Usage) provided by Photon lets you crawl the web exactly the way you want.\Here's a secret, most of the tools floating on the internet aren't properly multi-threaded even if they are supposed to. They either supply a list of items to threads which results in multiple threads accessing the same item or they simply put a thread lock and end up rendering multi-threading useless.\But Photon is different or should I say "genius"? Take a look at [this](https://github.com/s0md3v/Photon/blob/8b58580df1bdfe5f7b96eaf83957d018418ec8ae/photon.py#L357-L381) and decide yourself.diff --git a/photon.py b/photon.pyindex 037df0b..fb25f6e 100644--- a/photon.py+++ b/photon.py@@ -10,6 +10,7 @@ import warningsimport argparseimport threadingfrom math import log+from tld import get_fldfrom re import search, findallfrom requests import get, post@@ -75,6 +76,7 @@ parser.add_argument('--ninja', help='ninja mode', dest='ninja', action='store_trparser.add_argument('--keys', help='find secret keys', dest='api', action='store_true')parser.add_argument('--update', help='update photon', dest='update', action='store_true')parser.add_argument('--only-urls', help='only extract urls', dest='only_urls', action='store_true')+parser.add_argument('--wayback', help='fetch urls from archive.org as seeds', dest='archive', action='store_true')args = parser.parse_args()####@@ -160,9 +162,11 @@ schema = main_url.split('//')[0] # https: or http:?storage.add(main_url) # adding the root url to storage for crawling-domain_name = urlparse(main_url).netloc # Extracts domain out of the url+host = urlparse(main_url).netloc # Extracts host out of the url-output_dir = args.output or domain_name+domain = get_fld(host, fix_protocol=True) # Extracts top level domain out of the host++output_dir = args.output or host##### This function makes requests to webpage and returns response body@@ -179,7 +183,7 @@ def requester(url):time.sleep(delay) # pause/sleep the program for specified timedef normal(url):headers = {- 'Host' : domain_name, # ummm this is the hostname?+ 'Host' : host, # ummm this is the hostname?'User-Agent' : random.choice(user_agents), # selecting a random user-agent'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Accept-Language' : 'en-US,en;q=0.5',@@ -236,6 +240,17 @@ def requester(url):####def zap(url):+ if args.archive:+ from core.verify import verify+ from plugins.wayback import timeMachine+ print ('%s Fetching URLs from archive.org' % run)+ if False:+ archived_urls = timeMachine(domain, 'domain')+ else:+ archived_urls = timeMachine(host, 'host')+ print ('%s Retrieved %i URLs from archive.org' % (good, len(archived_urls) - 1))+ for url in archived_urls:+ storage.add(url)response = get(url + '/robots.txt', verify=False).text # makes request to robots.txtif '<body' not in response: # making sure robots.txt isn't some fancy 404 pagematches = findall(r'Allow: (.*)|Disallow: (.*)', response) # If you know it, you know it@@ -360,7 +375,7 @@ def extractor(url):else:external.add(link)elif link[:2] == '//':- if link.split('/')[2].startswith(domain_name):+ if link.split('/')[2].startswith(host):storage.add(schema + link)else:external.add(link)@@ -530,7 +545,7 @@ print('%s Average request time: %s seconds' % (info, time_per_request))if args.dns:from plugins.dnsdumpster import dnsdumpster- dnsdumpster(domain_name, output_dir, colors)+ dnsdumpster(domain, output_dir, colors)if args.export:datasets = {diff --git a/plugins/dnsdumpster.py b/plugins/dnsdumpster.pyindex fcb0b93..04a06de 100644--- a/plugins/dnsdumpster.py+++ b/plugins/dnsdumpster.py@@ -1,6 +1,5 @@import reimport requests-from tld import get_flddef dnsdumpster(domain, output_dir, colors):if colors:@@ -16,9 +15,9 @@ def dnsdumpster(domain, output_dir, colors):data = {'csrfmiddlewaretoken': csrf_token, 'targetip': domain}response = requests.Session().post('https://dnsdumpster.com/', cookies=cookies, data=data, headers=headers)- image = requests.get('https://dnsdumpster.com/static/map/%s.png' % get_fld(domain, fix_protocol=True))+ image = requests.get('https://dnsdumpster.com/static/map/%s.png' % domain)if image.status_code == 200:with open('%s/%s.png' % (output_dir, domain), 'wb') as f:f.write(image.content)else:- print ('%s Failed to retrieve DNS image' % run)+ print ('%s Failed to retrieve DNS image' % run)\ No newline at end of filediff --git a/plugins/wayback.py b/plugins/wayback.pynew file mode 100644index 0000000..17d6a79--- /dev/null+++ b/plugins/wayback.py@@ -0,0 +1,11 @@+import json+from requests import get++def timeMachine(host, mode):+ url = '''http://web.archive.org/cdx/search?url=%s&matchType=%s&collapse=urlkey&fl=original&filter=mimetype:text/html&filter=statuscode:200&output=json&from=20180101&to=20181231''' % (host, mode)+ response = get(url).text+ parsed = json.loads(response)[1:]+ urls = []+ for item in parsed:+ urls.append(item[0])+ return urls\ No newline at end of file