Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

python requests怎么解决url中../自动跳目录的问题?

import requests

burp0_url = "http://127.0.0.1:80/../../../../a"
burp0_headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36", "Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "close", "Accept-Language": "en"}
requests.get(burp0_url, headers=burp0_headers, proxies={'http':'http://127.0.0.1:8080'})

image.png
图中可见../自动跳了目录,../在请求中不见了。
image.png
别给建议说编码、curl什么的,烦请能实现了再回答,能用python解决就行,谢了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

解决办法:

import urllib.request

proxy_support = urllib.request.ProxyHandler({"http" : "http://127.0.0.1:8080"})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)

url = "http://127.0.0.1/../../../../a"
f = urllib.request.urlopen(url)
print(f.read())

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...