为什么类型错误:<string>中要求字符串作为左操作数,而不是列表

2024-10-06 12:34:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我在python脚本中遇到了一个错误。请让我知道我能做什么

import requests import sys import time
url="http://10.10.10.7/dvwa/vulnerabilities/fi/?page=" 
words = ['root','version','crontab']
cookies = {'security' : 'medium','PHPSESSID':'fbd52775729365907b53e763854c5d24'}
f=open('Payloads.txt','r') 
for i in f.readlines():
    ur=requests.get(url+'{}'.format(i),cookies=cookies)
    if words in ur.content.decode("utf-8"):
        print(( ' [Detect LFI]------->   '+'  Payload is  '+str(i)))
            time.sleep(1)
    else:
        print("Not Found LFI Vulnerability")
print ("Scanning....... complete")

错误消息:


Tags: inimport脚本httpurltime错误sys
1条回答
网友
1楼 · 发布于 2024-10-06 12:34:39

您的问题在于这一行:

if words in ur.content.decode("utf-8"):

words是一个列表,ur.content.decode("utf-8")结果是一个字符串。如错误消息所示,表单表达式的左侧:

<left-hand-side> in <string>

要求<left-hand-side>是字符串,而不是列表。下面是一个表达式,它将执行您想要执行的操作:

if any(s in ur.content.decode("utf-8") for s in words):

相关问题 更多 >