Loading

ssrf利用所得----gopher协议

gopher协议

协议简介

gopher应用于http协议之前,用于访问internet,虽然很古老,但是目前很多库还在支持gopher协议,并且gopher协议很强大。
可以实现多数据包整合发送 ,然后gopher服务端家安多个数据包昆巴昂着发送到客户端,这就是他的菜单响应。
gopher协议使用tcp建立可靠连接。

协议格式

gopher协议格式为

gopher://<host>:<port>/<gopher-path>

默认为70

其中格式可以是如下的一种

<gophertype><selector>
<gophertype><selector>%09<search>
<gophertype><selector>%09<search>%09<gopher+_string>

整个<gopher-path>部分可以省略,这时候\也可以省略<gophertype>为默认的1。
<gophertype>是一个单字符用来表示url 资源的类型,在常用的安全测试中发现不管这个字符是什么都不影响,只要有就行了。
<selector>个人理解这个是包的内容,为了避免一些特殊符号需要进行url 编码,但如果直接把wireshark 中ascii 编码的数据直接进行url 编码然后丢到gopher 协议里跑会出错,得在wireshark 里先换成hex 编码的原始数据后再每两个字符的加上%,通过对比发现直接url 编码的话会少了%0d回车字符。
<search>用于向gopher 搜索引擎提交搜索数据,和<selector>之间用%09隔开。
<gopher+_string>是获取gopher+ 项所需的信息,gopher+ 是gopher 协议的升级版。

import urllib.parse

if __name__ == '__main__':
    cansshu = """POST /?a=1 HTTP/1.1
Host: 172.73.23.100:80
Content-Length: 3
Content-Type: application/x-www-form-urlencoded
X-Forwarded-For:127.0.0.1
Referer: bolean.club

b=1"""
    cansshu = urllib.parse.quote(cansshu)
    cansshu.replace("%0A","%0D%0A")
    cansshu = urllib.parse.quote(cansshu)
    print(cansshu)
posted @ 2022-04-25 19:47  sovo  阅读(242)  评论(0)    收藏  举报