Python - 虽然输入不起作用

时间:2017-08-11 18:33:12

标签: python input while-loop

为什么这不起作用?我输入windows/meterpreter/reverse_tcp并再次返回错误

def shellcode():
    os.system("clear")
    print style
    print green + "  [+]Your Choose 4 | C Type Format - ShellCode Generate"
    print style
    print payload_types
    print ' '
    payload_choose = raw_input(time + white + "Choose Payload > ")
    while (payload_choose != "windows/meterpreter/reverse_tcp" or "linux/x86/meterpreter/reverse_tcp"):
        print "[-]error"
        payload_choose = raw_input(time + white + "Choose Payload > ")
    print "ok"

1 个答案:

答案 0 :(得分:4)

这一行:

while (payload_choose != "windows/meterpreter/reverse_tcp" or "linux/x86/meterpreter/reverse_tcp"):

可能不会做你想要的。我想你可能就是这个意思?

while payload_choose != "windows/meterpreter/reverse_tcp" and payload_choose != "linux/x86/meterpreter/reverse_tcp":

进一步说明

这个表达式:

a or b

表示“a是真或b是真的”。

这个表达式:

foo != 'hello' or 'goodbye'

表示“(foo!='hello')为真或'再见'为真”。在Python中,非空字符串被认为是“真实的”,因此原始的while循环条件始终为真。