") print "Set ip t-6ren">
gpt4 book ai didi

python - Python,我正在编码一个远程shell制造器,并继续遇到语法错误

转载 作者:行者123 更新时间:2023-12-03 08:10:43 25 4
gpt4 key购买 nike

import os
os.system("touch shellback.py")
a = raw_input("IP of The Listener(you)> ")
print "Set ip to "+ a +""
file = open("shellbackdoor.py", "a")
file.write("from socket import *\n")
file.write("HOST = '"+ a +"'\n");
file.close()
file = open("shellback.py", "a")
file.write("PORT = 443\n")
print "You might to to port forward your router to the port 443"
file.write("s = socket(AF_INET, SOCK_STREAM)\n")
file.write("s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)\n")
file.write("s.bind((HOST, PORT))\n")
file.write("print 'Listening on "+ a +":%s' % str(PORT)\n")
file.write("s.listen(10)\n")
file.write("conn, addr = s.accept()\n")
file.write("print 'Connected by', addr\n")
file.write("data = conn.recv(1024)\n")
file.write("while 1:\n")
file.write(" command = raw_input("> ")")
file.write(" conn.send(command)\n")
file.write(" if command == "quit":\n")
file.write(" break\n")
file.write(" data = conn.recv(1024)\n")
file.write(" print data\n")
file.write("conn.close()\n")

我继续遇到语法错误
file.write("     if command == "quit":\n")

放我不知道为什么

它在上面使用了两行
file.write("     command = raw_input("Insert your command or quit>")")

但是在我将其更改为后,它停止了错误
file.write("     command = raw_input("> ")")

最佳答案

你做得对。但是您需要像我在下面显示的那样避免双引号

您代码中的行:

file.write("     if command == "quit":\n")

固定线
file.write("     if command == \"quit\":\n")

希望这可以帮助

关于python - Python,我正在编码一个远程shell制造器,并继续遇到语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49832623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com