When we run the software, we often encounter the following situations. Some software cannot copy it to other machines after installation; some software even even running again after the machine's soft and hardware configuration changes. . In fact, these situations are implemented using CMOS to encrypt software encryption. When installing the software, install the software to the hard disk through the installer, and save the CMOS information of the current machine to the installation floppy disk, that is, the key is saved. When you run the software on the hard disk, the main program of the software will compare the key recorded on the installation disc with the CMOS information that is running the software machine. If it is exactly the same, the software is allowed to run, otherwise the software is running . Many of the domestic software is encrypted using this principle. Since the CMOS has better concealment than the disk and the irrevacity under normal DOS, the software is encrypted using CMOS to prevent software illegal copying. The following will provide a focus on encrypting software to prevent illegal copying of the software by CMOS.
First, CMOS data format CMOS is an abbreviation of complementary metal oxide semiconductors, which is intended to manufacture a technique for manufacturing a large scale integrated circuit chip or a chip made in this technique. Here is a readable writable RAM chip on the computer motherboard. It relies on the system power supply and the backup battery, and the content will not be lost after the system is powered down. It stores the basic information of the machine soft and hardware configuration, with a total of 128 bytes. The system is read when the system is booted to initialize the state of each component.
Second, the encryption principle If you want to limit the software to run on a fixed machine, you can read the contents of the current machine CMOS when the software is installed, and saved as the key to the mounting disk. Automatically check if the content of the CMOS currently running the program machine is the same as the key saved on the installation disc. If the check results are incorrect, it is proved that the machine that is not originally installed. The software is not installed to the hard disk. It is illegal copy, and the software must be terminated to achieve encryption software to prevent illegal copies. In the 128 byte unit of CMOS, the data in the 00h-0fh byte unit is too strong, it is not easy to be used as a key. 1BH ~ 2DH, 34H ~ 3FH, 40H ~ 7FH are CMOS reserved units. Different BIOS versions are different for this reserved unit. According to the author's observation, the AST series original machine BIOS fills the data to 0. The COMPAQ series of original machines and BIOS using Award, AMI are filled with different data on this unit. 2Eh, 2FH units are stored in each byte of the bytes in the 10h ~ 2DH unit. Each time the system is guided to read the CMOS information, it is also possible to check whether the checksum of each byte in the 10H ~ 2DH cell is the same as the data in the 2Eh, 2FH unit, and the data in the CMOS is wrong. Due to the retention unit, it is not recommended as a key. 30H ~ 33H unit content cannot distinguish between different configurations, you can use it without consideration. Only the contents of the CMOS 10h ~ 2DH cells involve the most basic hardware configurations such as floppy disk, hard disk, memory, and display cards. In practical applications, the hardware configuration is almost absent, so it can be checked as a key in CMOS, which can be used as a key to prevent illegal copy of the software.
Third, implementation method In the computer system, read and write to data in CMOS is implemented by two I / O ports, where port 70h is a only-write port, with it to set data address in CMOS. The port 71h is the data unit byte content in the CMOS address set to the port 70h. So when reading and writing CMOS data, an address value can be written through the 70H port, and then read a data through the 71H port, and the encryption of the software is implemented by this. In the process of using CMOS encryption software, it is generally necessary to prepare two programs: a program functionality to save CMOS content as a key in the installer; the function of another program is to detect the key in the software main program, and correct This program is called when running the software each time. The key inspection method used in this paper is "check and method". The so-called verification method is to calculate a accumulation and a key to all information or partial information, and store it on the mounting disc. When the software is running again, it is calculated to compare a accumulation and comparison, and the two can be executed correctly. Once the inconsistency is found, it can be treated, and the software is terminated. Because a machine configuration changes, checksum inevitably changes. Procedure 1: Write the checksum of the data in the CMOS to 2DH units into a file on the installation floppy disk. This program is embedded in the software installer during use. / *Jm1.c*/#clude"stdio.h"main() kettle * fp; for (i = 0x10; i <= 0x2d; i ) / * Search installer machine CMOS in CMOS and * / {OUTPORTB (0x70, i); CSUM = InportB (0x71);} IF ((fp = fopen ("a: /mima.dat", "wb")) == null) / * Open the key file * / {Printf ("Please open write protection / 07"); exit (0);} fwrite (& CSUM, 2, 1, fp); fclose (fp);} Run: on a disk Generate a file called mima.dat, which records the key generated when the program is installed. Program 2: Check whether the checks in the current machine CMOS 10h ~ 2DH unit is the same as the key saved on the installation floppy disk. This program is embedded in the main program of the software during use.
/ *Jm2.c*/#clude"stdio.h"main() ket; unsigned int fsum; file * fp; for (i = 0x10; i <= 0x2d; i ) {OUTPORTB ( 0x70, i); CSUM = inportb (0x71); / * Since the checksum * /} IF in the CMOS of the program machine ((fp = fopen ("A: /MIMA.DAT", "RB"))))))) == NULL) {Printf ("Please insert key disc"); exit (0); / * Installation disk does not exist, terminate the program running * /} FREAD (& fsum, 2, 1, fp); if (fsum! = CSUM ) / * Compare the current machine CMOS to compare * / {printf ("You are not a legal user, please purchase genuine software! / 07"); exit (0); / * Terminate the operation, Can be further processed * /} else {printf ("You are legal users, welcome!");} Fclose (fp); / * Continue to run the main program * /} Run: If the software is installed through the installer to the machine On, prompt "You are a legal user, welcome!", Continue to run the program; if the software is on the machine, the alarm tips "You are not a legitimate user, please purchase genuine software!", And Terminate the operation of the program. (Where JM1.C, JM2.C is written in Tubro C v2.0, link to generate an EXE file, debugging under UCDOS 6.0.) Finally, the ending needs to be explained, using CMOS to perform software encryption implementation method, In practical applications, it is necessary to determine simplicity and complex according to the specific situation. It is usually considered to consider the following factors: 1. Evolution of the CMOS key. The more CMOS data is checked, the more strict on the soft and hardware configuration checks for the machine. 2.CMOS key check method. If you can do one-byte check is the most accurate. 3. ~ CMOS Key Save Method. If you are stored on a file in the form of a file, it is possible to easily discovery. It can be considered to save the implicit sector saved to the floppy disk, such as guiding sectors, directory area, file allocation table, etc., or save to the hidden sector of the hard disk, If the main boot record, partition table, etc., the installation disk is needed to be started each time; or save it to the reserved unit of CMOS. These methods can increase the decimal difficulty of the CMOS key, improve the reliability of software encryption. 4. Combined with fingerprint technology on the mounting disc, use INT13H to format additional tracks and special sectors, save the CMOS key to the special sector of the additional track, can greatly enhance the copying ability of the mounting disk, and further Software encryption.