1 Dynamic decoding of the program
Dynamic decoding is to dynamically restore the instructions or data codes of the encrypted program. When the program is running, there is a section of instructions that is specifically used to decrypt the instructions or data codes of a certain area, and when the decrypted code is used up, it must be re-encrypted so that there is no complete program code in the memory. This method is very effective for static analysis of anti-programs, because it is difficult to see the true face of the program from the list of encrypted programs. However, dynamic decoding has its own unique features in terms of anti-tracing of programs. In terms of preventing debugging and tracing with breakpoints, since the program appears in ciphertext before execution, it is difficult for the decryptor to determine the location of the breakpoint setting. If one is not careful, the decryption failure will cause system damage (electrically erasing data in EPROM). The following is a specific example of program dynamic decoding:
...
SUB1: ADD A,#94H; virtual program segment
XRL 54H,#13H
...
MOV R0,#20H
MOV R1,#5
MOV R2,#55H
MOV DPTR,#SUB1
MOV A,#00H
LOOP1: PUSH A
MOVC A,@A+DPTR
XRL A,R2; XOR operation
MOV @R0,A; store actual data
POP A
INC A
INC R0
DJNZ R1,LOOP1
...
This program dynamically transforms the data group (there are 5) starting from RAM address 20H. Because the initial data group is in password form, it needs to be changed during program execution, and the changed data must be used in other segments of the program. Here, the instruction code in the SUB1 program segment (codes: 24H, 94H, 63H, 54H, 13H) is used to dynamically decode with 55H. Data 55H is encrypted data. After "XORing" the instruction code, the correct data is stored in the unit starting from 20H (the result is: 71H, C1H, 36H, 01H, 46H). In order to illustrate the dynamic data decoding process, this example is relatively simple. In fact, when entering this program segment, the data unit address can be generated by certain operations to enhance the program's anti-analysis ability.
2 Program segment modification prevention
In the encryption program, there will not be only one obstacle set. In order to make the encryption measures perfect, the echo of the program before and after in some key places is an effective method for anti-decryption. For some purposes, the decryptor must modify a certain section of program instructions; and program segment modification prevention is a technical means used for this decryption method. In order to achieve the integrity of the encrypted program, instructions or data codes can be taken at the key points of the program to participate in a certain operation, and the result is used as the basis for judging whether the program has been changed. The following is a program segment to prevent modification:
……
SUB2: ADD A,#35H
SUBB A,#05H
……
MOV DPTR,#SUB2
MOV R0,#30H
MOV A,#1
MOV R1,#3
MOV @R0,#24H ;The first instruction code of SUB2 segment is 24H
LOOP2: PUSH A
MOVC A,@A+DPTR
XRL 30H,A ;XOR operation
POP A
INC A
DJNZ R1,LOOP2
MOV A,30H
……
CJNE A,#80H,ERR ;The result is compared with 80H
……
ERR: MOV A,#0 ;Error exit
……
In the SUB2 program segment, some data are calculated through instructions, such as the charging algorithm, etc. The decryptor always has to modify some instructions to achieve a certain purpose. However, the decryption work is in the following LOOP2 program segment, which uses the instruction bytes (here 4 bytes are used) in the SUB2 program segment for calculation (here "XOR" calculation), and its result will directly affect the correct execution of the following program (the correct calculation result is 80H). If the SUB2 program segment is changed, the program will be led astray in the LOOP2 program segment, and will be lost unknowingly. If there is an electrically erasable EEPROM in the hardware design, the data in the program can be further modified (or deleted), so that the tracker can cause "damage" to the device and cannot re-analyze the program.
The microcontroller encryption method introduced above is to prevent the decryptor from illegally obtaining the program in the ROM or to prevent the program in the ROM from running in the copied microcontroller system. In practical applications, there are many ways to judge whether the program is running normally or being tracked. For example, the running time of a certain program segment can be determined based on the clock timing, so as to make different responses, because there is a big difference in time between single-step and continuous operation. In addition, the encryption of the MCU cannot be limited to one of the above methods, and the anti-tracking method cannot be single. Several methods must be used together to achieve good results. For example, software encryption can be combined with hardware encryption, dynamic decoding can be combined with program anti-modification, etc., and new technologies and methods (such as programmable logic devices, etc.) can be fully utilized to make the encryption protection of the MCU more effective.
Previous article:Rapid Implementation of Removing Power Frequency Interference in Single Chip Microcomputer Application System
Next article:Discussion on the stability of multi-computer communication system based on single chip microcomputer
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- Help! CCS7.3 enters the exit.c file after entering debug mode. I don't know how to solve it
- [RVB2601 creative application development] 2. CH2601 serial port receiving
- A summary of the most downloaded electronic technical materials this week (2020.5.1~9), each one is a classic
- [i.MX6UL development problem] How to use tftp to burn program in uboot
- FPGA image processing algorithm.zip
- How to Reduce EMI in Switching Power Supply Circuits
- [GD32L233C-START Evaluation] 16. RT-Thread event set wakes up tasks from interrupts
- Good news! If you buy Wuzhi openmv3 now, you can also participate in cashback + lucky draw! Come and join the openmv army!
- EEWORLD University Hall - Comic Illustrations of Deep Learning
- Xinxin is waiting for you to create the world