Vulnhb 靶场系列:Jarbas1.0
靶场镜像
信息收集
攻击机kali IP地址

通过nmap 进行主机发现,发现目标机IP地址
nmap -sP 192.168.227.1/24

参数说明:
-sP (Ping扫描)
该选项告诉Nmap仅仅 进行ping扫描 (主机发现),然后打印出对扫描做出响应的那些主机。 没有进一步的测试 (如端口扫描或者操作系统探测)。 这比列表扫描更积极,常常用于 和列表扫描相同的目的。它可以得到些许目标网络的信息而不被特别注意到。 对于攻击者来说,了解多少主机正在运行比列表扫描提供的一列IP和主机名往往更有价值。
确定下来目标机的主机信息后,通过nmap 探测目标机的服务信息及开放的端口信息
nmap -A 192.168.227.139

可以看到开放了web 服务80端口和8080端口,首先访问一下80端口

没有发现什么有用信息,进一步探测一下web 目录,这里使用kali 下的dirb,指定类型为html文件
dirb http://192.168.227.139/ -X .html

发现两个文件,访问http://192.168.227.139/access.html

发现三组MD5加密的账号密码,解密之

尝试用这三组账号密码登录ssh和mysql,发现并不能登录

访问8080端口

尝试登录,发现第三组账号密码成功登录

漏洞挖掘
我们发现8080端口开放的服务,存在漏洞利用

参考文档:
https://www.rapid7.com/db/modules/exploit/multi/http/jenkins_script_console
打开msfconsole,并使用漏洞exp

设置参数

输入exploit,获取到一个meterpreter

输入shell,获取到一个shell 会话

也可以通过python 建立会话
python -c 'import pty;pty.spawn("/bin/bash")';

尝试通过find 发现flag 文件,发现权限太低,几乎都没法访问

最后我们发现一个很有意思的脚本


这个脚本每隔5分钟会清理一次http的访问日志,更重要的是这个脚本的权限是777

提权
我们先在本地新建一个CleaningScript.sh ,用于给find 设置suid权限,可以像root用户那样启动
chmod u+s /usr/bin/find

参考链接:
https://blog.csdn.net/wangjia55/article/details/80858415
通过meterpreter 上传脚本到目标机

等待5分钟进入shell

发现find 具有了suid权限

这时我们就可以利用find 命令的exec 功能以root 权限执行其他命令了

参考链接:
https://blog.csdn.net/hongrisl/article/details/83018536
最后我们就可以查找root 下是否有flag 文件了

并成功读取flag文件


另一种提权方法
同样先获取到meterpreter 权限,本地新建脚本CleaningScript.sh ,用于给cp 设置suid 的权限
chmod u+s /usr/bin/cp

通过meterpreter上传,然后在目标机通过cat 查看/etc/passwd

把文件内容复制下来,在本地新建passwd 粘贴内容,并创建一个具有root 权限的新用户

用户密码可以通过openssl 生成

通过meterpreter 上传到目标机/tmp 目录下

通过咱们设置好的cp 命令覆盖原先的/etc/passwd

su 切换到咱们创建的用户,成功获取到root 权限

另另一种提权方法
首先在本地通过msfvenom 生成一个反弹shell

在本地写入CleaningScript.sh

通过meterpreter 上传到目标机

在kali 开启监听

等待5分钟后,获取到一个root权限反弹shell


欢迎访问阿威的博客 https://www.cnblogs.com/TWX521/ 专注技术与交流,stay hungry stay foolish
