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

maybe-why-not · 2021年01月01日 · 最后由 maybe-why-not 回复于 2021年01月01日 · 1610 次阅读
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'})


图中可见../自动跳了目录,../在请求中不见了。

别给建议说编码、curl 什么的,烦请能实现了再回答,能用 python 解决就行,谢了。

共收到 1 条回复 时间 点赞

解决办法:

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())
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册