/
configuration.py
75 lines (71 loc) · 2.89 KB
/
configuration.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
71
72
73
74
from configparser import ConfigParser
import platform, os, sys
config = ConfigParser()
def firstTimeSetup(plat):
try:
if plat == "Linux":
home = os.path.expanduser("~")
configpath = home + '/BabySploit'
os.system('mkdir ' + configpath)
os.system('mkdir ' + configpath + '/configuration')
elif plat == "Darwin":
home = os.path.expanduser("~")
configpath = home + '/BabySploit/configuration'
os.system('mkdir -p ' + configpath)
elif plat == "Windows":
home = os.path.expanduser("~")
configpath = home + "/BabySploit/configuration/"
os.mkdir(configpath)
createuser(configpath)
except Exception as e:
print('Error: Unable to setup configuration path! Try running this in sudo for the first time setup.')
print(e)
exit()
def createuser(configpath):
system = platform.system()
release = platform.release()
config['DEFAULT'] = {
'lhost': '0.0.0.0',
'lport': '8080',
'rhost': 'google.com',
'rport': '80',
'platform': '',
'usernamelist': '/usr/bin/share/wordlists',
'passwordlist': '/usr/bin/share/wordlists',
'urlpath': '/connect'
}
config['DEFAULT']['platform'] = "%s %s" % (system, release)
if platform.system() == "Linux":
with open(configpath + 'config.cfg', "w") as configfile:
config.write(configfile)
elif platform.system() == "MacOS":
with open(configpath + 'config.cfg', "w") as configfile:
config.write(configfile)
elif platform.system() == "Windows":
with open(configpath + 'config.cfg', "w") as configfile:
config.write(configfile)
def checkuser():
if platform.system() == "Linux":
home = os.path.expanduser("~")
configpath = home + "/BabySploit/configuration"
if os.path.exists(configpath) == True:
print(" [i] Loaded Configuration... [i]\n\n")
else:
firstTimeSetup(platform.system())
print(" [i] Created New Configuration File... [i]")
elif platform.system() == "Darwin":
home = os.path.expanduser("~")
configpath = home + "/BabySploit/configuration"
if os.path.exists(str(configpath)) == True:
print(" [i] Loaded Configuration... [i]\n\n")
else:
firstTimeSetup(platform.system())
print(" [i] Created New Configuration File... [i]")
elif platform.system() == "Windows":
home = os.path.expanduser("~")
configpath = home + "/BabySploit/configuration"
if os.path.exists(str(configpath)) == True:
print(" [i] Loaded Configuration... [i]\n\n")
else:
firstTimeSetup(platform.system())
print(" [i] Created New Configuration File... [i]")