-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathpluginTest.py
55 lines (44 loc) · 1.56 KB
/
pluginTest.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
# coding: utf-8
"""
插件测试脚本
注意:要测试的插件文件需要放置在config/conf.py文件中指定的插件存放路径
使用方法:
python PluginTest.py -p "插件文件名(不需要后缀)" -t "需要测试的用户名/邮箱/手机"
"""
import imp
import argparse
from config import conf
def parse_args():
parser = argparse.ArgumentParser()
pluginHelp = 'plugin file name.'
parser.add_argument('-p','--plugin', help=pluginHelp)
targetHelp = 'your target.'
parser.add_argument('-t', '--target', help=targetHelp)
args = parser.parse_args()
return args
def run(plugin, target):
if plugin.endswith('.py'):
plugin = plugin.replace('.py', '')
try:
fp = imp.find_module(plugin, [conf.PLUGIN_DIR])
tempObj = imp.load_module(plugin, *fp)
except ImportError:
print '\033[1;31m[!] plugin: {0} not found!'.format(conf.PLUGIN_DIR + '/' + plugin + '.py')
return False
except Exception, e:
print '\033[1;31m[!] Exception: {0}'.format(e)
return False
if hasattr(tempObj, 'Plugin'):
classObj = getattr(tempObj, 'Plugin')() # 初始化
classObj.register(target)
result = classObj.verify()
if result:
print '\033[1;32m[+] {0} is found!'.format(target)
else:
print '\033[1;33m[-] {0} not found!'.format(target)
else:
print '\033[1;31m[!] {0} ClassException: Plugin not found!'.format(plugin)
return False
if __name__ == '__main__':
args = parse_args()
run(args.plugin, args.target)