-
Notifications
You must be signed in to change notification settings - Fork 0
/
detexploit_server_console.py
118 lines (113 loc) · 4.5 KB
/
detexploit_server_console.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
###########################################################
# detexploit_server_cons.py
# Server console
# DetExploit (https://github.com/moppoi5168/DetExploit)
# Licensed by GPL License
###########################################################
import urllib.request
from pyfiglet import figlet_format
import sys
from termcolor import cprint
import colorama
def main():
print("Please enter your server's IP address.")
HOST = input('>> ')
print("Please enter your server's port number.")
PORT = input('>> ')
print("Please enter your server's management password.")
nopass = input('>> ')
if HOST == '0.0.0.0':
rurl = 'http://localhost:' + PORT + '/atest'
else:
rurl = 'http://' + HOST + ':' + PORT + '/atest'
with urllib.request.urlopen(url=rurl, data=nopass.encode()) as tp:
result = tp.read()
if result == b'Success':
print('Logged in to server management platform!!')
passwd = nopass
else:
print('Auth Failed :(')
exit(1)
print('\n')
while True:
inst = input('DSERVER >> ')
if inst == 'exit':
break
elif 'push' in inst:
tmp = inst.split(' ')
if HOST == '0.0.0.0':
rurl = 'http://localhost:' + PORT + '/push'
else:
rurl = 'http://' + HOST + ':' + PORT + '/push'
try:
sdata = tmp[1].encode() + b'|||' + passwd.encode()
except IndexError:
print('Error: UID is not specified')
pass
with urllib.request.urlopen(url=rurl, data=sdata) as tp:
res = tp.read().decode()
if res == 'Success':
print('Starting the scan......')
else:
print('Error: UID not found on server')
elif inst == 'pall':
print('Pushing scan instruction to all registered machine...')
if HOST == '0.0.0.0':
rurl = 'http://localhost:' + PORT + '/pushall'
else:
rurl = 'http://' + HOST + ':' + PORT + '/pushall'
with urllib.request.urlopen(url=rurl, data=passwd.encode()) as tp:
res = tp.read().decode()
if res == 'Success':
print('Starting the scan......')
else:
print('Error: Authenciation failed')
elif inst == 'lsrep':
if HOST == '0.0.0.0':
rurl = 'http://localhost:' + PORT + '/rhist'
else:
rurl = 'http://' + HOST + ':' + PORT + '/rhist'
with urllib.request.urlopen(url=rurl, data=passwd.encode()) as tp:
res = tp.read().decode()
print(res)
elif 'catrep' in inst:
tmp = inst.split(' ')
if HOST == '0.0.0.0':
rurl = 'http://localhost:' + PORT + '/ohist'
else:
rurl = 'http://' + HOST + ':' + PORT + '/ohist'
sdata = tmp[1].encode() + b'|||' + passwd.encode()
with urllib.request.urlopen(url=rurl, data=sdata) as tp:
res = tp.read().decode()
print(res)
elif inst == 'list':
print('''
Command List
> push [UID] : Send scan instruction to target machine
> pall : Push scan instruction to all registered machine
> uids : List up all UID's stored in server
> lsrep : List up report file(s) stored in server
> catrep [FN] : Open specific report file stored in server
> exit : Exit
''')
elif inst == 'uids':
if HOST == '0.0.0.0':
rurl = 'http://localhost:' + PORT + '/pcli'
else:
rurl = 'http://' + HOST + ':' + PORT + '/pcli'
with urllib.request.urlopen(url=rurl, data=passwd.encode()) as tp:
uids = tp.read().decode()
if '|||' in uids:
tmp = uids.split('|||')
print('UID List')
for uid in tmp:
print('>> ' + uid + '\n')
else:
print('UID List')
print('>> ' + uids)
else:
print('\nCommand not find. \nUse list command to see entire command for this console.\n')
if __name__ == '__main__':
colorama.init(strip=not sys.stdout.isatty())
cprint(figlet_format(' DetExploit'), 'red', attrs=['bold'], end='')
main()