-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathfind.py
53 lines (41 loc) · 1.25 KB
/
find.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
import re
import os
import sys
def listTargetFolder(folder_name="."):
ret = []
if folder_name == ".":
for folder in os.listdir("."):
if folder[0] == ".":
continue
if os.path.isdir(folder):
for plugin in os.listdir(folder):
ret.append(folder+"/"+plugin)
return ret
return os.listdir(folder_name)
def search(pluginName, regx):
with open(pluginName) as f:
if re.search(regx, f.read()):
return True
# for plugin in listTargetFolder(cms):
# path = cms + "/" + plugin
# if search(path, key):
# print("find {} in {}".format(key, path))
if __name__ == '__main__':
cms = None
key = None
args = sys.argv
if len(args) == 3:
_, cms, key = args
elif len(args) == 2:
_, key = args
cms = "."
else:
print("使用方法: ")
print("python {script} dedecms \"login.php\"".format(script=args[0]))
print("python {script} \"login.php\"".format(script=args[0]))
exit()
# print(listTargetFolder(cms))
for plugin in listTargetFolder(cms):
path = cms + "/" + plugin
if search(path, key):
print("find {} in {}".format(key, path))