Code: Select all
Import "kernel32.lib"
GetProcAddress(h.i,s.p-Ascii)
EndImport
Procedure.i RunPatchStub(Target.s,Offset.l,Value.l)
Structure PATCH_STUB_STRUCT
a1.l
a2.l
a3.l
a4.l
a5.l
offset.l
value.l
EndStructure
Protected *Ascii
Protected AsciiSize.l
Protected *Buffer
Protected *Patch.PATCH_STUB_STRUCT
Protected Base.l
Protected Result.l
Base = GetModuleHandle_("kernel32.dll")
*Ascii = Ascii(Target)
If *Ascii
AsciiSize = MemorySize(*Ascii)
*Buffer = AllocateMemory(AsciiSize + 146)
If *Buffer
CopyMemory(?Shellcode,*Buffer,146)
CopyMemory(*Ascii,*Buffer + 146,AsciiSize)
*Patch = *Buffer + 146 - SizeOf(PATCH_STUB_STRUCT)
*Patch\a1 = GetProcAddress(Base,"CreateFileA")
*Patch\a2 = GetProcAddress(Base,"Sleep")
*Patch\a3 = GetProcAddress(Base,"SetFilePointer")
*Patch\a4 = GetProcAddress(Base,"WriteFile")
*Patch\a5 = GetProcAddress(Base,"CloseHandle")
*Patch\offset = Offset
*Patch\value = Value
Result = CallFunctionFast(*Buffer)
FreeMemory(*Buffer)
EndIf
FreeMemory(*Ascii)
EndIf
ProcedureReturn Result
Shellcode:;by CELTIC88 (with changed delay!)
!db 0E8h,06Ah,000h,000h,000h,089h,0C5h,068h,00Ah,000h,000h,000h,0FFh
!db 055h,004h,08Dh,055h,01Ch,068h,000h,000h,000h,000h,068h,000h,000h
!db 000h,000h,068h,003h,000h,000h,000h,068h,000h,000h,000h,000h,068h
!db 000h,000h,000h,000h,068h,000h,000h,000h,040h,052h,0FFh,055h,000h
!db 083h,0F8h,0FFh,074h,0CEh,050h,068h,000h,000h,000h,000h,068h,000h
!db 000h,000h,000h,0FFh,075h,014h,050h,0FFh,055h,008h,08Bh,004h,024h
!db 08Dh,055h,018h,051h,08Dh,00Ch,024h,068h,000h,000h,000h,000h,051h
!db 068h,004h,000h,000h,000h,052h,050h,0FFh,055h,00Ch,059h,08Bh,004h
!db 024h,050h,0FFh,055h,010h,058h,0C3h,08Bh,004h,024h,083h,0C0h,071h
!db 0C3h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
!db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
!db 000h,000h,000h
EndProcedure
OpenConsole("PatchStub (x86) by CELTIC88")
PrintN(Str(RunPatchStub("Test.exe",$280,$FFFFFFFF)))
Input()
CloseConsole()