python写poc时的笔记
This_is_Y Lv6

requests请求

在批量验证是,不要直接写
rsp=request.get
这一块尽可能的使用try,同时设置timeout和verify
verify=False, timeout=25
如下

1
2
3
4
try:
rsp = requests.post(url=url,headers=headers,files=uploaddata,verify=False, timeout=25)
except:
print('error')

multipart文件上传

python发送一个文件上传的请求包,这里我使用的requests包,因为没找到直接在数据包里修改数据的办法,所以我采取的办法是先建立一个文件,在打开一个它。

注意这里使用的是files=uploaddata,指定files,如果用的data,那就不是上传文件了。(花了一小时在这上面,太憨憨了)

1
2
3
4
5
6
7
8
9
10
11
with open('test2.php','w',encoding='utf-8')as f:
# f.write('<?php echo "py";phpinfo();?>\n')
f.write('hello world\n')
uploaddata = {
'Filedata':('test.php',open('test2.php', 'rb'), 'image/jpeg') # image或者file
}

try:
rsp = requests.post(url=url,headers=headers,files=uploaddata,verify=False, timeout=25)
except:
print('error')
 Comments