Incredibly fast crawler designed for OSINT.
Minor refactor (#40)
Connor Skees147a0fa8ab0b
diff --git a/photon.py b/photon.pyindex 0173a13..616ed70 100644--- a/photon.py+++ b/photon.py@@ -25,7 +25,7 @@ machine = sys.platform # Detecting the os of current systemif machine.startswith('os') or machine.startswith('win') or machine.startswith('darwin') or machine.startswith('ios'):colors = False # Colors shouldn't be displayed in mac & windowsif not colors:- end = red = white = green = yellow = run = bad = good = info = que = ''+ end = red = white = green = yellow = run = bad = good = info = que = ''else:end = '\033[1;m'red = '\033[91m'@@ -36,7 +36,7 @@ else:bad = '\033[1;31m[-]\033[1;m'good = '\033[1;32m[+]\033[1;m'info = '\033[1;33m[!]\033[1;m'- que = '\033[1;34m[?]\033[1;m'+ que = '\033[1;34m[?]\033[1;m'# Just a fancy ass bannerprint ('''%s ____ __ __@@ -56,7 +56,7 @@ parser.add_argument('-c', '--cookie', help='cookie', dest='cook')parser.add_argument('-r', '--regex', help='regex pattern', dest='regex')parser.add_argument('-e', '--export', help='export format', dest='export')parser.add_argument('-o', '--output', help='output directory', dest='output')-parser.add_argument('-s', '--seeds', help='additional seed urls', dest='seeds')+parser.add_argument('-s', '--seeds', help='additional seed urls', dest='seeds', nargs="+", default=[])parser.add_argument('--user-agent', help='custom user agent(s)', dest='user_agent')parser.add_argument('-l', '--level', help='levels to crawl', dest='level', type=int)parser.add_argument('--timeout', help='http request timeout', dest='timeout', type=float)@@ -140,7 +140,7 @@ intel = set() # emails, website accounts, aws buckets etc.robots = set() # entries of robots.txtcustom = set() # string extracted by custom regex patternfailed = set() # urls that photon failed to crawl-storage = set() # urls that belong to the target i.e. in-scope+storage = set([s for s in args.seeds]) # urls that belong to the target i.e. in-scopescripts = set() # javascript filesexternal = set() # urls that don't belong to the target i.e. out-of-scopefuzzable = set() # urls that have get params in them e.g. example.com/page.php?id=2@@ -151,12 +151,6 @@ everything = []bad_intel = set() # unclean intel urlsbad_scripts = set() # unclean javascript file urls-seeds = []-if args.seeds: # if the user has supplied custom seeds- seeds = args.seeds- for seed in seeds.split(','): # we will convert them into a list- storage.add(seed) # and them to storage for crawling-# If the user hasn't supplied the root url with http(s), we will handle itif main_inp.startswith('http'):main_url = main_inp@@ -245,7 +239,7 @@ def requester(url):# select a random request function i.e. random APIresponse = random.choice([photopea, normal, pixlr, code_beautify])(url)if response != '':- return response # return response body+ return response # return response bodyelse:return 'dummy'else:@@ -403,7 +397,7 @@ zap(main_url)# Step 2. Crawl recursively to the limit specified in "crawl_level"for level in range(crawl_level):links = storage - processed # links to crawl = all links - already crawled links- if len(links) == 0: # if links to crawl are 0 i.e. all links have been crawled+ if not links: # if links to crawl are 0 i.e. all links have been crawledbreakelif len(storage) <= len(processed): # if crawled links are somehow more than all links. Possible? ;/if len(storage) > 2 + len(seeds): # if you know it, you know it@@ -441,7 +435,7 @@ if not only_urls:intel.add(url)now = time.time() # records the time at which crawling stopped-diff = (now - then) # finds total time taken+diff = (now - then) # finds total time takendef timer(diff):minutes, seconds = divmod(diff, 60) # Changes seconds into minutes and seconds@@ -457,7 +451,7 @@ if not os.path.exists(output_dir): # if the directory doesn't existos.mkdir(output_dir) # create a new directorydatasets = [files, intel, robots, custom, failed, storage, scripts, external, fuzzable, endpoints]-dataset_names = ['files', 'intel', 'robots', 'custom', 'failed', 'links', 'scripts', 'external', 'fuzzable', 'endpoints']+dataset_names = ['files', 'intel', 'robots', 'custom', 'failed', 'links', 'scripts', 'external', 'fuzzable', 'endpoints']def writer(datasets, dataset_names, output_dir):for dataset, dataset_name in zip(datasets, dataset_names):