Skip to content

Incredibly fast crawler designed for OSINT.

Merge remote-tracking branch 'upstream/master'

oXis6715bf17067a
diff --cc core/requester.py
index 6450933,028b535..11cd8f1
--- a/core/requester.py
+++ b/core/requester.py
@@@ -16,8 -16,6 +16,7 @@@ def requester
headers=None,
timeout=10,
host=None,
- ninja=False,
+ proxies=None,
user_agents=None,
failed=None,
processed=None
diff --cc core/utils.py
index c8e69f9,d7f0d02..0354e7f
--- a/core/utils.py
+++ b/core/utils.py
@@@ -83,10 -79,9 +84,10 @@@ def writer(datasets, dataset_names, out
filepath = output_dir + '/' + dataset_name + '.txt'
with open(filepath, 'w+') as out_file:
joined = '\n'.join(dataset)
- out_file.write(str(joined.encode('utf-8')))
+ out_file.write(str(joined.encode('utf-8').decode('utf-8')))
out_file.write('\n')
+
def timer(diff, processed):
"""Return the passed time."""
# Changes seconds into minutes and seconds
diff --cc photon.py
index 767d6b9,8274db1..f318e92
--- a/photon.py
+++ b/photon.py
@@@ -10,9 -11,23 +11,23 @@@ import sy
import time
import warnings
- import requests
-
-from core.colors import good, info, run, green, red, white, end
+from core.colors import good, info, run, green, red, white, end, bad
+
+ # Just a fancy ass banner
+ print('''%s ____ __ __
+ / %s__%s \/ /_ ____ / /_____ ____
+ / %s/_/%s / __ \/ %s__%s \/ __/ %s__%s \/ __ \\
+ / ____/ / / / %s/_/%s / /_/ %s/_/%s / / / /
- /_/ /_/ /_/\____/\__/\____/_/ /_/ %sv1.2.2%s\n''' %
++ /_/ /_/ /_/\____/\__/\____/_/ /_/ %sv1.3.0%s\n''' %
+ (red, white, red, white, red, white, red, white, red, white, red, white,
+ red, white, end))
+
+ try:
+ from urllib.parse import urlparse # For Python 3
+ except ImportError:
- print ('%s Photon runs only on Python 3.2 and above.' % info)
++ print('%s Photon runs only on Python 3.2 and above.' % info)
+ quit()
+
import core.config
from core.config import INTELS
from core.flash import flash
@@@ -20,44 -35,10 +35,21 @@@ from core.mirror import mirro
from core.prompt import prompt
from core.requester import requester
from core.updater import updater
-from core.utils import top_level, extract_headers, verb, is_link, entropy, regxy, remove_regex, timer, writer
-from core.zap import zap
+from core.utils import (luhn,
+ UrlType,
+ ProxyType,
+ is_good_proxy,
+ top_level,
+ extract_headers,
+ verb, is_link,
+ entropy, regxy,
+ remove_regex,
+ timer,
+ writer)
+from core.regex import rintels, rendpoint, rhref, rscript, rentropy
+from core.zap import zap
- try:
- from urllib.parse import urlparse # For Python 3
- python2, python3 = False, True
- except ImportError:
- from urlparse import urlparse # For Python 2
- python2, python3 = True, False
-
-
- try:
- input = raw_input
- except NameError:
- pass
-
-
- # Just a fancy ass banner
- print('''%s ____ __ __
- / %s__%s \/ /_ ____ / /_____ ____
- / %s/_/%s / __ \/ %s__%s \/ __/ %s__%s \/ __ \\
- / ____/ / / / %s/_/%s / /_/ %s/_/%s / / / /
- /_/ /_/ /_/\____/\__/\____/_/ /_/ %sv1.3.0%s\n''' %
- (red, white, red, white, red, white, red, white, red, white, red, white,
- red, white, end))
-
# Disable SSL related warnings
warnings.filterwarnings('ignore')
@@@ -132,16 -109,6 +122,15 @@@ delay = args.delay or 0 # Delay betwee
timeout = args.timeout or 6 # HTTP request timeout
cook = args.cook or None # Cookie
api = bool(args.api) # Extract high entropy strings i.e. API keys and stuff
- ninja = bool(args.ninja) # Ninja mode toggle
+
+proxies = None
+if args.proxies:
+ proxies = {"http": args.proxies,
+ "https": args.proxies}
+ if not is_good_proxy(proxies):
+ print("%s Proxy doesn't seem to work" % bad)
+ exit()
+
crawl_level = args.level or 2 # Crawling level
thread_count = args.threads or 2 # Number of threads
only_urls = bool(args.only_urls) # Only URLs mode is off by default
@@@ -203,16 -169,13 +191,16 @@@ else
supress_regex = False
- def intel_extractor(response):
+ def intel_extractor(url, response):
"""Extract intel from the response body."""
- matches = re.findall(r'([\w\.-]+s[\w\.-]+\.amazonaws\.com)|([\w\.-]+@[\w\.-]+\.[\.\w]+)', response)
- if matches:
- for match in matches:
- verb('Intel', match)
- intel.add(url + ':' + ''.join(list(match)))
+ for rintel in rintels:
+ res = re.sub(r'<(script).*?</\1>(?s)', '', response)
+ res = re.sub(r'<[^<]+?>', '', res)
+ matches = rintel[0].findall(res)
+ if matches:
+ for match in matches:
+ verb('Intel', match)
+ bad_intel.add((match, rintel[1]))
def js_extractor(response):
@@@ -224,12 -187,22 +212,22 @@@
verb('JS file', match)
bad_scripts.add(match)
+ def remove_file(url):
+ if url.count('/') > 2:
+ replacable = re.search(r'/[^/]*?$', url).group()
+ if replacable != '/':
+ return url.replace(replacable, '')
+ else:
+ return url
+ else:
+ return url
+
def extractor(url):
"""Extract details from the response body."""
- response = requester(url, main_url, delay, cook, headers, timeout, host, ninja, proxies, user_agents, failed, processed)
- response = requester(url, main_url, delay, cook, headers, timeout, host, user_agents, failed, processed)
++ response = requester(url, main_url, delay, cook, headers, timeout, host, proxies, user_agents, failed, processed)
if clone:
mirror(url, response)
- matches = re.findall(r'<[aA][^>]*?(href|HREF)=([^\s>]+)', response)
+ matches = rhref.findall(response)
for link in matches:
# Remove everything after a "#" to deal with in-page anchors
link = link[1].replace('\'', '').replace('"', '').split('#')[0]
@@@ -271,9 -250,9 +275,9 @@@
def jscanner(url):
"""Extract endpoints from JavaScript code."""
- response = requester(url, main_url, delay, cook, headers, timeout, host, ninja, proxies, user_agents, failed, processed)
- response = requester(url, main_url, delay, cook, headers, timeout, host, user_agents, failed, processed)
++ response = requester(url, main_url, delay, cook, headers, timeout, host, proxies, user_agents, failed, processed)
# Extract URLs/endpoints
- matches = re.findall(r'[\'"](/.*?)[\'"]|[\'"](http.*?)[\'"]', response)
+ matches = rendpoint.findall(response)
# Iterate over the matches, match is a tuple
for match in matches:
# Combining the items because one of them is always empty