forked from em-corp/f0x
-
Notifications
You must be signed in to change notification settings - Fork 2
/
f0x.py
executable file
·982 lines (744 loc) · 30.2 KB
/
f0x.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__NAME__ = "f0x.py"
__VERSION__ = "2.0"
import argparse
import re
import os
import time
import json
import threading
import asyncio
import random
from proxybroker import Broker
from concurrent.futures import ThreadPoolExecutor
from git import Repo
from lib.prettyPrint import Prettify as pp
from lib.config import ConfigManager as conf
from lib.utils import DirUtil as dutil
from lib.utils import FileUtil as futil
from lib.google import GoogleSearch as gsrch
from lib.utils import Random as rand
from lib.useragents import UA
def banner():
print(pp.green(' .o88o. .o o.'))
print(pp.green(' 888 `" .8\' `8.'))
print(pp.green(' o888oo .8\' ' + pp.yellow('oooo ooo') + ' `8.'))
print(pp.green(' 888 88 ' + pp.yellow('`88b..8P') + ' 88'))
print(pp.green(' 888 88 ' + pp.yellow('Y888') + ' 88'))
print(pp.green(' 888 `8. ' + pp.yellow('.o8"\'88b') + ' .8\''))
print(pp.green(' o888o `8. ' + pp.yellow('o88\' 888o') + ' .8\''))
print()
parser = argparse.ArgumentParser()
# input
parser.add_argument('-d', '--domain', help='Specify Target domain.',
dest='domain')
parser.add_argument('-q', '--query', help='Specify query/dork manually, and' +
' don\'t use more dorks from dorks-db.', dest='query')
parser.add_argument('-n', '--no-stop', help='Works with `--query`, If ' +
'specified dorks from dorks-db will also be used along ' +
'with manually supplied dork.', dest='query_nostop',
action="store_true")
parser.add_argument('-Q', '--query-args', help='Specify extra query to ' +
'supply with each dorks.', dest='ex_query')
# dork selection
parser.add_argument('-c', '--category', help='Comma (,) separated dorks ' +
'categories to use.', dest='category')
parser.add_argument('-cA', '--any', help='Use all available categories.',
dest='cat_any', action="store_true")
parser.add_argument('-S', '--severity', help='Comma (,) separated severity ' +
'range(from 1 to 10). eg. consider range expansion as : ' +
'"-4" will become "1,2,3,4", or ' +
'"2-5" will become "2,3,4,5", or ' +
'"7-" will become "7,8,9,10", or ' +
'"1-4,7" will become "1,2,3,4,7".', dest='severity')
parser.add_argument('-SQ', '--quality', help='Only use quality dorks ' +
'i.e. with `severity >= 7`.', dest='sev_quality',
action="store_true")
parser.add_argument('-SA', '--all', help='Use all available severities.',
dest='sev_all', action="store_true")
# optimize fox
parser.add_argument('-t', '--threads', help='Max parallel threads ' +
'(Default: 3).', type=int, dest='threads')
parser.add_argument('-p', '--proxy', help="Specify proxy to use.", dest='proxy')
parser.add_argument('-pF', '--proxy-file', help='Specify file to read proxies '
+'list (one per line).', dest='proxy_file')
parser.add_argument('-pO', '--open-proxies', help='Make use of open public ' +
'proxies.', dest='proxy_open', action='store_true')
parser.add_argument('-pC', '--open-proxies-count', help='Try collecting ' +
'`n` open proxies. (Default: 20)', dest='proxy_count',
type=int)
parser.add_argument('-C', '--conn', help='Max connections per proxy ' +
'(Default: 2).', dest='proxy_conn', type=int)
parser.add_argument('--no-ssl-check', help='Disable certificate check.',
dest='no_ssl_check', action='store_true')
parser.add_argument('--timeout', help='Set request timeout.', dest='time_out',
type=int)
parser.add_argument('-m', '--min-delay', help='Specify minimum delay(sec) ' +
'between requests. (Default: `max-delay` - 3)s.',
dest='delay_min', type=int)
parser.add_argument('-M', '--max-delay', help='Specify maximum delay(sec) ' +
'between requests. (Default: `min-delay` + 3)s.',
dest='delay_max', type=int)
parser.add_argument('-w', '--wait', help='Specify fix delay(sec) between ' +
'requests (Default: 1s).', dest='delay', type=int)
parser.add_argument('-U', '--user-agent', help='Specify User Agent.', dest='ua')
parser.add_argument('--update', help='Update dorks repo and exit.',
dest='repo_update', action="store_true")
parser.add_argument('-v', '--verbose', help='Be verbose.', dest='verbose',
action="store_true")
parser.add_argument('-V', '--version', help='Display version info and exit.',
dest='version', action="store_true")
parser.add_argument('-r', '--results', help='Dork results to fetch in one ' +
'page request (Default: 30).', dest='page_size', type=int)
parser.add_argument('-R', '--requests', help='Pages to request for each ' +
'dork (Default: 5).', dest='no_of_pages', type=int)
parser.add_argument('-T', '--max-results', help='Maximum results to fetch ' +
'for all the dorks combined.', dest='max_results', type=int)
# output filters
parser.add_argument('-l', '--list-dorks', help='List all dorks to be used ' +
'and exit. Specify `category` or `severity` to narrow ' +
'down the list. ', dest='list_dorks', action="store_true")
parser.add_argument('-L', '--categories', help='List available categories ' +
'and exit.', dest='list_cat', action="store_true")
parser.add_argument('-o', '--outdir', help='Specify output directory.',
dest='out_dir')
parser.add_argument('-oJ', '--out-json', help='Save output in JSON format.',
dest='out_fmt_json', action="store_true")
parser.add_argument('-oX', '--out-xml', help='Save output in XML format.',
dest='out_fmt_xml', action="store_true")
parser.add_argument('-oR', '--out-report', help='Create html report with ' +
'JSON format results.', dest='out_report',
action="store_true")
parser.add_argument('--silent', help='Do not print fetched links to stdout, ' +
'just save them in file.', dest='out_silent',
action='store_true')
args = parser.parse_args()
if args.version:
print("{} v{}".format(pp.as_bold(pp.red(__NAME__)), pp.blue(__VERSION__)))
quit()
banner()
class F0x:
def __init__(self, verbose=False):
self._conn_per_proxy_count = None
self._proxy_ptr = -1
self._out_fmt_json = 1 << 0
self._out_fmt_xml = 1 << 1
self._out_report = 1 << 2
self._outmode = 0
self._proxy_lock = threading.Lock()
self._count_lock = threading.Lock()
self.verbose = verbose
self.severities = None
self.categories = None
self.domain = None
self.query = None
self.ex_args = None
self.process_dorksdb_flag = True
self.useragent = None
self.threads = 3
self.delay_min = 1
self.delay_max = 1
self.connection_per_proxy = 2
self.proxies_list = None
self.request_timeout = None
self.ssl_check = True
self.open_proxy_count = 20
self.page_size = gsrch.correct_page_size(30)
self.no_of_pages = 5
self.max_results = None
self.outdir = None
self.out_silent = False
self.results_count = 0
self._load_conf()
def _load_conf(self):
conf.load('./f0x.config')
if self.is_verbose():
pp.p_debug("Loaded Config file, keys: {}"
.format(self.get_conf().getKeys()))
def get_conf(self):
return conf.getConfig()
def is_verbose(self):
return self.verbose
def set_categories(self, categories=None):
self.categories = categories
def get_categories(self):
return self.categories
def set_severities(self, severities=None):
self.severities = severities
def get_severities(self):
return self.severities
def set_domain(self, domain):
self.domain = domain
def get_domain(self):
return self.domain
def set_query(self, query):
self.query = query
def get_query(self):
return self.query
def set_ex_args(self, ex_args):
self.ex_args = ex_args
def get_ex_args(self):
return self.ex_args
def set_useragent(self, useragent):
self.useragent = useragent
def get_useragent(self):
return self.useragent
def set_process_dorksdb_flag(self, flag):
self.process_dorksdb_flag = flag
def get_process_dorksdb_flag(self):
return self.process_dorksdb_flag
def set_threads(self, threads):
self.threads = threads
def get_threads(self):
return self.threads
def set_delay_min(self, delay_min):
self.delay_min = delay_min
def get_delay_min(self):
return self.delay_min
def set_delay_max(self, delay_max):
self.delay_max = delay_max
def get_delay_max(self):
return self.delay_max
def set_connection_per_proxy(self, conn):
self.connection_per_proxy = conn
def get_connection_per_proxy(self):
return self.connection_per_proxy
def add_proxy(self, proxy):
if not self.proxies_list:
self.proxies_list = []
self._conn_per_proxy_count = []
self.proxies_list += [proxy]
self._conn_per_proxy_count += [0]
def get_proxy_list(self):
return self.proxies_list
def set_page_size(self, page_size):
self.page_size = page_size
def get_page_size(self):
return self.page_size
def set_no_of_pages(self, no_of_pages):
self.no_of_pages = no_of_pages
def get_no_of_pages(self):
return self.no_of_pages
def set_max_results(self, max_results):
self.max_results = max_results
def get_max_results(self):
return self.max_results
def set_outdir(self, outdir):
self.outdir = outdir
def get_outdir(self):
return self.outdir
def set_outmode_json(self):
self._outmode |= self._out_fmt_json
def set_outmode_xml(self):
self._outmode |= self._out_fmt_xml
def set_outmode_report(self):
self._outmode |= self._out_report
def get_outmode_json(self):
return (self._outmode & self._out_fmt_json) == self._out_fmt_json
def get_outmode_xml(self):
return (self._outmode & self._out_fmt_xml) == self._out_fmt_xml
def get_outmode_report(self):
return (self._outmode & self._out_report) == self._out_report
def set_output_silent(self, flag):
self.out_silent = flag
def is_output_silent(self):
return self.out_silent
def set_results_count(self, count):
self.results_count = count
def get_results_count(self):
return self.results_count
def set_request_timeout(self, timeout):
self.request_timeout = timeout
def get_request_timeout(self):
return self.request_timeout
def set_ssl_check(self, ssl_check):
self.ssl_check = ssl_check
def do_ssl_check(self):
return self.ssl_check
def set_open_proxy_count(self, count):
self.open_proxy_count = count
def get_open_proxy_count(self):
return self.open_proxy_count
async def _record_proxy(self, proxies):
while True:
proxy = await proxies.get()
if proxy is None:
break
proto = 'https' if 'HTTPS' in proxy.types else 'http'
proxy_url = '%s://%s:%d' % (proto, proxy.host, proxy.port)
self.add_proxy(proxy_url)
if fox.is_verbose():
pp.p_log("Found proxy: {}".format(pp.light_green(proxy_url)))
def collect_open_proxies(self):
proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(broker.find(types=['HTTP', 'HTTPS'],
limit=self.get_open_proxy_count()),
self._record_proxy(proxies))
loop = asyncio.get_event_loop()
loop.run_until_complete(tasks)
def update_dorks_repo(self):
pp.p_log("Building Dork Repo.")
repo_url = self.get_conf().get('repo_url')
pp.p_log("Fetching from '{}'".format(repo_url))
tmpdir = dutil.create_temp_dir('f0x', 'repo_')
Repo.clone_from(repo_url, tmpdir)
pp.p_log("Done Fetching.")
rmdirs = ['.git']
rmfiles = ['README.md', 'LICENSE']
for i in rmdirs:
try:
g = dutil.get_dir(tmpdir, i)
except:
pass
else:
dutil.rmdir(g)
for i in rmfiles:
try:
f = futil.get_file(tmpdir, i)
except:
pass
else:
os.remove(f)
try:
dutil.merge_dirs(tmpdir, self.get_dork_path())
except Exception as e:
pp.p_error(e)
quit()
pp.p_log("Dork Repo updated.")
def get_dork_path(self):
dp = ''
flag = False
try:
dp = self.get_conf().get('dork_path')
except:
pp.p_error("Dorks path not exists.")
flag = True
else:
if dp == '':
pp.p_error("Dorks path not defined.")
flag = True
if flag:
raise Exception("Error in Config file.")
if dp.startswith('~'):
dp = os.path.expanduser(dp)
elif dp.startswith('/'):
pass
elif dp.startswith('./'):
cwd = os.path.realpath('.')
dp = dutil.join_names(cwd, dp[2:])
else:
cwd = os.path.realpath('.')
dp = dutil.join_names(cwd, dp)
return dp
def list_repo_categories(self):
dp = None
try:
dp = self.get_dork_path()
except Exception as e:
pp.p_error(e)
quit()
dl = dutil.get_dir_list(dp, True)
if len(dl) == 0:
pp.p_log("No Dorks available, Update dork repo.")
return
for i in dl:
dc = re.sub('^{}[/]?'.format(dp), '', i)
dc = re.sub('/', '.', dc)
td = len(dutil.get_files_list(i, True))
pp.p_log("Category: {}".format(dc))
pp.p_log("Total Dorks: {}\n".format(td), '**')
def list_dorks(self):
cat = None
sev = None
if self.get_categories():
cat = self.get_categories()
else:
cat = [""]
if self.get_severities():
sev = self.get_severities()
else:
sev = range(1, 11)
for c in cat:
for d in self.get_dorks(c, sev):
pp.p_log(d)
def get_dorks(self, category, sev_list):
dorks = []
dpath = None
chome = ''
if not sev_list or len(sev_list) == 0:
return dorks
try:
dpath = self.get_dork_path()
except Exception as e:
pp.p_error(e)
return []
if category:
chome = re.sub('\.', '/', category)
dpath = dutil.get_dir(dpath, chome)
for i in dutil.get_files_list(dpath, True):
with open (i, 'r') as dfile:
d = None
j = None
for l in dfile:
if l.lstrip().lower().startswith('googledork:'):
d = re.sub('^googledork:', '', l.lstrip().lower())
d = d.strip()
elif l.lstrip().lower().startswith('severity:'):
j = re.sub('^severity:', '', l.lstrip().lower())
j = j.strip()
elif (not d) and l.lstrip().lower().startswith('dork:'):
d = re.sub('^dork:', '', l.lstrip().lower())
d = d.strip()
if d and j:
break
if j and int(j) in sev_list and d:
dorks.append(d)
return dorks
def fetch_page_response(self, dork, pagenum, proxy):
gurl = gsrch.prepare_URL(dork, self.get_domain(), self.get_query(),
pagenum, self.get_page_size())
ua = None
if self.get_useragent():
ua = self.get_useragent()
else:
ua = UA.get_random_ua()
return gsrch.fetch(gurl, ua, proxy, self.get_request_timeout(),
self.do_ssl_check())
def save_links(self, dork, dname, pnum, links_list):
if not self.get_outdir():
for l in links_list:
pp.p_log(l)
return dname
append = True
if pnum == 1:
append = False
dname = dutil.create_random_dir(self.get_outdir(), dname)
dname = re.sub('^{}[/]?'.format(self.get_outdir()), '', dname)
futil.dump_list(futil.
join_names(dutil.get_dir(self.get_outdir(),
dname),
"{}.info".format(dname)),
["dork: {}".format(dork)], append)
futil.dump_list(futil.
join_names(dutil.get_dir(self.get_outdir(), dname),
"{}.txt".format(dname)), links_list, append)
if not self.is_output_silent():
for l in links_list:
pp.p_log(l)
return dname
def update_results_stats(self, c):
with self._count_lock:
self.set_results_count(self.get_results_count() + c)
def can_fetch_more(self):
if self.get_max_results():
return self.get_results_count() < self.get_max_results()
return True
def get_proxy_object(self):
proxy = {'proxy': None, 'loc': None}
p = None
l = None
if self.get_proxy_list():
pl = len(self.get_proxy_list())
c = 0
with self._proxy_lock:
while True:
c += 1
self._proxy_ptr += 1
if self._proxy_ptr == pl:
self._proxy_ptr = 0
if self._conn_per_proxy_count[self._proxy_ptr] < \
self.get_connection_per_proxy():
p = self.get_proxy_list()[self._proxy_ptr]
self._conn_per_proxy_count[self._proxy_ptr] += 1
l = self._proxy_ptr
break
if c >= pl:
c = 0
time.sleep((self.get_delay_min() *
self.get_no_of_pages()) / 4)
if p:
proxy = {'proxy': {'http': p, 'https': p}, 'loc': l}
return proxy
def release_proxy(self, proxyobj):
l = proxyobj['loc']
try:
if (l or int(l) == 0) and self._conn_per_proxy_count[l] != 0:
self._conn_per_proxy_count[l] -= 1
except:
pass
def process_dork(self, dork):
if self.is_verbose():
pp.p_debug("Processing dork: {}".format(dork))
dname = "dork{}".format(int(random.random() * 1000))
proxy = self.get_proxy_object()
for p in range(1, self.get_no_of_pages() + 1):
if not self.can_fetch_more():
break
time.sleep(rand.rand_between(self.get_delay_min(),
self.get_delay_max()))
response = None
try:
response = self.fetch_page_response(dork, p, proxy['proxy'])
except Exception as e:
self.release_proxy(proxy)
gsrch.session_cleanup()
pp.p_error(e)
return
if self.is_verbose():
pp.p_debug("Fetched page : {}".format(p))
links = gsrch.extract_urls(response)
if self.is_verbose():
pp.p_debug("Found {} url(s).".format(len(links)))
dname = self.save_links(dork, dname, p, links)
self.update_results_stats(len(links))
if not gsrch.has_next(response):
break
self.release_proxy(proxy)
gsrch.session_cleanup()
def execute(self):
dorks = []
if self.get_query():
dorks += [self.get_query()]
if self.get_process_dorksdb_flag():
cat = []
if self.get_categories():
cat = self.get_categories()
for c in cat:
dorks += self.get_dorks(c, self.get_severities())
if self.is_verbose():
pp.p_debug("{} dorks to fetch.".format(len(dorks)))
with ThreadPoolExecutor(max_workers=self.get_threads()) as exec:
exec.map(self.process_dork, dorks)
self.make_report()
def make_report(self):
if not self.get_outdir():
return
if not (self.get_outmode_json() or self.get_outmode_report() or
self.get_outmode_xml()):
return
fdr = None
if self.get_outmode_report():
fdr = open(futil.join_names(self.get_outdir(), 'index.html') , 'w')
fdr.write('<!DOCTYPE html> <html><head><title>f0x Report: links' +
'</title></head><body>')
for ddir in dutil.get_dir_list(self.get_outdir()):
dname = re.sub('^{}[/]?'.format(self.get_outdir()), '', ddir)
links = futil.get_file_aslist(
futil.get_file(ddir, "{}.txt".format(dname)))
if self.get_outmode_json():
with open(futil.join_names(ddir, '{}.json'.format(dname)),
'w') as fd:
fd.write(json.dumps({'urls': links}))
try:
fdh = None
fdx = None
if self.get_outmode_report():
fdh = open(futil.join_names(ddir, '{}.html'.format(dname)),
'w')
if self.get_outmode_xml():
fdx = open(futil.join_names(ddir, '{}.xml'.format(dname)),
'w')
except Exception as e:
pp.p_error(e)
else:
if fdh:
fdh.write('<!DOCTYPE html> <html><head><title>dork urls' +
'</title></head><body>')
if fdx:
fdx.write('<?xml version="1.0" ?><urls>')
for link in links:
if fdh:
fdh.write('<a href="{}">{}</a><br/>'.format(link, link))
if fdx:
fdx.write('<url>{}</url>'.format(link))
if fdx:
fdx.write('</urls>')
if fdh:
fdh.write('</body></html>')
if fdr:
fdr.write(('dork: <a href="{}/{}.html">{}</a> urls ' +
'fetched: {}<br/>').format(dname, dname, dname,
len(links)))
finally:
if fdh:
fdh.close()
if fdx:
fdx.close()
if fdr:
fdr.write('</body></html>')
fdr.close()
fox = F0x(verbose=args.verbose)
if args.repo_update:
fox.update_dorks_repo()
quit()
if args.list_cat:
fox.list_repo_categories()
quit()
flag_dork_selector = False
if args.severity:
flag_dork_selector = True
s = []
l = "1"
m = "10"
if re.search("[^0-9,-]", args.severity):
pp.p_error("Severity value can only contains numbers or numeral " +
"range, separated by comma (,).")
quit()
for i in args.severity.split(','):
j = i
if i.startswith('-'):
j = l + i
elif i.endswith('-'):
j = i + m
k = j.split('-')
for x in range(int(k[0]), int(k[-1]) + 1):
s += [x]
s = list(set(s))
fox.set_severities(s)
if args.sev_all:
flag_dork_selector = True
s = []
for x in range(1, 11):
s += [x]
fox.set_severities(s)
if args.severity and args.sev_all and fox.is_verbose():
pp.p_debug("Provided severity range is overridden by `all` switch.")
if args.sev_quality:
flag_dork_selector = True
s = []
for x in range(7, 11):
s += [x]
fox.set_severities(s)
if (args.severity or args.sev_all) and args.sev_quality and fox.is_verbose():
pp.p_debug("Provided severity (range | `all` switch) is overridden by " +
"`quality` switch.")
if args.category:
flag_dork_selector = True
fox.set_categories(args.category.split(','))
if args.cat_any:
flag_dork_selector = True
fox.set_categories(["."])
if args.category and args.cat_any and fox.is_verbose():
pp.p_debug("Provided categories value is overridden by `any` switch.")
if args.list_dorks:
fox.list_dorks()
quit()
if args.query:
flag_dork_selector = True
fox.set_query(args.query.strip())
fox.set_process_dorksdb_flag(args.query_nostop)
if not flag_dork_selector:
pp.p_error('Please provide atleast one dork selector from ' +
'`category`, `severity` or `query`.')
quit()
if args.domain:
domain = args.domain.strip()
domain = re.sub(r'^http(s)?://(www\.)?', '', domain)
domain = re.sub('/.*(/)?', '', domain)
fox.set_domain(domain)
if args.ex_query:
fox.set_ex_args(args.ex_query.strip())
if args.ua:
fox.set_useragent(args.ua.strip())
if args.threads:
if args.threads > 0:
fox.set_threads(args.threads)
else:
pp.p_error("Please provide some +ve value for threads.")
quit()
if args.delay:
if args.delay > 0:
fox.set_delay_min(args.delay)
fox.set_delay_max(args.delay)
else:
pp.p_error("Please provide some +ve value for delay.")
quit()
if args.delay_min:
if args.delay_min > 0:
fox.set_delay_min(args.delay_min)
fox.set_delay_max(args.delay_min + 3)
else:
pp.p_error("Please provide some +ve value for delay_min.")
quit()
if args.delay_max:
if args.delay_max > 0:
fox.set_delay_max(args.delay_max)
if args.delay_max - 3 > 0:
fox.set_delay_min(args.delay_max - 3)
else:
fox.set_delay_min(0)
else:
pp.p_error("Please provide some +ve value for delay_max.")
quit()
if args.delay_min and args.delay_max:
fox.set_delay_min(args.delay_min)
fox.set_delay_max(args.delay_max)
if args.page_size:
if args.page_size <= 0:
pp.p_error("Please provide some +ve value for `dork results`.")
quit()
fox.set_page_size(gsrch.correct_page_size(args.page_size))
if args.no_of_pages:
if args.no_of_pages <= 0:
pp.p_error("Please provide some +ve value for `pages to request`.")
quit()
fox.set_no_of_pages(int(args.no_of_pages))
if args.max_results:
if args.max_results <= 0:
pp.p_error("Please provide some +ve value for `max results`.")
quit()
fox.set_max_results(args.max_results)
if ((args.out_fmt_json or args.out_fmt_xml or args.out_report) and
not args.out_dir):
pp.p_error("Output format is defined without specifying output directory.")
quit()
if args.out_silent and not args.out_dir:
pp.p_warn("Can't silent links output, as no output directory defined " +
"to save them.")
if args.out_silent:
fox.set_output_silent(True)
if args.out_dir:
fox.set_outdir(args.out_dir.strip())
if args.out_fmt_json:
fox.set_outmode_json()
if args.out_fmt_xml:
fox.set_outmode_xml()
if args.out_report:
fox.set_outmode_report()
if args.no_ssl_check:
fox.set_ssl_check(False)
if args.time_out:
if args.time_out <= 0:
pp.p_error("Please provide some +ve value for `request timeout`.")
quit()
fox.set_request_timeout(args.time_out)
if args.proxy_conn:
if args.proxy_conn > 0:
fox.set_connection_per_proxy(args.proxy_conn)
else:
pp.p_error("Please provide some +ve value for connection per proxy.")
if args.proxy_open and (args.proxy or args.proxy_file):
pp.p_error("Please use only one option from `open proxies` or " +
"(proxy and proxy_file).")
quit()
if args.proxy and args.proxy_file:
pp.p_error("Please use only one option from proxy or proxy_file.")
quit()
if args.proxy:
fox.add_proxy(args.proxy.strip())
if args.proxy_file:
for i in futil.get_file_aslist(args.proxy_file):
fox.add_proxy(i)
if args.proxy_count:
if args.proxy_count <= 0:
pp.p_error("Please provide some +ve value for `open proxy count`.")
quit()
fox.set_open_proxy_count(args.proxy_count)
if fox.is_verbose() and not args.proxy_open:
pp.p_info('Ignoring `open proxy count` as provided without ' +
'enabling `open proxies` switch.')
if args.proxy_open:
fox.collect_open_proxies()
fox.execute()