![]() |
Re: try ... except
Zitat:
Zitat:
Hier das logische Prinzip:
Delphi-Quellcode:
err:=false
try //hier MUSS ein fehler erzeugt werden except err:=true end //hier kann mit hilfe der variable err kontrolliert werden ob die interne Fehlerbehandlungsroutine genutzt wurde oder ein Debugger angesprungen ist |
Re: try ... except
Du könntest auch soetwas machen wie
Delphi-Quellcode:
if IsDebuggerPresent then Application.Terminate;
![]() ;) |
Re: try ... except
Nee lass man, Olly Shadow ist einer der bevorzugten Debugger unter WinXP. Dieser ist mit Plugins ausgestattet die IsDebuggerPresent mit falschen werten füttert und ihn somit für diese funktion unsichtbar macht. Genauer gesagt soll es eine DLL werden die Prozesse vorm Debuggen schützt und auf vielfache art und weise nach Debuggern sucht. In eingen CrackMe#s von mir hat diese art von Debugger-Checks auc sehr gut funktioniert, nur weiss ich nicht wieso es jetzt nicht funktioniert :(
|
Re: try ... except
hier mal der komplette source
Delphi-Quellcode:
Bis auf die Funktion ForceException funtioniert es auch wunderbar
library test;
uses // dialogs,sysutils, windows; const IMAGEBASE = $00400000; CRC = $4808181C; {$R *.res} procedure CheckSerial(serial:Pchar); begin if Serial='MCQs Debugger-Protection' then 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. |
Re: try ... except
Lies dir das mal durch:
![]() Und guck dir mal diesen Code an:
Delphi-Quellcode:
Wior der Code ausgeführt, crasht der Debugger. Läßt sich aber auch umgehen, wenn man weiß, wie. Lass dir gesagt sein, dass es keinen hundertprozentigen Crack-Schutz gibt.
asm
pushad call @SetupSEHAndRaiseException mov ecx, dword ptr [esp+12] mov eax, fs:[$30] movzx eax, byte ptr [eax+$2] and eax, eax jnz @NoAddOpCodeSize mov dword ptr [ecx+$B8], offset @AfterExceptionCause @NoAddOpCodeSize: mov dword ptr [ecx+$04], eax mov dword ptr [ecx+$08], eax mov dword ptr [ecx+$0C], eax mov dword ptr [ecx+$10], eax mov dword ptr [ecx+$14], eax and dword ptr [ecx+$18], $155 and dword ptr [ecx+$C0], $FFFFFEFF xor eax, eax ret @SetupSEHAndRaiseException: xor eax, eax push dword ptr fs:[eax] mov fs:[eax], esp @KillCode: and dword ptr [eax+$18], $155 @AfterExceptionCause: pop dword ptr fs:[$0] add esp, $4 popad end; |
Re: try ... except
Naja, ich werd es mal tracen und schauen was passiert.
Das es keinen 100%igen CrackSchutz ist mir klar, schließlich cracke ich selbst schon einige jahre (nur legale CrackMe's natürlich ;) ) aber wenn ich schon einen Schutz einbaue, dann möchte ich dch wenigstens das der Angreifer etwas davon merkt, und das ist bei IsDebuggerPresent nicht der fall daran ändert auch die nachprogrammierung von M. Puff nichts. Danke erstmal für eure Hilfe, sollte ich trotz tracens nicht weiterkommen melde ich mich hier nochmal Greez MCQ |
Re: try ... except
Irgendwas scheint da massiv nicht zu stimmen, wenn selbst eine popelige EDevByZero-Exception durch try-except nicht abgefangen wird. Bei mir (XP, SP2, in einer VM) funktioniert es jedenfalls ohne Probleme, auch mit int3 und DebugBreak(). Hast du den Code mal auf einem zweiten System (vorzugsweise einer möglichst sauberen Installation) kompiliert und getestet?
Zitat:
DebugBreak() tut auch nichts anderes, als eine schnöde Exception zu werfen, die wie jede andere auch abgefangen werden kann. |
Re: try ... except
So, das Problem ist gelöst, ich hoffe mir kann jemannd erklären wieso es nach der einbindung von sysutils geklappt hat. Wenn windows beim ausführen von try-except etwas fehlen sollte, sollte dann der Compiler nicht meckern?
|
Re: try ... except
Zitat:
|
Re: try ... except
Hallo,
ich bin ja kein Delphi-Crack, aber ich vermisse da eine solche Zeile nach "except":
Delphi-Quellcode:
Soweit ich weiss wird nur so die Exception als behandelt betrachtet. (?)
on <Deine_Exceptionklasse> do err := ....
Tschau /\/\arcus |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:52 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz