-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathenv_config.py
53 lines (46 loc) · 1.42 KB
/
env_config.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
# coding=utf-8
'''
env_config.py
配置扫描所需要的环境
'''
import os
import platform
import teye_config as Settings
os_info = platform.platform() # 获取操作系统名称及版本号,'Windows-7-6.1.7601-SP1'
sys_info = platform.system() # Linux or windows or darwin
'''
def nmap_search_path():
pass
syslist = {
"win": ["windows"],
"linux": ['ubuntu', 'centos', 'debian'],
"mac": ["darwin"]
}
if os_info.lower() in syslist.get("mac"): # Mac
# Install brew
cmd = 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2 > /dev/null'
os.system(cmd)
# Install Nmap
cmd = "brew install nmap"
os.system(cmd)
# Install python-nmap
cmd = "pip install python-nmap"
os.system(cmd)
if os_info.lower() in syslist.get("linux"): # Linux
# python-dev,python-pip
os.system("apt-get -y install python-dev")
os.system("apt-get install python-pip")
# lxml
os.system("apt-get -y install libxml2 libxml2-dev")
os.system("apt-get -y install python-libxml2")
os.system("apt-get -y install python-lxml")
# nmap
os.system("apt-get -y install nmap")
# python-paramiko
os.system("apt-get -y install python-paramiko")
if os_info.lower() in syslist.get("win"): # windows
pass
'''
# pip install -r requirements.txt
piprequire = Settings.ROOT_PATH + "/requirements.txt"
os.system("pip install -r " + piprequire)