-
Notifications
You must be signed in to change notification settings - Fork 117
/
scanShell.py
70 lines (66 loc) · 1.77 KB
/
scanShell.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
#!/usr/bin/env python
#coding=utf8
import os, glob, sys
import time
from filterShell import FilterShell
from getFileTime import getFileTime
#插件列表
plusArr = []
#加载插件
def loadPlus(ext="all"):
plusTmp = glob.glob('plugins/*-plugin.py')
if ext == "all":
for plus in plusTmp:
plusname = plus.split('/')[-1][:-3]
__import__("plugins." + plusname)
plusArr.append(plusname)
elif ext == "php":
for plus in plusTmp:
plusname = plus.split('/')[-1][:-3]
if plusname.find("php") == 0:
__import__("plugins." + plusname)
plusArr.append(plusname)
elif ext == "asp":
for plus in plusTmp:
plusname = plus.split('/')[-1][:-3]
if plusname.find("aps") == 0:
__import__("plugins." + plusname)
plusArr.append(plusname)
elif ext == "aspx":
for plus in plusTmp:
plusname = plus.split('/')[-1][:-3]
if plusname.find("apsx") == 0:
__import__("plugins." + plusname)
plusArr.append( plusname)
elif ext == "jsp":
for plus in plusTmp:
plusname = plus.split('/')[-1][:-3]
if plusname.find("jps") == 0:
__import__("plugins." + plusname)
plusArr.append(plusname)
else:
print "error args!"
exit()
#通过加载插件扫描
def scan(path, ext, blackList, resList):
loadPlus(ext)
#获取绝对路径
for root, dirs, files in os.walk(path):
for filename in files:
filepath = os.path.join(root, filename)
if filepath not in blackList:
#判断文件大小
if os.path.getsize(filepath) < 500000:
for plus in plusArr:
fp = open(filepath, "rb")
fileCtent = fp.read()
fp.close()
res = sys.modules["plugins." + plus].judgeBackdoor(fileCtent)
filetime = getFileTime(filepath)
if res:
resList.append([filepath, res, filetime])
break
else:
pass
else:
pass