How to Use CMOS encryption software to prevent illegal copying

Source: Internet
Author: User

How to Use CMOS encryption software to prevent illegal copying
We often encounter the following situations when running software. Some software cannot be copied to other machines after being installed on one machine; some software cannot even run again after the software or hardware configuration of the original machine is changed. In fact, some of these situations are implemented through software encryption using cmos. When installing the software, install the software on the hard disk through the installer, and save the CMOS information of the current machine to the installation floppy disk, which is equivalent to saving the key. When the software is run on the hard disk in the future, the main program of the software will compare the key recorded on the installation disk with the CMOS information of the machine running the software. If the key is exactly the same, the software is allowed to continue to run; otherwise, the software is terminated. Many software in China adopt this principle for encryption.
Because CMOS is more concealed than a disk and inaccessible under normal DOS, using cmos to encrypt software is a way to prevent unauthorized copying of software. The following describes how to use the C language to encrypt the software to prevent illegal copying.

I. CMOS Data Format
CMOS, short for complementary metal oxide semiconductors, is intended to refer to a technology used to manufacture large-scale integrated circuit chips or chips manufactured using this technology. It refers to a read/write RAM chip on the computer motherboard. It is powered by system power supply and backup battery, and the content will not be lost after the system power is down. It stores the basic information about the hardware and software configurations of the machine, totaling 128 bytes. The System reads CMOS information during power-on boot to initialize the status of each part of the machine.

Ii. Encryption principles
If you want to restrict the software to run only on a fixed machine, you can read the content in the current machine CMOS during software installation and save it as a key to the installation disk as a file. When the software is running, it automatically checks whether the content in the CMOS of the currently running program machine is the same as that saved on the installation disk. If the check result is incorrect, it indicates that it is not the machine where the software was originally installed. If the software is not installed on the hard disk, It is illegally copied and the software must be terminated, thus, encryption software can prevent illegal copying.
Among the 128 bytes in CMOS, the data in the 00h-0fh is too random to act as a key. 1bh ~ 2dh, 34h ~ 3fh, 40 h ~ 7fh is the reserved unit of CMOS. Different BIOS versions have different settings for this retention unit. According to the author's observation, the ast series of original installation BIOS fills the data of this unit with 0. The Compaq series are installed in the original server and machines using BIOS such as award and AMI fill in different data for this unit. The 2EH and 2fh units are stored for 10 h ~ The checksum of each byte in the 2dh unit. The system must read the CMOS information during each boot and check for 10 h ~ Whether the checksum of each byte in the 2dh unit is the same as that in the 2EH and 2fh units. Otherwise, the data in the CMOS unit is incorrect. It is not recommended to use as a key because retention unit is involved. 30h ~ The unit content of 33h cannot distinguish machines with different configurations.
Only 10 h ~ of CMOS ~ The 2dh unit involves basic hardware configurations such as floppy disk, hard disk, memory, and display card. In actual applications, machines with identical software and hardware configurations almost do not exist. Therefore, you can use the content in CMOS as the key to check the software and prevent unauthorized copying of the software.

Iii. Implementation Method
In computer systems, Data Reading and Writing in CMOS is achieved through two I/O ports, in which port 70 H is a single byte write-only port, it is used to set the data address in CMOS, and the port h is used to read and write the data unit bytes in the CMOS address set for the port 70 h. Therefore, when reading and writing CMOS Data, you can write an address value through port 70 h, and then read a data through port h. The software encryption is implemented through this.
In the process of using the CMOS encryption software, two procedures are generally required: the function of a program is to save the CMOS content as the key in the installation program; the function of another program is to check whether the key exists and is correct in the software master program, and call this program every time the software runs.
The key check method used in this article is "checksum ". The so-called checksum method is to calculate the sum of all or part of the information and store the key on the installation disk. When the software is running, a sum is calculated for the information part to be checked, and the two are compared to ensure consistency, the operation can be correctly executed. Once inconsistency is found, some processing can be done to terminate the software operation. Because the configuration of a machine changes, the checksum will inevitably change.
Program 1: convert 10 h ~ in CMOS ~ The data checksum in the 2dh unit is written as the key to a file on the installation floppy disk. This program is embedded into the software installer.
/* Jm1.c */
# Include "stdio. H"
Main ()
{
Unsigned int I, csum = 0;
File * FP;
For (I = 0x10; I <= 0x2d; I ++)/* obtain the CMOS checksum of the installer machine */
{
Outportb (0x70, I );
Csum + = inportb (0x71 );
}
If (FP = fopen ("A:/Mima. dat", "WB") = NULL)/* Open the key file */
{Printf ("Enable write protection/07 ");
Exit (0 );
}
Fwrite (& csum, 2, 1, FP );
Fclose (FP );
}
Running result: a file named Mima. dat is generated on disk A, which records the key generated during installation of the program.
Procedure 2: Check 10 h ~ in current machine CMOS ~ Whether the checksum in the 2dh unit is the same as the key stored on the mounted floppy disk. This program is embedded into the main program of the software.
/* Jm2.c */
# Include "stdio. H"
Main ()
{
Unsigned int I, csum = 0;
Unsigned int fsum;
File * FP;
For (I = 0x10; I <= 0x2d; I ++)
{
Outportb (0x70, I );
Csum + = inportb (0x71);/* calculate the checksum in the CMOS of the running program machine */
}
If (FP = fopen ("A:/Mima. dat", "rb") = NULL)
{Printf ("Please insert a key disk ");
Exit (0);/* If the installation disk does not exist, terminate the Program */
}
Fread (& fsum, 2, 1, FP );
If (fsum! = Csum)/* compare the checksum and key of the current machine CMOS */
{Printf ("You are not a legal user. Please purchase genuine software! /07 ");
Exit (0);/* terminate the running of the program, which can be further processed */
}
Else
{Printf ("You are a legal user. Welcome! ");
}
Fclose (FP);/* continue to run the main program */
}
Running result: If the software is installed on the machine through the installer, the system prompts "you are a legal user. welcome to use it !", Continue to run the program. If the software is illegally copied to the machine, the alert will prompt "you are not a legal user. Please purchase genuine software !", And terminate the running of the program.
(Jm1.c and jm2.c are written in tubro C v2.0 and are linked to generate the EXE file. They are debugged in UCDOS 6.0 .)

Iv. Conclusion
Finally, it should be noted that the implementation methods of Software encryption using cmos are different. In actual application, the simplicity and complexity should be determined based on the actual situation. The following factors may be taken into account:
1. Difficulty of the CMOS key. The more CMOS Data is checked, the stricter the machine's software and hardware configuration check.
2. CMOS key check method. If you can perform the most accurate byte-based check.
3 .~ CMOS key storage method. If files are stored on the disk, they may be easily cracked. You can consider storing them to the hidden sector of the floppy disk, such as the Boot Sector, directory area, and file allocation table area; or the hidden sectors stored in the hard disk, such as the Master Boot Record and partition table. At the same time, you need to read the installation disk each time you start the disk, or save it to the retention unit of CMOS. These methods increase the difficulty of deciphering CMOS keys and improve the reliability of Software encryption.
4. in combination with the fingerprint technology on the mounting disk, the extra magnetic channels and special sectors are formatted using int13h, And the CMOS key is saved to the special sectors of the extra magnetic channels. This greatly enhances the anti-copy capability of the mounting disk, further Software encryption.

Table 1 CMOS Data Format
Address description
00 H seconds 10 h floppy disk drive type
01 H seconds alarm 11 h retained
02 h score 12 h hard drive type
03 h score alarm 13 H retained
04 H hour 14 h device byte
05 h hour alert 15 ~ 16 h basic memory capacity, in K
06 h the number of weeks 17 ~ 18 h memory capacity expansion, in K
07 h date 19 h hard drive 0 Type
1ah hard drive type 1 in the month of 08 h
09 h Year 1B ~ 2dh retention
0ah a register status 2E ~ 2fh 10-2dh checksum
0bh B register status 30 ~ 31 h memory capacity expansion, in K
0ch C register status 32 h BCD code century Value
0dh D register status 33 H information flag
0eh diagnostic status byte 34 ~ 3fh Reserved
0fh shutdown status byte 40 ~ 7fh retention

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.