文章来源:先知社区
0x00 使用场景
0x01 原理
Socket-reuse shellcode is used to bypass firewalls. Usually, shellcode and exploit developers and users provide "bindshell" and "connect-back" shellcodes. Both of these require a permissive firewall to some extent or another. However, because sockets are treated as re-usable or dynamic file descriptors by most operating systems, it is possible to examine existing socket connections, therefore one can simply bind a shell to the socket that the exploit shellcode came from.
0x02 踩坑过程
select_fd[0]
即数据库链接fd1337
,select_fd[1]
是我们用proxychains
连接时产生的fdproxychains ssh [email protected]
,抓个包验证一下(不熟悉socks5的师傅可以看看这个),客户端先发送了05 01 00
,05
是版本号,01
是支持的认证方式总数,后面就是认证方式,00
即NOAUTH
05 00
,同样05
是版本号,00
是服务端选择的认证方式05 01 00 01 7f 00 00 01 00 16
,各字节含义如下:-
05
版本号 -
01
CONNECT命令 -
00
保留字段 -
01
地址类型为IPv4 -
7f 00 00 01
IP地址127.0.0.1 -
00 16
端口号22
PSH ACK
的回应,于是客户端发了FIN结束连接,所以问题在服务端select do_carracha('a');
之后,服务端用getpeername遍历所有fd,通过ip匹配上我们的连接,并fork出一个子进程,执行payload05 01 00
和服务端发的05 00
05 01 00 01 7f 00 00 01 00 16
的前4个字节01
,但是判断socks命令类型不应该是判断第2个字节吗......虽然结果是一样的,这里就假设是对的
00
......所以是socks5_invitation这里读少了一个字节,擦,那作者是怎么跑成功的......联系/合作/投稿邮箱:[email protected]
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论