|
3 | 3 | from lib.common import * |
4 | 4 | import os, platform, sys |
5 | 5 | from lib.Webserver import * |
| 6 | +from lib.globalvar import * |
6 | 7 |
|
7 | 8 |
|
8 | 9 | # 作者:咚咚呛 |
@@ -63,42 +64,44 @@ def scan_web(self): |
63 | 64 |
|
64 | 65 | def init_scan(self): |
65 | 66 | suspicious, malice, skip = False, False, False |
66 | | - if sys.version_info < (3, 0): |
67 | | - DEPENDENT_LIBRARIES_2_6 = "/lib/egg/yara_python-3.5.0-py2.6-linux-2.32-x86_64.egg" |
68 | | - DEPENDENT_LIBRARIES_3_10 = "/lib/egg/yara_python-3.5.0-py2.7-linux-3.10-x86_64.egg" |
69 | | - DEPENDENT_LIBRARIES_4_20 = "/lib/egg/yara_python-3.8.1-py2.7-linux-4.20-x86_64.egg" |
70 | | - DEPENDENT_LIBRARIES_16 = "/lib/egg/yara_python-3.5.0-py2.7-macosx-10.12-x86_64.egg" |
71 | | - DEPENDENT_LIBRARIES_17 = "/lib/egg/yara_python-3.5.0-py2.7-macosx-10.13-x86_64.egg" |
72 | | - _kernel = platform.release() |
73 | | - if _kernel.startswith('2.6'): |
74 | | - sys.path.append(sys.path[0] + DEPENDENT_LIBRARIES_2_6) |
75 | | - elif _kernel.startswith('3.') and ("6." in str(platform.dist())): |
76 | | - sys.path.append(sys.path[0] + DEPENDENT_LIBRARIES_2_6) |
77 | | - elif _kernel.startswith('3.'): |
78 | | - sys.path.append(sys.path[0] + DEPENDENT_LIBRARIES_3_10) |
79 | | - elif _kernel.startswith('4.'): |
80 | | - sys.path.append(sys.path[0] + DEPENDENT_LIBRARIES_4_20) |
81 | | - elif _kernel.startswith('16.'): |
82 | | - sys.path.append(sys.path[0] + DEPENDENT_LIBRARIES_16) |
83 | | - elif _kernel.startswith('17.'): |
84 | | - sys.path.append(sys.path[0] + DEPENDENT_LIBRARIES_17) |
| 67 | + try: |
| 68 | + SYS_PATH = get_value('SYS_PATH') |
| 69 | + if sys.version_info < (3, 0): |
| 70 | + DEPENDENT_LIBRARIES_2_6 = "/lib/egg/yara_python-3.5.0-py2.6-linux-2.32-x86_64.egg" |
| 71 | + DEPENDENT_LIBRARIES_3_10 = "/lib/egg/yara_python-3.5.0-py2.7-linux-3.10-x86_64.egg" |
| 72 | + DEPENDENT_LIBRARIES_4_20 = "/lib/egg/yara_python-3.8.1-py2.7-linux-4.20-x86_64.egg" |
| 73 | + DEPENDENT_LIBRARIES_16 = "/lib/egg/yara_python-3.5.0-py2.7-macosx-10.12-x86_64.egg" |
| 74 | + DEPENDENT_LIBRARIES_17 = "/lib/egg/yara_python-3.5.0-py2.7-macosx-10.13-x86_64.egg" |
| 75 | + _kernel = platform.release() |
| 76 | + if _kernel.startswith('2.6'): |
| 77 | + sys.path.append(SYS_PATH + DEPENDENT_LIBRARIES_2_6) |
| 78 | + elif _kernel.startswith('3.') and ("6." in str(platform.dist())): |
| 79 | + sys.path.append(SYS_PATH + DEPENDENT_LIBRARIES_2_6) |
| 80 | + elif _kernel.startswith('3.'): |
| 81 | + sys.path.append(SYS_PATH + DEPENDENT_LIBRARIES_3_10) |
| 82 | + elif _kernel.startswith('4.'): |
| 83 | + sys.path.append(SYS_PATH + DEPENDENT_LIBRARIES_4_20) |
| 84 | + elif _kernel.startswith('16.'): |
| 85 | + sys.path.append(SYS_PATH + DEPENDENT_LIBRARIES_16) |
| 86 | + elif _kernel.startswith('17.'): |
| 87 | + sys.path.append(SYS_PATH + DEPENDENT_LIBRARIES_17) |
| 88 | + else: |
| 89 | + return suspicious, malice, True |
| 90 | + import yara |
85 | 91 | else: |
86 | | - # pringf(u'跳过', suspicious=True) |
87 | 92 | return suspicious, malice, True |
88 | | - import yara |
89 | | - else: |
90 | | - # pringf(u'跳过', suspicious=True) |
91 | | - return suspicious, malice, True |
92 | 93 |
|
93 | | - # 编译规则 |
94 | | - self.yararule = self.getRules(yara) |
95 | | - self.scan_web() |
| 94 | + # 编译规则 |
| 95 | + self.yararule = self.getRules(yara) |
| 96 | + self.scan_web() |
96 | 97 |
|
97 | | - if len(self.webshell_list) > 0: |
98 | | - malice = True |
99 | | - # 内容去重 |
100 | | - self.webshell_list = list(set(self.webshell_list)) |
101 | | - return suspicious, malice, skip |
| 98 | + if len(self.webshell_list) > 0: |
| 99 | + malice = True |
| 100 | + # 内容去重 |
| 101 | + self.webshell_list = list(set(self.webshell_list)) |
| 102 | + return suspicious, malice, skip |
| 103 | + except: |
| 104 | + return suspicious, malice, skip |
102 | 105 |
|
103 | 106 | def run(self): |
104 | 107 | print(u'\n开始Webshell安全扫描') |
|
0 commit comments