forked from youtubetutorial/DarkSpiritz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
219 lines (203 loc) · 7.14 KB
/
main.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/python
# -*- coding: utf-8 -*-
colors=['\033[0m', # 0} WHITE
'\033[31m', # 1} RED
'\033[32m', # 2} YELLOW
'\033[33m', # 3} PURPLE
'\033[34m', # 4} CYAN
'\033[35m', # 5} MAGENT
'\033[36m', # 6} CURL ____
'\033[1m', # 7} WHITE LOW
'\033[4m', # 8} WHITE HIGH
'\033[0m', # 9} WHITE (FUCK)
'\033[40m', # 10} BACKGROUND GREY
'\033[41m', # 11} BACKGROUND RED
'\033[42m', # 12} BACKGROUND GREEN
'\033[43m', # 13} BACKGROUND YELLOW
'\033[32m'] # 14} GREEN
import os, sys, time, readline, rlcompleter, os.path, platform, re, socket, glob
from time import sleep
from sys import stdout, exit
from core import help
from core import header
from os.path import join
from subprocess import check_output
from lxml import etree
from core import retarget
os.system('clear')
version_open = open("storage/version","r")
version = version_open.read()
intname = "dark"
lan_ip = os.popen("hostname -i | awk {' print $1 '}").read()
def complete(text, state):
a = (glob.glob(text + '*') + [None])[state].replace("__init__.pyc", "").replace("__init__.py", "").replace(".plugin", "").replace("banners", "").replace("Resources", "").replace("storage", "").replace("modules", "").replace("plugin_support.py", "").replace("plugin_support.pyc", "").replace("core", "").replace("main.py","").replace("files","")
a = a.replace("//", "/")
if os.path.isfile(a[:-1] + ".py"):
return a[:-1]
else:
return a
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(complete)
LOGS = "storage/logs"
STORAGE = "storage"
MODULES = "modules"
CORE = "core"
CHECK_LOGS = os.path.exists(LOGS)
CHECK_STORAGE = os.path.exists(STORAGE)
CHECK_MODULES = os.path.exists(MODULES)
CHECK_CORE = os.path.exists(CORE)
header.main_header()
if CHECK_CORE == False:
print "Missing files..."
sys.exit()
else:
pass
if CHECK_MODULES == False:
print "Missing files..."
sys.exit()
else:
pass
if CHECK_STORAGE == False:
print "Missing files..."
sys.exit()
else:
pass
RescoursesDir = os.getcwd()
dandtime = time.strftime("%d-%m-%Y-%H:%M:%S")
logfile = "storage/logs/%s.log" % (dandtime)
if CHECK_LOGS == True:
if os.path.exists("storage/logs/config.xml") == False:
print "[" + time.strftime("%H:%M:%S") + "] Failed to load Configuration file. STATUS:[" + colors[1] + "FAILED" + colors[0] + "]"
os.system("cp storage/config-skeleton.xml storage/logs/config.xml")
retarget.edit()
print "[" + time.strftime("%H:%M:%S") + "] Creating a Configuration file: storage/logs/config.xml. STATUS:[" + colors[14] + "OK" + colors[0] + "]"
time.sleep(0.6)
else:
print "[" + time.strftime("%H:%M:%S") + "] Failed creating Configuration file. STATUS:[" + colors[1] + "FAILED" + colors[0] + "]"
exit()
time.sleep(0.5)
#Wait and check internet activity
time.sleep(0.8)
sx = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
hostname = '0.0.0.0'
try:
sx.connect(('8.8.8.8', 80))
hostname = sx.getsockname()
data = "%s" % (hostname[0])
print "[" + time.strftime("%H:%M:%S") + "] Connected to a network", data
except KeyboardInterrupt:
print "[" + time.strftime("%H:%M:%S") + "] Failed to connect to a network"
#Start screen
time.sleep(0.1)
print "[" + time.strftime("%H:%M:%S") + "] Initializing Global State."
time.sleep(0.6)
print "[" + time.strftime("%H:%M:%S") + "] Detected Version => %s" % (version)
time.sleep(0.1)
mac_address = os.popen("ip addr | grep 'state UP' -A1 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'").read()
gateway_ip = check_output("/sbin/ip route | awk '/default/' | awk {' print $3 '} | sed -n 1p", shell=True)
PLUGIN_END = ".plugin"
PLUGIN_EXEC = "/usr/bin/python2 "
def main():
try:
line_1 = "\033[4m" + intname + "\033[0m > "
terminal = raw_input(line_1)
if terminal[0:3] =='use':
if terminal[4:] == terminal[4:]:
Exploit_check = "%s.plugin" % (terminal[4:])
if os.path.exists(Exploit_check) == True:
os.system("python %s.plugin" % (terminal[4:]))
main()
else:
print "[\033[1;91m!\033[0m] %s: could not be found" % (terminal[4:])
if terminal[0:6] == 'pyexec':
exec(terminal[7:])
main()
elif terminal[0:21] == "retarget":
retarget.edit()
main()
elif terminal[0:17] == 'show ' + terminal[5:]:
print ""
print "Plugin Category: " + terminal[5:]
print "==============================\n"
print " Name Description"
print " ---- -----------"
directory_list = glob.glob(terminal[5:] + '/*.plugin')
for line in directory_list:
about = line
with open(about, 'r') as myfile:
data = myfile.read().splitlines()
desc = data[0]
datar = desc.replace("Description = '", "")
x = datar.rstrip("'")
bb = line.split(terminal[5:] + '/')[1].split('.plugin')[0]
if x == "#!/usr/bin/python":
x = "\033[1;91mDescription has not yet been implemented.\033[1;m"
print(" {0:17s} {1:12s}".format(bb,x))
print " "
main()
elif terminal[0:] == 'session':
print """Automatic Settings
======================
Variable Value
-------- -----
LOCAL_IP %s GATEWAY_IP %s MAC_ADDR %s""" % (str(lan_ip), str(gateway_ip), str(mac_address))
sesread = open("modules/session.py","r").read()
print ""
exec(sesread)
main()
elif terminal[0:4] =='help':
help.help()
main()
elif terminal[0:] == 'show':
showlist()
main()
elif terminal[0:2] =='?':
help.help()
main()
elif terminal[0:5] =='ipnet':
os.system('ifconfig')
main()
elif terminal[0:5] =='clear':
os.system('clear')
main()
elif terminal[0:6] =='banner':
os.system('clear')
header.main_header()
main()
elif terminal[0:9] =='exit':
exit()
elif terminal[0:1] =='!':
os.system(terminal[1:])
main()
else:
print "\033[31m[!]\033[0m %s: command not found" % (terminal)
main()
except(KeyboardInterrupt):
print "\n"
return main()
def showlist():
print """
Plugin Category
===============
Name
----"""
for d in glob.iglob('*'):
if "CONTRIBUTING.md" not in d:
if ".travis.yml" not in d:
if "requirements.txt" not in d:
if "LICENSE" not in d:
if "README.md" not in d:
if "lib" not in d:
if "installer.py" not in d:
if "main.py" not in d:
if "banners" not in d:
if "core" not in d:
if "Resources" not in d:
if "storage" not in d:
if "CODE_OF_CONDUCT.md" not in d:
if "modules" not in d:
print """ %s""" % (d)
print ""
if __name__=='__main__':
main()