-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
48 lines (42 loc) · 1.19 KB
/
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
import io
import time
import socket
import pyscreenshot as ImageGrab
from gzip import zlib
class client:
# Constructor
def __init__(self, address, port, packet_size=4096000):
self.address = address
self.port = port
self.packet_size = packet_size
# Socket creation
def create_socket(self):
while True:
try:
connection = (self.address, self.port)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = socket.create_connection(connection)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, self.packet_size)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
return sock
except:
print "[!] Error creating socket .... trying again"
time.sleep(2)
# Start client
def start(self):
sock = self.create_socket()
while True:
try:
stream_buffer = io.BytesIO()
ImageGrab.grab().save(stream_buffer,'PNG')
screenshot = stream_buffer.getvalue()
# Compress screenshot
screenshot = zlib.compress(screenshot)
sock.sendall(screenshot)
time.sleep(0.1)
except:
print "[!] Error starting client.... trying again"
time.sleep(2)
if __name__ == '__main__':
elclient = client('127.0.0.1',9595)
elclient.start()