Thema: Delphi try ... except

Einzelnen Beitrag anzeigen

MCQ

Registriert seit: 14. Jan 2004
Ort: Dessau
80 Beiträge
 
#14

Re: try ... except

  Alt 14. Feb 2006, 22:15
hier mal der komplette source

Delphi-Quellcode:
library test;

uses
// dialogs,sysutils,
  windows;

const
 IMAGEBASE = $00400000;
 CRC = $4808181C;
{$R *.res}


procedure CheckSerial(serial:Pchar);
begin
if Serial='MCQs Debugger-Protectionthen
MessageBox(0,'Gültige Serial - aber darum gings hier ja auch nicht ;)','',MB_ICONINFORMATION)
else
MessageBox(0,'ungültige Serial','Fehler',MB_ICONERROR)
end;


exports CheckSerial;



procedure ForceException;stdcall;
var start,ende,dw:DWORD;
    err:boolean;
begin
err:=false;
start:=GetTickCount;
try
 asm
  int 3 // <-- BreakPoint für Debugger
 end
except
 err:=true;
end;
ende:=GetTickCount;
if (start-ende>10) or not err then ExitProcess(0); // wenn Debugger angesprungen oder timeout dann ExitProcess
end;


procedure AntiBP;
label weiter;
var mycrc:DWORD;
begin
 asm
(*
  EAX - Start
  EBX - Länge
  ECX - Zähler
  EDX - CRC
*)

  push eax
  push ebx
  push ecx
  push edx
  mov eax,IMAGEBASE
  add eax,$3C
  mov eax,[eax]
  add eax, IMAGEBASE
  mov ebx, [eax+$1C] // Size of Code
  mov eax, [eax+$2C] // Base of Code
  add eax, IMAGEBASE
  xor ecx, ecx
  xor edx, edx
  weiter:
  xor edx,[eax+ecx]
  inc ecx
  cmp ecx,ebx
  jnz weiter
// int 3
  mov mycrc,edx
  cmp edx,crc
  push 100
  call sleep
  pop edx
  pop ecx
  pop ebx
  pop eax
  jz AntiBP
  mov eax,offset ExitProcess
  call eax
  end;
// showmessage(inttohex(mycrc,8));
  ExitProcess(0);
end;

procedure AntiAttach;
var pProc:Pointer;
    tmp:DWORD;
begin
pProc:=GetProcAddress(LoadLibrary('ntdll.dll'),'DbgUiRemoteBreakin');
VirtualProtect(pProc,1,PAGE_EXECUTE_READWRITE,tmp);
asm
 push eax
  mov eax,pProc
  mov [eax],$006A
  mov [eax+2],$B8
  mov [eax+3], offset ExitProcess
  mov [eax+7], $D0FF
 pop eax
end;
VirtualProtect(pProc,1,tmp,tmp);
end;


label SetAPIHook;
var tmp:DWORD;
begin
 asm
  push eax
  push ebx
  mov eax,IMAGEBASE
  add eax,$3C
  mov eax,[eax]
  add eax,IMAGEBASE
  add eax,$28
  mov eax,[eax]
  add eax,IMAGEBASE
  mov bl,[eax]
  xor bl,$23
  add bl,$11
  test bl,bl
  jnz SetAPIHook
  mov eax,offset ExitProcess
  push 0
  call eax // ExitProcess(0);
  SetAPIHook:
  pop ebx
  pop eax
  call AntiAttach
  call ForceException
 end;
BeginThread(nil,0,@AntiBP,nil,0,tmp);
end.
Bis auf die Funktion ForceException funtioniert es auch wunderbar
  Mit Zitat antworten Zitat