-
Notifications
You must be signed in to change notification settings - Fork 3
/
exploit.py
5153 lines (4686 loc) · 233 KB
/
exploit.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
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#-*- coding:utf-8 -*-
import time
import pdb
import re
import os
import sys
exp10it_module_path = os.path.expanduser("~")+"/exp10it"
sys.path.insert(0, exp10it_module_path)
import warnings
from concurrent import futures
from urllib.parse import urlparse
from colorama import Fore
from exp10it import figlet2file
from exp10it import get_string_from_command
from exp10it import CLIOutput
from exp10it import get_key_value_from_config_file
from exp10it import update_config_file_key_value
from exp10it import check_string_is_ip
from exp10it import check_string_is_domain
from exp10it import get_input_intime
from exp10it import get_http_domain_from_url
from exp10it import MyThread
from exp10it import keep_session
from exp10it import get_root_domain
from exp10it import Xcdn
from exp10it import install_medusa
from exp10it import get_request
#from exp10it import mail_msg_to
from exp10it import get_csrf_token_value_from_html
from exp10it import get_remain_time
from exp10it import get_string_from_url_or_picfile
from exp10it import get_user_and_pass_form_from_html
from exp10it import get_yanzhengma_form_and_src_from_url
from exp10it import get_url_has_csrf_token
from exp10it import get_value_from_url
from exp10it import get_server_type
from exp10it import jie_di_qi_crack_ext_direct_webshell_url
from exp10it import crack_ext_direct_webshell_url
from exp10it import get_ip_domains_list
from exp10it import get_ip
from exp10it import get_http_or_https
from exp10it import save_url_to_file
from exp10it import get_target_script_type
from exp10it import like_admin_login_content
from exp10it import module_exist
from exp10it import get_webshell_suffix_type
from exp10it import check_webshell_url
from exp10it import COMMON_NOT_WEB_PORT_LIST
from exp10it import post_request
from exp10it import seconds2hms
from exp10it import get_user_and_pass_form_from_url
import pymysql
pymysql.install_as_MySQLdb()
def scan_init():
# 这个函数用于配置exp10itScanner要用到的参数
global DB_NAME
global DB_SERVER
global DB_USER
global DB_PASS
global DELAY
import os
if not os.path.exists(CONFIG_PATH):
os.system("mkdir %s" % CONFIG_PATH)
if not os.path.exists(CONFIG_INI_PATH):
os.system("touch %s" % CONFIG_INI_PATH)
else:
# 如果配置文件存在则不运行这个函数
return
with open(CONFIG_INI_PATH, 'r+') as f:
content = f.read()
# 下面配置BingAPI用于获取旁站的需要
# 不再用bing接口查询旁站,因为bing关闭这个接口了
'''
if re.search(r"bingapikey", content):
pass
else:
print("please input your bing api key:")
key = input()
update_config_file_key_value(CONFIG_INI_PATH, 'default', 'bingapikey', "'" + key + "'")
'''
# 下面配置邮件通知相关口令
if re.search(r"mailto", content):
mailto = eval(get_key_value_from_config_file(
CONFIG_INI_PATH, 'mail', 'mailto'))
else:
mailto = input("please input email address you want send to:")
update_config_file_key_value(
CONFIG_INI_PATH, 'mail', 'mailto', "'" + mailto + "'")
if re.search(r"user", content):
user = eval(get_key_value_from_config_file(
CONFIG_INI_PATH, 'mail', 'user'))
else:
user = input("please input your email account:")
update_config_file_key_value(
CONFIG_INI_PATH, 'mail', 'user', "'" + user + "'")
if re.search(r"password", content):
password = eval(get_key_value_from_config_file(
CONFIG_INI_PATH, 'mail', 'password'))
else:
password = input("please input your email account password:")
update_config_file_key_value(
CONFIG_INI_PATH, 'mail', 'password', "'" + password + "'")
# 下面配置数据库相关设置
config_file_abs_path = CONFIG_INI_PATH
while 1:
DB_SERVER = input("please input your database server addr:>")
if check_string_is_ip(DB_SERVER) or check_string_is_domain(DB_SERVER):
update_config_file_key_value(config_file_abs_path, 'default',
'DB_SERVER', "'" + DB_SERVER + "'")
break
else:
print("your input may not be a regular ip addr:(")
continue
print("DB_SERVER:" + DB_SERVER)
DB_USER = input("please input your database username:>")
update_config_file_key_value(
config_file_abs_path, 'default', 'DB_USER', "'" + DB_USER + "'")
print("DB_USER:" + DB_USER)
DB_PASS = input("please input your database password:>")
update_config_file_key_value(
config_file_abs_path, 'default', 'DB_PASS', "'" + DB_PASS + "'")
print("DB_PASS:" + DB_PASS)
# 下面配置全局扫描中的每两次访问的时间间隔,DELAY参数
if re.search(r"DELAY", content):
pass
else:
print(
"please input your DELAY time (seconds) between every two requests [default 0]\n>")
# 默认0s间隔
DELAY = int(get_input_intime(0))
update_config_file_key_value(
config_file_abs_path, 'default', 'DELAY', int(DELAY))
# 下面配置全局是否要求必须可连通google才工作,forcevpn参数
if re.search(r"forcevpn", content):
pass
else:
print('''Do you want to work with vpn connected(can visit google)?
input 0 if you don't want,
input 1 if you want
I suggest you input 1 unless you don't need cdn recgnization or don't care about the result of cdn recgnization''')
#forcevpn = get_input_intime(1)
forcevpn = input("> ")
if forcevpn != "0":
update_config_file_key_value(
config_file_abs_path, 'default', 'forcevpn', 1)
else:
update_config_file_key_value(
config_file_abs_path, 'default', 'forcevpn', int(forcevpn))
# 下面配置扫描是否为"强制询问cookie"模式
# 强制询问cookie模式要求用户手动选择是否输入cookie
# 非强制询问cookie模式不要求用户手动选择是否输入cookie,默认选择不输入cookie
# 两种模式最终都是使用更新后的配置文件中的cookie
print("请选择使用什么模式:\n0.非强制询问cookie模式\n(非强制询问cookie模式不要求用户手动选择是否输入cookie,默认选择不输入cookie)\n1.\
强制询问cookie模式\n(强制询问cookie模式要求用户手动选择是否输入cookie)\n\n两种模式最终都是使用更新后的配置文件中的cookie")
print("请输入你的选择 0 for 1,default 0")
force_ask_cookie = get_input_intime(0)
if force_ask_cookie != "1":
update_config_file_key_value(
config_file_abs_path, 'default', 'force_ask_cookie', 0)
else:
update_config_file_key_value(
config_file_abs_path, 'default', 'force_ask_cookie', int(force_ask_cookie))
def scan_way_init():
global SCAN_WAY
exist_scan_way = 0
if os.path.exists(CONFIG_INI_PATH):
with open(CONFIG_INI_PATH, "r+") as f:
config_file_string = f.read()
if re.search("SCAN_WAY.*=\D*\d+", config_file_string, re.I):
exist_scan_way = eval(get_key_value_from_config_file(
CONFIG_INI_PATH, 'default', 'scan_way'))
if exist_scan_way != 0:
default_choose = exist_scan_way
else:
default_choose = 1
else:
default_choose = 1
print('''1>scan targets and targets' pang domains
2>scan targets and targets' sub domains
3>scan targets and targets' pang domains and sub domains
4>scan targets without pang and without sub domains''')
print("please input your chioce,default [%s]" % str(default_choose))
#choose = get_input_intime(str(default_choose))
choose = input("> ")
if choose != str(default_choose):
update_config_file_key_value(
CONFIG_INI_PATH, 'default', 'scan_way', int(choose))
SCAN_WAY = int(choose)
else:
update_config_file_key_value(
CONFIG_INI_PATH, 'default', 'scan_way', default_choose)
SCAN_WAY = default_choose
def get_start_url_urls_table(start_url):
# eg.http://www.baidu.com --> www_baidu_com_urls
# eg.http://www.baidu.com/ --> www_baidu_com_urls
# eg.http://www.baidu.com/cms/ --> www_baidu_com_cms_urls
# eg.http://www.baidu.com/1.php --> www_baidu_com_urls
# eg.http://www.baidu.com/cms --> www_baidu_com_cms_urls
# eg.http://www.baidu.com/cms/1.php --> www_baidu_com_cms_urls
# eg.http://www.baidu.com:40711 --> www_baidu_com_40711_urls
# eg.http://www.baidu.com:40711/cms/1.php --> www_baidu_com_40711_cms_urls
parsed = urlparse(start_url)
netloc = parsed.netloc
path = parsed.path
if path != "":
if "." in path.split("/")[-1]:
path_part_value = path[:-
(len(path.split("/")[-1]) + 1)].replace("/", "_")
elif path[-1] == "/":
path_part_value = path[:-1].replace("/", "_")
else:
path_part_value = path.replace("/", "_")
else:
path_part_value = ""
netloc_part_value = netloc.replace(".", "_").replace(":", "_")
return netloc_part_value + path_part_value + "_urls"
def execute_sql_in_db(sql, db_name="mysql"):
# 执行数据库命令
# 返回值为fetchone()的返回值
global DB_SERVER
global DB_USER
global DB_PASS
#print("current sql string is:")
# print(sql)
try:
import MySQLdb
except:
# for ubuntu16.04 deal with install MySQLdb error
os.system("apt-get -y install libmysqlclient-dev")
os.system("easy_install MySQL-python")
os.system("pip3 install MySQLdb")
import MySQLdb
try:
conn = MySQLdb.connect(
DB_SERVER,
DB_USER,
DB_PASS,
db=db_name,
port=3306,
charset="utf8"
)
conn.autocommit(1)
cur = conn.cursor()
cur.execute('SET NAMES utf8')
#print("sql is:")
# print(sql)
cur.execute(sql)
result = cur.fetchall()
#print("result is:")
# print(result)
return result
except:
import traceback
traceback.print_exc()
# 发生错误回滚
conn.rollback()
finally:
cur.close()
conn.close()
def exist_database(db_name):
# 检测DB_NAME名字的数据库是否存在
# 存在返回True,否则返回False
result = execute_sql_in_db("show databases")
if len(result) > 0:
for each in result:
if len(each) > 0 and each[0] == db_name:
return True
return False
def exist_table_in_db(table_name, db_name):
# 检测数据库中存在表,存在返回True,否则返回False
result = execute_sql_in_db("show tables", db_name)
if len(result) > 0:
for each in result:
if len(each) > 0 and each[0] == table_name:
return True
return False
def database_init():
# 本地数据库初始化,完成数据库配置和建立数据(数据库和targets+first_targets表),以及目标导入
# 完成这一步后需要从数据库中按优先级取出没有完成的任务
# eg.一个目标为http://www.freebuf.com,将它加入到targets表中,targets表中的sqli_scaned等各项标记扫描完成列代
# 表该目标及其所有旁站对应项的扫描全部完成,在www_freebuf_com_pang表中也有http_domain为
# http://www.freebuf.com的记录,该表中对应的sqli_scaned等各项标记代表目标
# http://www.freebuf.com这一个网站的扫描完成情况
global DB_SERVER
global DB_USER
global DB_PASS
global DB_NAME
global TARGETS_TABLE_NAME
global FIRST_TARGETS_TABLE_NAME
global SCAN_WAY
sys_info = get_string_from_command("uname -a")
mysql_service_info = get_string_from_command("service mysql status")
if re.search(r"kali", sys_info, re.I) and re.search(r"debian", sys_info, re.I):
if re.search(r"dead", mysql_service_info, re.I):
os.system("service mysql start")
mysql_service_info = get_string_from_command("service mysql status")
if re.search(r"dead", mysql_service_info, re.I):
input(
"press any to exit your scan progress coz your mysql is not running,check your mysql service")
# 下面是为了解决新版kali linux(2017.1)connect refused(无法修改root密码导致的)
# 解决方法链接https://superuser.com/questions/949496/cant-reset-mysql-mariadb-root-password
# 下面的双反斜杠在terminal中是不用双反斜杠的,但是在os.system中要多加一个反斜杠
a = get_string_from_command(
"echo select plugin from mysql.user where user=\\'root\\' | mysql")
if re.search(r"unix_socket", a, re.I):
# 下面的双反斜杠在terminal中是不用双反斜杠的,但是在os.system中要多加一个反斜杠
os.system(
"echo update mysql.user set plugin=\\'\\' where user=\\'root\\' | mysql")
os.system("echo flush privileges | mysql")
print("database init process,database and tables will be created here...")
config_file_abs_path = CONFIG_INI_PATH
if DB_SERVER == "":
print("can not find DB_SERVER")
while 1:
print("please input your database server addr", end=" ")
DB_SERVER = get_input_intime("127.0.0.1", 20)
if check_string_is_ip(DB_SERVER) or check_string_is_domain(DB_SERVER):
update_config_file_key_value(config_file_abs_path, 'default',
'DB_SERVER', "'" + DB_SERVER + "'")
break
else:
print(
"your input may not be a regular ip addr or a domain addr:(")
continue
print("DB_SERVER:" + DB_SERVER)
if DB_USER == "":
print("can not find DB_USER")
print("please input your database username", end=' ')
DB_USER = get_input_intime("root", 10)
update_config_file_key_value(
config_file_abs_path, 'default', 'DB_USER', "'" + DB_USER + "'")
print("DB_USER:" + DB_USER)
if DB_PASS == "":
print("can not find DB_PASS")
print("please input your database password", end=' ')
DB_PASS = get_input_intime("root", 20)
update_config_file_key_value(
config_file_abs_path, 'default', 'DB_PASS', "'" + DB_PASS + "'")
print("DB_PASS:" + DB_PASS)
print("DB_NAME:" + DB_NAME)
# 创建数据库DB_NAME和表TARGETS_TABLE_NAME,FIRST_TARGETS_TABLE_NAME,domain_pang
sql0 = "create database %s" % DB_NAME
if not exist_database(DB_NAME):
execute_sql_in_db(sql0)
execute_sql_in_db("ALTER DATABASE `%s` CHARACTER SET utf8" % DB_NAME)
else:
print("database exists,I will use the former database store tables")
# 数据库中统一都用字符串形式存储各种数据
# targets和first_targets表存放扫描是否完成信息和旁站列表和总的扫描结果
# 这里的crawl_finished代表所有主要目标一个domain完成了爬虫
#default_get_pang_value="0" if SCAN_WAY in [1,3] else "1"
#default_get_sub_value="0" if SCAN_WAY in [2,3] else "1"
sql1 = "create table `%s`(start_url varchar(200) not null primary key,http_domain varchar(100) not null,domain varchar(50) not null,\
you_can_take_notes_in_this_column_for_your_own_pentest text not null comment '人工渗透时笔记列' default '',\
actual_ip_from_cdn_scan varchar(50) not null,\
cdn_scaned varchar(50) not null default 1,\
port_scan_info text not null,port_scaned varchar(50) not null default 1,\
risk_scan_info mediumtext not null,\
risk_scaned varchar(50) not null default 1,\
script_type varchar(50) not null,\
script_type_scaned varchar(50) not null default 1,\
dirb_info mediumtext not null,dirb_scaned varchar(50) not null default 1,\
sqlis text not null,sqli_scaned varchar(50) not null default 1,\
xsss text not null,xss_scaned varchar(50) not null default 1,\
robots_and_sitemap text not null,scan_result mediumtext not null,\
crawl_scaned varchar(50) not null default 1,\
cms_value text not null,cms_identify_scaned varchar(50) not null default 1,cms_scan_info text not null,cms_scaned varchar(50) not null default 1,\
like_admin_login_urls text not null,\
cracked_admin_login_urls_info text not null,like_webshell_urls text not null,\
cracked_webshell_urls_info text not null,\
crack_webshell_scaned varchar(50) not null default 1,\
crack_admin_page_scaned varchar(50) not null default 1,\
port_brute_crack_info text not null,port_brute_crack_scaned varchar(50) not null default 1,\
whois_info text not null,whois_scaned varchar(50) not null default 1,\
resource_files text not null,\
scan_finished varchar(50) not null default 0,\
get_pang_domains_finished varchar(50) not null default 1,\
get_sub_domains_finished varchar(50) not null default 1,\
pang_domains_crawl_scaned varchar(50) not null default 1,\
sub_domains_crawl_scaned varchar(50) not null default 1,\
pang_domains_cdn_scaned varchar(50) not null default 1,\
sub_domains_cdn_scaned varchar(50) not null default 1,\
pang_domains_risk_scaned varchar(50) not null default 1,\
sub_domains_risk_scaned varchar(50) not null default 1,\
pang_domains_script_type_scaned varchar(50) not null default 1,\
sub_domains_script_type_scaned varchar(50) not null default 1,\
pang_domains_dirb_scaned varchar(50) not null default 1,\
sub_domains_dirb_scaned varchar(50) not null default 1,\
pang_domains_sqli_scaned varchar(50) not null default 1,\
sub_domains_sqli_scaned varchar(50) not null default 1,\
pang_domains_xss_scaned varchar(50) not null default 1,\
sub_domains_xss_scaned varchar(50) not null default 1,\
pang_domains_cms_identify_scaned varchar(50) not null default 1,\
pang_domains_cms_scaned varchar(50) not null default 1,\
sub_domains_cms_identify_scaned varchar(50) not null default 1,\
sub_domains_cms_scaned varchar(50) not null default 1,\
pang_domains_crack_webshell_scaned varchar(50) not null default 1,\
sub_domains_crack_webshell_scaned varchar(50) not null default 1,\
pang_domains_crack_admin_page_scaned varchar(50) not null default 1,\
sub_domains_crack_admin_page_scaned varchar(50) not null default 1,\
pang_domains_port_scaned varchar(50) not null default 1,\
sub_domains_port_scaned varchar(50) not null default 1,\
pang_domains_port_brute_crack_scaned varchar(50) not null default 1,\
sub_domains_port_brute_crack_scaned varchar(50) not null default 1,\
pang_domains_whois_scaned varchar(50) not null default 1,\
sub_domains_whois_scaned varchar(50) not null default 1,\
pang_domains_scan_finished varchar(50) not null default 0,\
sub_domains_scan_finished varchar(50) not null default 0,\
final_scan_result mediumtext not null)" % TARGETS_TABLE_NAME
sql2 = "create table `%s`(start_url varchar(200) not null primary key,http_domain varchar(100) not null,domain varchar(50) not null,\
you_can_take_notes_in_this_column_for_your_own_pentest text not null comment '人工渗透时笔记列' default '',\
actual_ip_from_cdn_scan varchar(50) not null,\
cdn_scaned varchar(50) not null default 1,\
port_scan_info text not null,port_scaned varchar(50) not null default 1,\
risk_scan_info mediumtext not null,\
risk_scaned varchar(50) not null default 1,\
script_type varchar(50) not null,\
script_type_scaned varchar(50) not null default 1,\
dirb_info mediumtext not null,dirb_scaned varchar(50) not null default 1,\
sqlis text not null,sqli_scaned varchar(50) not null default 1,\
xsss text not null,xss_scaned varchar(50) not null default 1,\
robots_and_sitemap text not null,scan_result mediumtext not null,\
crawl_scaned varchar(50) not null default 1,\
cms_value text not null,cms_identify_scaned varchar(50) not null default 1,cms_scan_info text not null,cms_scaned varchar(50) not null default 1,\
like_admin_login_urls text not null,\
cracked_admin_login_urls_info text not null,like_webshell_urls text not null,\
cracked_webshell_urls_info text not null,\
crack_webshell_scaned varchar(50) not null default 1,\
crack_admin_page_scaned varchar(50) not null default 1,\
port_brute_crack_info text not null,port_brute_crack_scaned varchar(50) not null default 1,\
whois_info text not null,whois_scaned varchar(50) not null default 1,\
resource_files text not null,\
scan_finished varchar(50) not null default 0,\
get_pang_domains_finished varchar(50) not null default 1,\
get_sub_domains_finished varchar(50) not null default 1,\
pang_domains_crawl_scaned varchar(50) not null default 1,\
sub_domains_crawl_scaned varchar(50) not null default 1,\
pang_domains_risk_scaned varchar(50) not null default 1,\
sub_domains_risk_scaned varchar(50) not null default 1,\
pang_domains_cdn_scaned varchar(50) not null default 1,\
sub_domains_cdn_scaned varchar(50) not null default 1,\
pang_domains_script_type_scaned varchar(50) not null default 1,\
sub_domains_script_type_scaned varchar(50) not null default 1,\
pang_domains_dirb_scaned varchar(50) not null default 1,\
sub_domains_dirb_scaned varchar(50) not null default 1,\
pang_domains_sqli_scaned varchar(50) not null default 1,\
sub_domains_sqli_scaned varchar(50) not null default 1,\
pang_domains_xss_scaned varchar(50) not null default 1,\
sub_domains_xss_scaned varchar(50) not null default 1,\
pang_domains_cms_identify_scaned varchar(50) not null default 1,\
pang_domains_cms_scaned varchar(50) not null default 1,\
sub_domains_cms_identify_scaned varchar(50) not null default 1,\
sub_domains_cms_scaned varchar(50) not null default 1,\
pang_domains_crack_webshell_scaned varchar(50) not null default 1,\
sub_domains_crack_webshell_scaned varchar(50) not null default 1,\
pang_domains_crack_admin_page_scaned varchar(50) not null default 1,\
sub_domains_crack_admin_page_scaned varchar(50) not null default 1,\
pang_domains_port_scaned varchar(50) not null default 1,\
sub_domains_port_scaned varchar(50) not null default 1,\
pang_domains_port_brute_crack_scaned varchar(50) not null default 1,\
sub_domains_port_brute_crack_scaned varchar(50) not null default 1,\
pang_domains_whois_scaned varchar(50) not null default 1,\
sub_domains_whois_scaned varchar(50) not null default 1,\
pang_domains_scan_finished varchar(50) not null default 0,\
sub_domains_scan_finished varchar(50) not null default 0,\
final_scan_result mediumtext not null)" % FIRST_TARGETS_TABLE_NAME
# print sql1
if not exist_table_in_db(TARGETS_TABLE_NAME, DB_NAME):
execute_sql_in_db(sql1, DB_NAME)
else:
print("TARGETS_TABLE_NAME exists,I will use the former one to store info")
if not exist_table_in_db(FIRST_TARGETS_TABLE_NAME, DB_NAME):
execute_sql_in_db(sql2, DB_NAME)
else:
print("FIRST_TARGETS_TABLE_NAME exists,I will use the former one to store info")
# 目标导入并根据选择的扫描模式创建目标旁站表或子站表
print(
"input your targets now,make sure your targets are web app entries[eg.http://www.onlyhasdvwasite.com/dvwa/]...")
print("input 'a|A' for adding your targets one by one\n\
input 'f|F' for adding your target by loading a target file\n\
input 'n|N' for adding no targets and use the exists targets in former db\n\
Attention! Make sure your input url is a cms entry,eg.'http://192.168.1.1/dvwa' or 'http://192.168.1.1/dvwa/'")
#choose = get_input_intime('n', 10)
choose = input("> ")
if choose == 'f' or choose == 'F':
targets_file_abs_path = input("Please input your targets file\n:>")
with open(targets_file_abs_path, "r+") as f:
for start_url in f:
start_url = re.sub(r"(\s)$", "", start_url)
target = get_http_domain_from_url(start_url)
print('''你想要随便扫描还是认真的扫描?
输入y|Y选择随便扫描,不要求输入cookie
输入n|N选择认真扫描,要求输入用户登录后的cookie
默认随便扫描,default[y]''')
tmpchoose = get_input_intime('y', 2)
if tmpchoose in ['n', 'N']:
cookie = input(
"please input your cookie for %s\n>" % start_url)
else:
cookie = ""
update_config_file_key_value(
config_file_abs_path, start_url, 'cookie', "'" + cookie + "'")
# 保持session不失效
if cookie != "":
keep_session_thread = MyThread(
keep_session, (start_url, cookie))
keep_session_thread.start()
print("已更新配置文件中的cookie,如果你之后想更新cookie,可直接在配置文件中修改")
# 创建目标旁站表,比目标表少了pang_domains字段和sub_domains字段
domain_value = target.split("/")[-1]
domain_is_ip = False
if re.match(r"(\d+\.){3}\d+", domain_value):
domain_is_ip = True
pang_table_name = domain_value.replace(".", "_") + "_pang"
# 创建目标子站表,比目标表少了pang_domains字段和sub_domains字段
sub_table_name = domain_value.replace(".", "_") + "_sub"
# 这里的crawl_scaned代表一个站(pang or sub)完成了爬虫
sql_pang = "create table `%s`(http_domain varchar(100) not null primary key,domain varchar(50) not null,\
you_can_take_notes_in_this_column_for_your_own_pentest text not null comment '人工渗透时笔记列' default '',\
actual_ip_from_cdn_scan varchar(50) not null,\
cdn_scaned varchar(50) not null default 1,\
port_scan_info text not null,port_scaned varchar(50) not null default 1,\
risk_scan_info mediumtext not null,\
risk_scaned varchar(50) not null default 1,\
script_type varchar(50) not null,\
script_type_scaned varchar(50) not null default 1,\
dirb_info mediumtext not null,dirb_scaned varchar(50) not null default 1,\
sqlis text not null, sqli_scaned varchar(50) not null default 1,\
xsss text not null, xss_scaned varchar(50) not null default 1,\
crawl_scaned varchar(50) not null default 1,\
cms_value text not null,cms_identify_scaned varchar(50) not null default 1,cms_scan_info text not null,cms_scaned varchar(50) not null default 1,\
like_admin_login_urls text not null,\
cracked_admin_login_urls_info text not null, like_webshell_urls text not null,\
cracked_webshell_urls_info text not null,\
crack_webshell_scaned varchar(50) not null default 1,\
crack_admin_page_scaned varchar(50) not null default 1,\
port_brute_crack_info text not null,port_brute_crack_scaned varchar(50) not null default 1,\
whois_info text not null,whois_scaned varchar(50) not null default 1,\
resource_files text not null,\
robots_and_sitemap text not null, scan_result mediumtext not null,\
scan_finished varchar(50) not null default 0)" % pang_table_name
sql_sub = "create table `%s`(http_domain varchar(100) not null primary key,domain varchar(50) not null,\
you_can_take_notes_in_this_column_for_your_own_pentest text not null comment '人工渗透时笔记列' default '',\
actual_ip_from_cdn_scan varchar(50) not null,\
cdn_scaned varchar(50) not null default 1,\
port_scan_info text not null,port_scaned varchar(50) not null default 1,\
risk_scan_info mediumtext not null,\
risk_scaned varchar(50) not null default 1,\
script_type varchar(50) not null,\
script_type_scaned varchar(50) not null default 1,\
dirb_info mediumtext not null,dirb_scaned varchar(50) not null default 1,\
sqlis text not null, sqli_scaned varchar(50) not null default 1,\
xsss text not null, xss_scaned varchar(50) not null default 1,\
crawl_scaned varchar(50) not null default 1,\
cms_value text not null,cms_identify_scaned varchar(50) not null default 1,cms_scan_info text not null,cms_scaned varchar(50) not null default 1,\
like_admin_login_urls text not null,\
cracked_admin_login_urls_info text not null, like_webshell_urls text not null,\
cracked_webshell_urls_info text not null,\
crack_webshell_scaned varchar(50) not null default 1,\
crack_admin_page_scaned varchar(50) not null default 1,\
port_brute_crack_info text not null,port_brute_crack_scaned varchar(50) not null default 1,\
whois_info text not null,whois_scaned varchar(50) not null default 1,\
resource_files text not null,\
robots_and_sitemap text not null, scan_result mediumtext not null,\
scan_finished varchar(50) not null default 0)" % sub_table_name
# 这里改成无论何种扫描方式都建立sub表,因为爬虫模块会爬到子站,将爬到的子站放到sub表中对应字段中
# 这里改成无论何种扫描方式都建立pang表,因为后面可能有对pang表的访问
if SCAN_WAY in [1, 2, 3, 4]:
if not domain_is_ip:
# 如果domain是ip的格式则不建domain_pang和domain_sub表
execute_sql_in_db(sql_pang, DB_NAME)
execute_sql_in_db(sql_sub, DB_NAME)
else:
# domain是ip格式
if SCAN_WAY in [1, 2, 3]:
input(
"If the domain is ip format and SCAN_WAY is not 4,I will skip this target.Press any key to continue")
continue
else:
print("SCAN_WAY setup error,not in 1-4")
# 创建目标urls表.eg:www_baidu_com_urls
target_urls_table_name = get_start_url_urls_table(start_url)
sql = "create table `%s`(url varchar(250) not null primary key,code varchar(10) not null,\
title varchar(100) not null,content mediumtext not null,has_sqli varchar(50) not null,\
is_upload_url varchar(50) not null,\
like_webshell_url varchar(50) not null default 0,\
cracked_webshell_url_info varchar(50) not null,\
like_admin_login_url varchar(50) not null,\
cracked_admin_login_url_info varchar(50) not null,\
http_domain varchar(70) not null)" % target_urls_table_name
execute_sql_in_db(sql, DB_NAME)
print(
"do you want to add it to the first targets table with higher priority to scan? y|n\
default[n]")
choose = get_input_intime('n', 10)
if choose == 'y' or choose == 'Y':
with open(targets_file_abs_path, "r+") as f:
for start_url in f:
start_url = re.sub(r"(\s)$", "", start_url)
target = get_http_domain_from_url(start_url)
sql3 = "insert into `%s`(start_url,http_domain,domain) values('%s','%s','%s')" % (
FIRST_TARGETS_TABLE_NAME, start_url, target, target.split("/")[-1])
execute_sql_in_db(sql3, DB_NAME)
else:
with open(targets_file_abs_path, "r+") as f:
for start_url in f:
start_url = re.sub(r"(\s)$", "", start_url)
target = get_http_domain_from_url(start_url)
sql3 = "insert into `%s`(start_url,http_domain,domain) values('%s','%s','%s')" % (
TARGETS_TABLE_NAME, start_url, target, target.split('/')[-1])
execute_sql_in_db(sql3, DB_NAME)
elif choose == 'a' or choose == 'A':
while 1:
print(
"please input your targets,eg.https://www.baidu.com,'d|D' for done,default[d]")
start_url = input()
if len(start_url) == 0:
start_url = 'd'
if start_url != 'd' and start_url != 'D' and re.match(
r"http.*", start_url):
print(
"do you want to add it to the first targets table with higher priority to scan? y|n\
default[n]")
choose = get_input_intime('n', 10)
target = get_http_domain_from_url(start_url)
print("你想要随便扫描还是认真的扫描,随便扫描不要求输入cookie,认真扫描要求输入用户登录后的cookie,输入y|Y选\
择随便扫描,n|N选择认真扫描,默认随便扫描,default[y]")
tmpchoose = get_input_intime('y')
if tmpchoose in ['n', 'N']:
cookie = input(
"please input your cookie for %s\n>" % start_url)
else:
cookie = ""
update_config_file_key_value(
config_file_abs_path, start_url, 'cookie', "'" + cookie + "'")
# 保持session不失效
if cookie != "":
keep_session_thread = MyThread(
keep_session, (target, cookie))
keep_session_thread.start()
print("已更新配置文件中的cookie,如果你之后想更新cookie,可直接在配置文件中修改")
# 创建目标旁站表,比目标表少了pang_domains字段和sub_domains字段
domain_value = target.split('/')[-1]
domain_is_ip = False
if re.match(r"(\d+\.){3}\d+", domain_value):
domain_is_ip = True
pang_table_name = domain_value.replace(".", "_") + "_pang"
# 创建目标子站表,比目标表少了pang_domains字段和sub_domains字段
sub_table_name = domain_value.replace(".", "_") + "_sub"
# 这里的crawl_scaned代表一个站(pang or sub)完成了爬虫
sql_pang = "create table `%s`(http_domain varchar(100) not null primary key,domain varchar(50) not null,\
you_can_take_notes_in_this_column_for_your_own_pentest text not null comment '人工渗透时笔记列' default '',\
actual_ip_from_cdn_scan varchar(50) not null,\
cdn_scaned varchar(50) not null default 1,\
port_scan_info text not null,port_scaned varchar(50) not null default 1,\
risk_scan_info mediumtext not null,\
risk_scaned varchar(50) not null default 1,\
script_type varchar(50) not null,\
script_type_scaned varchar(50) not null default 1,\
dirb_info mediumtext not null,dirb_scaned varchar(50) not null default 1,\
sqlis text not null,sqli_scaned varchar(50) not null default 1,\
xsss text not null,xss_scaned varchar(50) not null default 1,\
crawl_scaned varchar(50) not null default 1,\
cms_value text not null,cms_identify_scaned varchar(50) not null default 1,cms_scan_info text not null,cms_scaned varchar(50) not null default 1,\
like_admin_login_urls text not null,\
cracked_admin_login_urls_info text not null,like_webshell_urls text not null,\
cracked_webshell_urls_info text not null,\
crack_webshell_scaned varchar(50) not null default 1,\
crack_admin_page_scaned varchar(50) not null default 1,\
port_brute_crack_info text not null,port_brute_crack_scaned varchar(50) not null default 1,\
whois_info text not null,whois_scaned varchar(50) not null default 1,\
resource_files text not null,\
robots_and_sitemap text not null,scan_result mediumtext not null,\
scan_finished varchar(50) not null default 0)" % pang_table_name
sql_sub = "create table `%s`(http_domain varchar(100) not null primary key,domain varchar(50) not null,\
you_can_take_notes_in_this_column_for_your_own_pentest text not null comment '人工渗透时笔记列' default '',\
actual_ip_from_cdn_scan varchar(50) not null,\
cdn_scaned varchar(50) not null default 1,\
port_scan_info text not null,port_scaned varchar(50) not null default 1,\
risk_scan_info mediumtext not null,\
risk_scaned varchar(50) not null default 1,\
script_type varchar(50) not null,\
script_type_scaned varchar(50) not null default 1,\
dirb_info mediumtext not null,dirb_scaned varchar(50) not null default 1,\
sqlis text not null, sqli_scaned varchar(50) not null default 1,\
xsss text not null, xss_scaned varchar(50) not null default 1,\
crawl_scaned varchar(50) not null default 1,\
cms_value text not null,cms_identify_scaned varchar(50) not null default 1,cms_scan_info text not null,cms_scaned varchar(50) not null default 1,\
like_admin_login_urls text not null,\
cracked_admin_login_urls_info text not null, like_webshell_urls text not null,\
cracked_webshell_urls_info text not null,\
crack_webshell_scaned varchar(50) not null default 1,\
crack_admin_page_scaned varchar(50) not null default 1,\
port_brute_crack_info text not null,port_brute_crack_scaned varchar(50) not null default 1,\
whois_info text not null,whois_scaned varchar(50) not null default 1,\
resource_files text not null,\
robots_and_sitemap text not null, scan_result mediumtext not null,\
scan_finished varchar(50) not null default 0)" % sub_table_name
# 这里改成无论何种扫描方式都建立sub表,因为爬虫模块会爬到子站,将爬到的子站放到sub表中对应字段中
# 这里改成无论何种扫描方式都建立pang表,因为后面可能有对pang表的访问
SCAN_WAY = eval(get_key_value_from_config_file(
CONFIG_INI_PATH, 'default', 'scan_way'))
if SCAN_WAY in [1, 2, 3, 4]:
if not domain_is_ip:
execute_sql_in_db(sql_pang, DB_NAME)
execute_sql_in_db(sql_sub, DB_NAME)
else:
# domain是ip格式
if SCAN_WAY in [1, 2, 3]:
input(
"If the domain is ip format and SCAN_WAY is not 4,I will skip this target.Press any key to continue")
continue
else:
print("SCAN_WAY setup error,not in 1-4")
# 创建目标urls表.eg:www_baidu_com_urls
target_urls_table_name = get_start_url_urls_table(start_url)
sql = "create table `%s`(url varchar(250) not null primary key,code varchar(10) not null,\
title varchar(100) not null,content mediumtext not null,has_sqli varchar(50) not null,\
is_upload_url varchar(50) not null,\
like_webshell_url varchar(50) not null default 0,\
cracked_webshell_url_info varchar(50) not null,\
like_admin_login_url varchar(50) not null,\
cracked_admin_login_url_info varchar(50) not null,\
http_domain varchar(70) not null)" % target_urls_table_name
execute_sql_in_db(sql, DB_NAME)
if choose == 'y' or choose == 'Y':
sql3 = "insert into `%s`(start_url,http_domain,domain) values('%s','%s','%s') " % (
FIRST_TARGETS_TABLE_NAME, start_url, target, target.split("/")[-1])
execute_sql_in_db(sql3, DB_NAME)
set_scan_finished("pang_domains_sqli_scaned", DB_NAME,
FIRST_TARGETS_TABLE_NAME, "start_url", start_url)
set_scan_finished("sub_domains_sqli_scaned", DB_NAME,
FIRST_TARGETS_TABLE_NAME, "start_url", start_url)
else:
sql3 = "insert into `%s`(start_url,http_domain,domain) values('%s','%s','%s')" % (
TARGETS_TABLE_NAME, start_url, target, target.split('/')[-1])
execute_sql_in_db(sql3, DB_NAME)
set_scan_finished(
"pang_domains_sqli_scaned", DB_NAME, TARGETS_TABLE_NAME, "start_url", start_url)
set_scan_finished(
"sub_domains_sqli_scaned", DB_NAME, TARGETS_TABLE_NAME, "start_url", start_url)
continue
elif start_url != 'd' and start_url != 'D' and re.match(r"http.*", start_url, re.I) is None:
print("please input http(s)://... or d or D")
continue
else:
break
else:
print("I will use the exisit targets in the db for scan job")
pass
print('''There are below 15 kinds of scan module:
1.cdn scan(check and find out actual ip behind cdn,it's a base for 2)
2.pang domains scan(get the pang domains of the targets,is based on 1)
3.sub domains scan(get the sub domains of the targets)
4.crawl scan(crawl the target,it's a base for 8 and 12 and 13,it's a base for 6)
5.port scan(scan the targets' port,it's a base for 6 and 14)
6.high rish scan(check if the targets has high risk vul,is based on 4 and 5)
7.sqli scan(check if the targets has sql injection vul)
8.xss scan(check if the targets has xss vul,is based on 4)
9.script type scan(try to find out the targets' script type[php,asp,aspx,jsp])
10.dirb scan(brute force scan the targets' dirs and files,it's a base for 12 and 13)
11.cms scan(findout the targets' cms type[joomla,wordpress,ecshop,...])
12.crack webshell scan(try to find the exists webshell on targets site and try to crack it,is based on 4 and 10)
13.crack admin page scan(try to find the targets' admin login page and try to crack it,is based on 4 and 10)
14.port brute crack scan(try to brute force crack the common open port,is based on 5)
15.whois scan(get the targets' whois info)''')
print(
'''Do you want my choosing to scan all of them by default,if you have special needs(eg.scan sqli vuls alone,etc) please input n|N , default[n]''')
choose_scan_strategy = get_input_intime('n')
# print("\n")
if choose_scan_strategy == 'Y' or choose_scan_strategy == 'y':
set_column_name_scan_module_unfinished("cdn_scaned", SCAN_WAY)
sql_list = []
tmp_sql = "update %s set get_pang_domains_finished='0'" % FIRST_TARGETS_TABLE_NAME
tmp_sql = "update %s set get_pang_domains_finished='0'" % TARGETS_TABLE_NAME
for each in sql_list:
execute_sql_in_db(each, DB_NAME)
sql_list = []
tmp_sql = "update %s set get_sub_domains_finished='0'" % FIRST_TARGETS_TABLE_NAME
tmp_sql = "update %s set get_sub_domains_finished='0'" % TARGETS_TABLE_NAME
for each in sql_list:
execute_sql_in_db(each, DB_NAME)
set_column_name_scan_module_unfinished("crawl_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("port_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("risk_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("sqli_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("xss_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("script_type_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("dirb_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("cms_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished(
"crack_webshell_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished(
"crack_admin_page_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished(
"port_brute_crack_scaned", SCAN_WAY)
set_column_name_scan_module_unfinished("whois_scaned", SCAN_WAY)
else:
while True:
print('''Please input your selections on upon 15 scan modules,use blank to separate them.
eg:
1 2
4 8
4 10 12
4 10 13
5 14
4 5 6
5
Attention:
|--->advice items<---|
a.if you have choosed 6,then you'd better have choosed 4 and 5
|--->must items<---|
a.if you have choosed 2,then you must have choosed 1
b.if you have choosed 8,then you must have choosed 4
c.if you have choosed 12,then you must have choosed 4 and 10
d.if you have choosed 13,then you must have choosed 4 and 10
e.if you have choosed 14,then you must have choosed 5
''')
should_continue = 0
selections = input("your choose:")
selections_list = re.split("\s+", selections)
if '2' in selections_list and ('1' not in selections_list):
print("if you have choosed 2,then you must have choosed 1")
should_continue = 1
if '8' in selections_list and ('4' not in selections_list):
print("if you have choosed 8,then you must have choosed 4")
should_continue = 1
if '12' in selections_list and ('4' not in selections_list or '10' not in selections_list):
print("if you have choosed 12,then you must have choosed 4 and 10")
should_continue = 1
if '13' in selections_list and ('4' not in selections_list or '10' not in selections_list):
print("if you have choosed 13,then you must have choosed 4 and 10")
should_continue = 1
if '14' in selections_list and ('5' not in selections_list):
print("if you have choosed 14,then you must have choosed 5")
should_continue = 1
if should_continue == 1:
continue
break
if '1' in selections_list:
set_column_name_scan_module_unfinished("cdn_scaned", SCAN_WAY)
if '2' in selections_list or SCAN_WAY in [1, 3]:
tmp_sql = "update %s set get_pang_domains_finished='0'" % FIRST_TARGETS_TABLE_NAME
execute_sql_in_db(tmp_sql, DB_NAME)
tmp_sql = "update %s set get_pang_domains_finished='0'" % TARGETS_TABLE_NAME
execute_sql_in_db(tmp_sql, DB_NAME)
if '3' in selections_list or SCAN_WAY in [2, 3]:
tmp_sql = "update %s set get_sub_domains_finished='0'" % FIRST_TARGETS_TABLE_NAME
execute_sql_in_db(tmp_sql, DB_NAME)
tmp_sql = "update %s set get_sub_domains_finished='0'" % TARGETS_TABLE_NAME
execute_sql_in_db(tmp_sql, DB_NAME)
if '4' in selections_list:
set_column_name_scan_module_unfinished("crawl_scaned", SCAN_WAY)
if '5' in selections_list:
set_column_name_scan_module_unfinished("port_scaned", SCAN_WAY)
if '6' in selections_list:
set_column_name_scan_module_unfinished("risk_scaned", SCAN_WAY)
if '7' in selections_list:
set_column_name_scan_module_unfinished("sqli_scaned", SCAN_WAY)
if '8' in selections_list:
set_column_name_scan_module_unfinished("xss_scaned", SCAN_WAY)
if '9' in selections_list:
set_column_name_scan_module_unfinished(
"script_type_scaned", SCAN_WAY)
if '10' in selections_list:
set_column_name_scan_module_unfinished("dirb_scaned", SCAN_WAY)
if '11' in selections_list:
set_column_name_scan_module_unfinished("cms_scaned", SCAN_WAY)
if '12' in selections_list:
set_column_name_scan_module_unfinished(
"crack_webshell_scaned", SCAN_WAY)
if '13' in selections_list:
set_column_name_scan_module_unfinished(
"crack_admin_page_scaned", SCAN_WAY)
if '14' in selections_list:
set_column_name_scan_module_unfinished(
"port_brute_crack_scaned", SCAN_WAY)
if '15' in selections_list:
set_column_name_scan_module_unfinished("whois_scaned", SCAN_WAY)
def set_column_name_scan_module_unfinished(column_name, scan_way):
# set the scan module which has column_name to be unfinished
# eg,column_name="cdn_scaned"
global DB_NAME
sql_list = []
tmp_sql = "update %s set %s='0'" % ("first_targets", column_name)
sql_list.append(tmp_sql)
tmp_sql = "update %s set %s='0'" % ("targets", column_name)
sql_list.append(tmp_sql)
tmp_sql = "update %s set pang_domains_%s='0'" % (
"first_targets", column_name)
sql_list.append(tmp_sql)
tmp_sql = "update %s set pang_domains_%s='0'" % ("targets", column_name)
sql_list.append(tmp_sql)
tmp_sql = "update %s set sub_domains_%s='0'" % (
"first_targets", column_name)
sql_list.append(tmp_sql)
tmp_sql = "update %s set sub_domains_%s='0'" % ("targets", column_name)
sql_list.append(tmp_sql)
for each in sql_list:
execute_sql_in_db(each, DB_NAME)
if scan_way in [1, 3]:
tmp_sql = "select table_name from information_schema.tables where table_schema='exp10itdb' and table_name regexp '.*_pang$'"
result = execute_sql_in_db(tmp_sql, DB_NAME)
if len(result) > 0:
for each in result:
each_table = each[0]
tmp_sql = "update %s set %s='0'" % (each_table, column_name)
execute_sql_in_db(tmp_sql, DB_NAME)
if scan_way in [2, 3]:
tmp_sql = "select table_name from information_schema.tables where table_schema='exp10itdb' and table_name regexp '.*_sub$'"
result = execute_sql_in_db(tmp_sql, DB_NAME)
if len(result) > 0:
for each in result:
each_table = each[0]
tmp_sql = "update %s set %s='0'" % (each_table, column_name)
execute_sql_in_db(tmp_sql, DB_NAME)