-
Notifications
You must be signed in to change notification settings - Fork 2
/
Ajatar.py
67 lines (53 loc) · 2.04 KB
/
Ajatar.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import inspect
import os
import sys
from distutils.version import LooseVersion
from lib.core.common import (weAreFrozen,getUnicode,setPaths,parser)#,Banner
from lib.core.data import logger,paths
from lib.core.settings import IS_WIN, VERSION
from thirdparty.colorama.initialise import init as winowsColorInit
from lib.utils.configfile import configFileParser
from lib.core.option import initOption
from lib.core.engine import pluginScan, webScan
from lib.core.exception import (ToolkitMissingPrivileges,ToolkitPluginException, ToolkitSystemException,ToolkitUserQuitException)
sys.dont_write_bytecode = True # 不生成pyc
try:
__import__("lib.utils.versioncheck") #检测 python version
except ImportError:
exit("[!]Please install python version for 3.x")
def modulePath():
try:
_ = sys.executable if weAreFrozen() else __file__ #sys.executable 返回的是py2.exe的路径
except NameError:
_ = inspect.getsourcefile(modulePath) #返回object的python源文件名
#os.path.dirname 获取py2.exe上一层文件路径
#getUnicode()返回unicode编码过的路径
return getUnicode(os.path.dirname(os.path.realpath(_)),encoding=sys.getfilesystemencoding())
def checkEnvironment():
try:
os.path.isdir(modulePath()) #os.path.isdir()用于判断对象是否为一个目录
except UnicodeEncodeError:
errMsg = "Unable to parse path information, please move another path"
logger.critical(errMsg) #记录路径解析错误情况
raise SystemExit
def main():
#主函数
checkEnvironment()#检测环境
setPaths(modulePath()) #初始化一些绝对路径,参数为根目录
#参数设置
args = parser()
if IS_WIN == 'win32':#win 初始化
winowsColorInit()
#Banner()
try:
configFileParser(os.path.join(paths.Ajatar_ROOT_PATH, "config.conf")) #配置文件参数处理
initOption(args) #初始化参数
pluginScan() #插件函数
webScan() #扫描函数
except ToolkitMissingPrivileges,e:
logger.error(e)
systemQuit(EXIT_STATUS.ERROR_EXIT)
if __name__ == '__main__':
main()