Check the EXE file prevention software from being cracked

xiaoxiao2021-03-06  37

Software condensed developers' heart blood, almost every kind of shared software is crackdown, protecting software from cracking, is the wish of each software author. Whether you restrict the number of software used or the number of days, the crack can only use anti-compilation software, directly modify the number of times of the exe file into unlimited, or modify the jump instruction, so that the registration code is invalid.

How to protect your software from crack? The self-verification of the program is better.

First, the principle is as follows:

Software developers have two executable files, one is crc.exe, responsible for verifying the exe file of shared software, gets its check code, write file system.dll (deliberately take this name, confuse the crackler, check The code is best encrypted, this article is not encrypted). The other is Selfcrc.exe, that is, the shared software we have written, it has the ability to verify itself. When sharing software is published, at least two files are included: Selfcrc.exe and System.dll.

Every time you run, you will first perform your own self-verification. The results are compared to the check code in System.dll, correctly, and the error will be warned and remove yourself. If the user deletes the SYSTEM.DLL file, the program will also refuse to execute and delete yourself. This ensures that this file cannot be run as long as the crackman has modified the EXE file.

Second, CRC.EXE interface and source code:

CRC.exe design interface

Unit unit1;

Interface

Uses

Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs,

STDCTRLS;

Type

TFORM1 = Class (TFORM)

Button1: tbutton;

Label1: TLABEL;

OpenDialog1: TopEndialog;

EDIT1: TEDIT;

Procedure Button1Click (Sender: TOBJECT);

Private

{Private Declarations}

public

{Public de clareds}

END;

VAR

FORM1: TFORM1;

IMPLEMentation

{$ R * .dfm}

/ / Define the calibration function

Function getChecksum (filename: string): DWORD;

VAR

F: File of DWORD;

P: POINTER;

Fsize: DWORD;

Buffer: array [0..500] of dword;

Begin

FileMode: = 0;

AssignFile (F, FileName);

RESET (F);

Seek (f, FileSize (f) Div 2);

Fsize: = filesize (f) -1 -filepos (f);

IF FSIZE> 500 THEN FSIZE: = 500;

Blockread (f, buffer, fsize);

Close (f);

P: = @Buffer;

ASM

XOR EAX, EAX

XOR ECX, ECX

Mov EDI, P

@Again:

Add Eax, [EDI 4 * ECX]

Inc ECX

CMP ECX, FSIZE

JL @again

Mov @ result, EAX

END;

END;

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);

VAR

CRCRESULT: DWORD;

Begin

// Open dialog box selection file

IF OpenDialog1.execute Thenbegin

CRCRESULT: = getChecksum (OpenDialog1.FileName);

IF crcResult <> 0 Then Edit1.Text: = INTTOHEX (CRCRESULT, 8)

Else ShowMessage ('The CRC Check Failed');

END;

END;

End.

Third, Selfcrc.exe interface and source program

Selfcrc.exe design interface

Unit unit1;

Interface

Uses

Windows, Messages, Sysutils, Classes, Graphics, Controls, Forms, Dialogs,

STDCTRLS;

Type

TFORM1 = Class (TFORM)

Button1: tbutton;

Label1: TLABEL;

Label2: TLABEL;

Procedure formcreate (Sender: TOBJECT);

Procedure Button1Click (Sender: TOBJECT);

Private

{Private Declarations}

public

{Public de clareds}

END;

VAR

FORM1: TFORM1;

IMPLEMentation

{$ R * .dfm}

/ / Define Delete your own process, dynamically create and execute batch files

Procedure deleteme (filename: String);

VAR

BATFILE: TEXTFILE;

Begin

Assignfile (Batfile, '. / delme.bat');

Rewrite (batFile);

Writeln (Batfile, '@ echo off');

Writeln (Batfile, ': loop');

Writeln (Batfile, 'DEL "' filename '");

Writeln (Batfile, 'if exist./file.exe goto loop ";

Writeln (Batfile, 'del./delme.bat');

Closefile (batFile);

Winexec ('./ delme.bat', sw_hide);

END;

/ / Define the calibration function

Function getChecksum (filename: string): DWORD;

// code is equal, omitted.

Procedure TFORM1.FormCreate (Sender: TOBJECT);

VAR

Outfile, batfile: textfile;

FNAME, CRCTRUE: STRING

CRCRESULT: DWORD;

Begin

Form1.visible: = false;

FNAME: = 'system.dll';

IF not fileexists (fname) THEN Begin

Application.Messagebox ('error: Due to the lost DLL file, the software will exit.', 'System Warning', 16);

// Delete yourself

Deleteme (Application.exename);

Application.Terminate;

end

Else Begin

AssignFile (Outfile, FNAME);

RESET (OUTFILE);

// Read the correct check code to CRCTRUE

Readln (Outfile, CRCTRUE);

Closefile (OUTFILE);

CRCRESULT: = getChecksum (Application.exename); if crcResult <> 0 THEN Begin

// In practical applications, the following prompt dialog box does not display

ShowMessage ('CRC verification results are:' INTTOHEX (CRCRESULT, 8));

// The verification results must be incorrect after cracking. The program refuses to execute and delete yourself

IF INTTOHEX (CRCRESULT, 8) <> CRCTRUE THEN

Begin

ShowMessage ('CRC result is wrong, the program will exit!');

Application.Terminate;

Deleteme (Application.exename);

end

Else Begin

ShowMessage ('CRC results are correct!');

END;

END;

END;

END;

Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);

Begin

CLOSE;

END;

End.

4. In practical applications, the number of days and days of the user's use and the number of days can only be used on one machine, and you can better protect your shared software from cracking. The above code is debugged in Win98, Delphi 5.0.

转载请注明原文地址:https://www.9cbs.com/read-64675.html

New Post(0)