JavaScript code character escaping

发布于 2023-07-09  21 次阅读

previous article:Splitting JavaScript code instructions

Following instruction decomposition, all variables and attributes, including 'document', have been converted into string constants. These constants, along with existing string constants within the code, appear as parameters for the loading instructions in the current intermediate code. However, due to the difficulty of converting these string constant parameters into bytecode format, they cannot be virtually mapped and ultimately encoded into bytecode storage during the subsequent protection process. Therefore, a new approach for parameter loading needs to be explored.

In traditional binary programs, the parameters of instructions, except for immediate values, are stored in specific memory units and retrieved through corresponding addressing modes. In reference to this process, this article proposes a design where all string constants within the instructions are extracted and stored separately in a string array called 'VMA[]' before mapping the intermediate code to virtual instructions. The original positions of the string constants are replaced with their corresponding array elements 'VMA[i]', resulting in the code form shown in the third module of Figure 8. This introduces a character transfer process, generating a new intermediate code and a string array. The string array serves as a storage space, with array indices corresponding to special addressing modes. By designing a corresponding virtual instruction, this operation can be simulated. Additionally, since all information such as attribute names is transferred to the array, the string array becomes a crucial data element, along with the bytecode program obtained through final encoding, and is saved in the virtual interpreter to restore code functionality during interpretive execution.

点击体验一键VMP加密 |下滑查看JSVMP相关文章