ssrf之gopher协议的使用和配置,以及需要注意的细节

gopher协议

目录

gopher协议

(1)安装一个cn

(2)使用Gopher协议发送一个请求,环境为:nc起一个监听,curl发送gopher请求

(3)使用curl发送http请求,命令为

(4)使用gopher输出

(5)get请求

(6)post请求

需要注意的几个细节:


URL:gopher://<host>:<port>/<gopher-path>_ 后接TCP数据流

gopher的默认端口是70

如果发起post请求,回车换行需要使用%0d%0a,如果多个参数,参数之间的&也需要进行URL编码

(1)安装一个cn

yum install -y nc

(2)使用Gopher协议发送一个请求,环境为:nc起一个监听,curl发送gopher请求

nc启动监听,监听9527端口:

nc -lp 9527

(3)使用curl发送http请求,命令为

curl gopher://127.0.0.1:9527/abcd

输出结果为bcd

当修改为curl gopher://127.0.0.1:9527/_abcd

输出结果为abcd

所以在执行时第一个字符会被抵消掉

(4)使用gopher输出

创建一个123.txt并输入代码为123123

 在另一个终端使用gopher进行shuchu

curl http://127.0.0.1/123.txt

这里需要注意当出现403报错时需要输入 setenforce 0可以暂时得到root权限

如果说要长期得到则需要在vim /etc/selinux/config 里面将enforcing改为disabled

(5)get请求

创建一个get请求的php代码如下

<?php

echo "hello ".$_GET['name'];

?>

将如下代码进行url编码

GET /ssrf/get.php?name=HSJ HTTP/1.1

Host: 127.0.0.1

编码后的结果为

GET%20%2Fget.php%3Fname%3Droot%20HTTP%2F1.1%0d%0aHost%3A%20127.0.0.1%0d%0a%0d%0a

用gopher去执行

curl gopher://127.0.0.1:80/_GET%20%2Fget.php%3Fname%3Droot%20HTTP%2F1.1%0d%0a

Host%3A%20127.0.0.1%0d%0a%0d%0a

结果为

(6)post请求

创建一个post请求的php代码如下

<?php

echo "hello ".$_POST['name'];

?>

将如下代码进行url编码

POST /post.php HTTP/1.1

host:127.0.0.1

Content-Type:application/x-www-form-urlencoded

Content-Length:8

name=HSJ

编码后的结果为

POST%20%2Fpost.php%20HTTP%2F1.1%0d%0ahost%3A127.0.0.1%0d%0aContent-Type%3Aapplication%2Fx-www-form-urlencoded%0d%0aContent-Length%3A8%0d%0a%0d%0aname%3DHSJ

用gopher去执行

curl gopher://127.0.0.1:80/_POST%20%2Fpost.php%20HTTP%2F1.1%0d%0ahost%3A127.0.0.1%0d%0aContent-Type%3Aapplication%2Fx-www-form-urlencoded%0d%0aContent-Length%3A8%0d%0a%0d%0aname%3DHSJ

结果为

需要注意的几个细节:

1、问号(?)需要转码为URL编码,也就是%3f

2、回车换行要变为%0d%0a,但如果直接用工具转,可能只会有%0a 3、在HTTP包的最后要

%0d%0a,代表消息结束(具体可研究HTTP包结束)

最近更新

  1. TCP协议是安全的吗?

    2023-12-31 19:52:02       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-31 19:52:02       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-31 19:52:02       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-31 19:52:02       18 阅读

热门阅读

  1. go 语言程序设计第3章--基础数据类型

    2023-12-31 19:52:02       34 阅读
  2. Bug升级记

    2023-12-31 19:52:02       41 阅读
  3. CF1914C Quests

    2023-12-31 19:52:02       36 阅读
  4. Crow:run的流程2 建立io_service及线程

    2023-12-31 19:52:02       41 阅读
  5. C语言K&R圣经笔记 4.10递归 4.11 C预处理

    2023-12-31 19:52:02       30 阅读
  6. 归并排序模板

    2023-12-31 19:52:02       32 阅读