This article mainly introduces the computer software registration and encryption technology from three aspects: Software registration and encryption in the DOS system, software registration and encryption in the Windows system, and the sharing software network registration method. Many of the methods described in this article are still in use, and some methods and technologies are outdated, but most of them are worth learning. While analyzing the registration encryption process and method, a lot of source code is referenced to highlight its implementation process.
Keywords:Software Encryption, software registration, and shared software
Introduction
With the development of computer science and technology, computer software has become an important part of computer science, and software products also play an important role in the computer product market. Due to the reproducibility and tampering of software products, it is easy to be illegally copied and sold, seriously damaging the legitimate rights and interests of software designers. To this end, software designers have made unremitting efforts to carefully encrypt their own software to ensure that their rights and interests are not infringed. They have succeeded, but they have also had a negative impact on computer security. Some designers add "logic bombs" to program code to crack down on piracy. What's more, A software with "suicide" and viruses was designed. When a replication operation was found, the code was used to destroy itself and spread the virus, these actions pose a threat to the security of computer systems.
To understand the popular computer software registration and encryption technologies, we must first go deep into the DOS system and deeply understand the principles and implementation methods of software registration and encryption in the DOS environment. Although Windows has been unified, DOS has long lost its light, but many software design ideas based on this platform are worth learning, because it has an irreplaceable feature of Windows: hardware operations are more convenient, and software encryption methods are more diversified and easier to implement. The emergence of Windows brings new opportunities to software designers: Registry, dynamic Connection Library, multi-thread technology and computer network provide a new way for software registration and encryption. If we can combine the software registration encryption technology under these two systems with completely different structures, I think the effect we can achieve is unmatched by any technology.
The focus of this article is not on the data encryption process, but on how to make full use of the features of the operating system and the provided API to make Software Encryption more secure. Or, we are more concerned about how to implement data encryption and how to implement Software encryption. Different Software Encryption and Data Encryption have different methods and purposes, but Software Encryption is inseparable from data encryption.
I,DOSSoftware registration and encryption technology in the system
Many shared software have the following characteristics: after a period of time, users are required to enter the user name and registration code. The user name is defined by the user, the registration code needs to be obtained through payment to the software author. After obtaining the registration code, the user enters the code in the dialog box and the software can continue to be used. Otherwise, the software will not run. This process is a process of first-class price exchange: the designer obtains its value, the user obtains the value of use, and the software becomes a commodity. So how does the software know that the information entered by the user is legal? In fact, it is very simple: the author and the software themselves use the same registration mechanism, or "protocol". users do not know this agreement, so they cannot crack the registration code and can only buy from the author. In fact, all registered software has a piece of code similar to the following:
Program MyProgram (Input, Output );
Function GetKey (UserName, OtherInfo: String): KeyType;
Begin
//...
End;
Function Registered (UserName, OtherInfor: String; UserInput: KeyType): Boolean;
Begin
If GetKey (UserName, OtherInfo) = UserInput then begin
Result: = TRUE;
Exit;
End;
Result: = FALSE;
End;
Begin
//...
If (not Registered) then begin
ShowMessage ('not Registered !! ');
Exit;
End;
//...
End.
In this Code, the GetKey function is used to generate a registration code using the user name and some other information. The Registered function is used to return whether the user is correctly Registered. As mentioned above, software encryption is different from Data Encryption. Software Encryption focuses on data encryption algorithms and data encryption concealment. The following describes common encryption technologies in the DOS system from three aspects.
1. Use hidden sectors of the disk for encryption
This is the oldest encryption technology. Still, why does the software prompt the user to register after it is used for a period of time or after how many times? How does it know how long or how many times the user has used it? We can think like this: when the software is installed by the installer, some information that records the legality and installation time of the user is written to the local computer. When the software is running in the future, you can determine whether the information is valid or whether to enable the user to continue using the information or register it immediately. This method also enhances the anti-replication capability of the software to a certain extent, because the copies cannot find legal user information on other machines that are not correctly installed, and thus cannot run correctly. In computer devices, the most direct place to store data is the disk, which is the most reliable to store the password information with hidden sectors of the hard disk. In the data structure of the hard disk, the first cylinder of each logical partition of the hard disk is hidden, and the last several cylinders of the entire physical hard disk are also hidden. It is hidden. That is to say, in the DOS system, the interrupted calls to disk read/write provided by an ordinary INT 21H cannot govern this part of the region, and the operation of this part of the hidden disk space is required, you must use INT 13 H.
The following Function Code reads and writes any part of the disk (including hidden sectors). It can read the information of one sector into the buffer zone and store the information in the buffer zone into one sector of the disk. It is worth noting that this function can only operate on data areas smaller than GB. Data areas larger than GB require INT 13 Extension support, which is not discussed here, interested readers can refer to the large-capacity hard disk read/write operation written by the author. This function is sufficient for general implementation of hidden sector encryption.
# Include <stdio. h>
# Include <dos. h>
Int DiskIo (int drive,
Int operation,
Unsigned int cylinder,
Unsigned int head,
Unsigned short sector,
Unsigned char * buffer)
{
Union REGS regs;
Struct SREGS sregs;
Regs. h. ah = operation; regs. h. al = 1;
Regs. x. bx = FP_OFF (buffer); sregs. es = FP_SEG (buffer );
Regs. h. ch = cylinder; regs. h. cl = sector;
Regs. h. dh = head; regs. h. dl = drive;
Int86x (0x13, & regs, & regs, & sregs );
Return regs. h. ah;
}
Finally, when designing the GetKey function in the software, try to use the hardware information and User Name of the Local Machine to generate a password and store it in a hidden sector, so that the password is confidential, and security.
2. Use the laser perforation method to implement anti-copy encryption for Software
This method is mainly implemented using the "trap technology" in programming. The basic design concept is as follows: the surface of the floppy disk is perforated, so that some sectors are damaged. This is physical damage and cannot be repaired using tools and software. Before developing software, the designer scans the disk surface with common detection tools, finds damaged sectors, records them, and designs the software later, as long as the software determines whether these sectors are damaged, it can determine whether the software has been copied.
This method is an economic and effective encryption method for the production of a small number of software products. However, if the software is to be produced in large quantities, this method becomes more complicated: the positions of each perforation are not necessarily the same, and the part numbers to be determined by the software are different. The implementation is quite difficult, but the design idea is worth learning from.
3. Anti-replication encryption technology for special channels
Although the laser perforation technology can achieve a good anti-copy encryption effect, its implementation process is quite complex. The special track anti-replication encryption technology is easy to implement and can play a very good role in software encryption. For the sake of simplicity, we will only discuss the floppy disk here.
The disk sector we discuss usually refers to the data zone. In fact, a sector consists of the identification zone, data zone, and two gaps. Some tracks (cylinders) is saved in a non-data zone. When the DOS system is started, the disk base table of the floppy disk is loaded to the memory unit at the starting address of. Many operations on the INT 13 H are determined based on this base table. Then, as long as we modify the disk base table and use a common INT 13 h to operate the disk, we can easily write the software key to the disk sector gap. Generally, the disk controller cannot write this type of sector on the disk. In this way, the general replication program cannot copy it, however, in the encrypted software program, the key at the gap can be read as a part of the special sector, and the key information can be determined to determine whether the software has been copied.
The following is an example of using this method to read a data zone with a sector length of 40,. the disk is read from the 0-sided, 0-sided, the read information is stored in the memory unit with the DS segment offset of H.
C: "WINDOWS> debug
-E00: 0525
02.05 3F. 01
-A100
1288: 0100 mov ax, 201
1288: 0103 mov bx, 1000
1288: 0106 mov cx, 0
1288: 0109 mov dx, 0
1288: 010C int 13
1288: 010E int 3
1288: 010F
-G = 100
The special track encryption is implemented in this way: the INT 13 h ah = 05H function is used to format the disk according to the parameters of the memory unit pointed to by the BX. As mentioned above, each slice has an ID consisting of a cylindrical ID, a head number, and a sector byte length. You only need to modify the ID parameter and format the disk with this special parameter, A special track is generated. The rest of the work is the same as the operation on the special sector: Write the key into the special track, you can achieve anti-copy software. The following is a C language function for formatting 360 K and DSDD disk tracks. The trktbl array stores the ID parameter of the disk sector.
Int fmt_trk (int dsk, int trk, int head)
{
Union REGS regs;
Struct SREGS sregs;
Char trktbl [36];
Int I;
For (I = 0; I <9; I ++ ){
Trktbl [I * 4] = trk;
Trktbl [I * 4 + 1] = head;
Trktbl [I * 4 + 2] = I;
Trktbl [I * 4 + 3] = 2;
}
Regs. h. ah = 0x05; regs. h. ch = trk;
Regs. h. dh = head; regs. h. dl = dsk;
Regs. x. bx = FP_OFF (trktbl); sregs. es = FP_SEG (trktbl );
Int86x (0x13, & regs, & regs, & sregs );
Return (regs. h. ah );
}
II,WindowsEncryption technology for software registration in the system
1. Use the Windows registry to implement software registration Encryption
I believe that most software uses this method to implement the registration function. Windows Registry has a large amount of information, and almost all Windows and computer system configuration information is stored in the registry. If the software key is written into the registry, searching for the key storage location is tantamount to a haidilao fishing needle. Without certain technologies (such as thread tracking), the key cannot be obtained.
The Windows Registry has six primary keys: HKEY_CLASS_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_CONFIG, and HKEY_DYN_DATA. Each primary key is divided into several sub-keys. You can create a new sub-key and item under each sub-key. The entire registry is structured in a tree. Each item has a name and value. The value can be binary, decimal, hexadecimal, or string type.
It is quite easy to use a program to implement registry operations. The following Delphi program section is used to create a sub-key named Arcobet under the sub-Key Software of HKEY_CURRENT_USER, and write the string "ChenQingyang" into the string.
UnitUnit1;
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Registry, StdCtrls;
Type
TForm1 =Class(TForm)
Button1: TButton;
ProcedureButton1Click (Sender: TObject );
Private
{Private declarations}
Public
{Public declarations}
End;
Var
Form1: TForm1;
Implementation
{$ R *. dfm}
ProcedureTForm1.Button1Click (Sender: TObject );
VarRegs: TRegistry;
Begin
Regs: = TRegistry. Create;
Regs. RootKey: = HKEY_CURRENT_USER;
If(NotRegs. OpenKey ('Software "Arcobet ', False ))Then
Regs. CreateKey ('Software "Arcobet ');
Regs. WriteString ('username', 'chenqingyang ');
Regs. CloseKey;
Regs. Destroy;
End;
End.
2. Special magnetic channels in Windows
The basic principle of this method is the same as that of the special magnetic method in DOS, but it must be noted that INT 13 H is directly used in 32bit Application. A protective error dialog box is displayed in Windows, prohibit program execution.
The basic solution to this problem is to use the Virtual Device Driver "VWIN32.VxD", which is implemented through DeviceIoControl, it can complete various functions of INT 13 H, INT 25 H, and INT 26H. Open VWIN32.VxD through CreateFile and obtain the control handle, and then execute various control commands. The format of VWIN32.VxD is as follows:
HANDLE hDevice = CreateFile ("." "VWIN32", GENERIC_WRITE | GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL );
After all the operations are completed, use CloseHandle (hDevice) to disable the opened VWIN32.VxD.
How to use this method to read and write disks is not discussed here. Please refer to the relevant literature.
Iii. Introduction to online registration of Shared Software
With the development of Internet, shared software also emerged. Shared software allows users to try the software and purchase the software through Internet registration. One of the biggest advantages of shared software is its usability. Through the free trial, users can timely feedback the use results to the software author, the author can improve the structure and function of the software based on the feedback. It can be said that shared software provides users and authors with a wider space for communication. On the other hand, the software purchase has also become simpler, greatly reducing the turnover period of the software in the market and making the software version update faster.
After being used by users for a period of time, many excellent software such as "Windows optimization master" will require users to register before they can continue to use it. At this time, the user should fill in the user name according to the interface prompt, the program will automatically generate a serial number, as long as the serial number and the registration fee are mailed to the software author, you can get the registration code, finally, enter the registration code in the specified position of the software and confirm it. Then, the shared software registration process is complete.
To facilitate user registration, many shared software websites have proxy registration services, which serves as a bridge between users and authors, helping both parties conveniently complete the registration process. Users only need to pay the serial number and registration fee to the website. The website regularly transfers the user name list, serial number, and registration fee to the author, based on the information sent by the website, the author generates the registration code for each user and sends it back to the website. The website then delivers the obtained registration code to each user.
Conclusion
There are still many methods to register software encryption, such as CRC error verification, weak location, hard disk lock, software dog, and hardware dog encryption, it is not described here. In short, as long as we can make good use of the program resources and interfaces provided by the operating system, we can use these interfaces and features to design a good registration encryption method. If you are interested, you can follow the methods described in this article or refer to other documents for a try. I believe this will bring you more benefits.
References
1. Sun Zhaolin, editor-in-chief of Software Encryption and computer security technology, China Water Conservancy press September 2001
2. Reference Manual for DOS programmers Terry Dettmann published by Tsinghua University Press January 1996
3. For Win9X system additional track anti-Replication Technology Liu xingping (computer programming skills and maintenance) 2000-5)
4. "Windows Registry completely proficient" Computer Enthusiast magazine May 2001
5. encryption and decryption methods and examples e-Age Technology & Development Beijing tengtu electronics Publishing House
6. "Deep DOS programming": 1993
7. Microsoft Software Developer Network (MSDN) Microsoft Press, July 2001
8. Jiang Tian, "using mutex disk lock to protect Disk Data" (computer programming skills and maintenance 2000-10)
9. DOS6.22 Kernel Analysis and Memory Management Technology Xiao Jinxiu published by China Land press in January 1998
10. CSDN Website: http://www.csdn.net/
11, DDCOPY: Hard Disk Full copy software: http://ddcopy.yeah.net/