Method and device for rewriting environment variables in terminal, equipment and storage medium
The location of environment variables is determined and replaced in the firmware BIOS through the SMI service program, which solves the problem of complex and easy vulnerability modification in the prior art, and achieves more efficient and secure environmental variable modification.
Patent Information
- Application Number
- CN202311283131.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2025-03-28
AI Technical Summary
When modifying environment variables in computers, the prior art needs to operate under the firmware BIOS or operating system, resulting in complex modifications and easy introduction of operational vulnerabilities and inefficient.
The SMI service program determines the environment variable to be modified in the firmware BIOS, records its location number, obtains the replaced target environment variable, and uses the SMI service program to replace the environment variable to be modified with the target environment variable according to the location number.
The modification process of environment variables is simplified, the complexity of user operations is reduced, unnecessary modification of the original code is avoided, and the risk of running vulnerabilities is reduced, thereby improving the modification efficiency of environment variables.
Smart Images

Figure CN119720208A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for rewriting environment variables in a terminal. Background Art
[0002] Environment variables can transfer information between computer systems, software or processes. When installing some software, users are required to configure and change the environment so that the software can be used normally.
[0003] Currently, the modification of computer environment variables requires entering the firmware BIOS (Basic Input / Output System) operation interface during the computer startup phase, or using the firmware BIOS original manufacturer's professional tools to modify it under the computer's operating system. However, no matter which existing method is used to modify the environment variables, it may involve modifying the original code, making the modification of the environment variables complicated, and easily causing the original code to have operating vulnerabilities, resulting in low efficiency in modifying the environment variables. Summary of the invention
[0004] The main purpose of this application is to provide a method, device, equipment and storage medium for rewriting environment variables in a terminal, aiming to solve the technical problem that the prior art may involve modification of the original code, resulting in complicated modification operations of the environment variables and easily causing operation vulnerabilities in the original code, resulting in low efficiency in modifying the environment variables.
[0005] To achieve the above object, the present application provides a method for rewriting environment variables in a terminal, the method for rewriting environment variables in the terminal comprising:
[0006] Determine the environment variable to be modified in the firmware BIOS based on the SMI service program, and record the position number of the environment variable to be modified;
[0007] Obtaining a target environment variable required to replace the environment variable to be modified;
[0008] Based on the SMI service program, the environment variable to be modified is replaced with the target environment variable according to the position number.
[0009] Optionally, the step of determining the environment variable to be modified in the firmware BIOS based on the SMI service program and recording the position number of the environment variable to be modified includes:
[0010] Get the environment variables in the firmware BIOS based on the SMI service program;
[0011] Determine the environment variables to be modified from the environment variables;
[0012] The location number of the to-be-modified environment variable is recorded in the SMI port of the SMI service program.
[0013] Optionally, the step of obtaining environment variables in the firmware BIOS based on the SMI service program includes:
[0014] When the operating system is running, the environment variables in the firmware BIOS are obtained based on the SMI service program.
[0015] Optionally, the step of obtaining environment variables in the firmware BIOS based on the SMI service program when the operating system is running includes:
[0016] When the operating system is running, the original code carrying the environment variables in the firmware BIOS is called through the SMI service program, and the environment variables are marked from the original code.
[0017] Optionally, before the step of replacing the to-be-modified environment variable with the target environment variable according to the position number based on the SMI service program, the step further includes:
[0018] Simulate running the program code to be tested after the target environment variable is replaced with the environment variable to be modified;
[0019] Detecting whether a target software corresponding to the program code to be tested reports an error when the program code to be tested is run;
[0020] If the target software does not report an error, the step of replacing the environment variable to be modified with the target environment variable according to the position number based on the SMI service program is executed.
[0021] Optionally, after the step of detecting whether the target software corresponding to the program code to be tested reports an error when the program code to be tested is run, the method further includes:
[0022] If the target software reports an error, detecting whether the program code to be tested has an operation vulnerability;
[0023] If there is an operational vulnerability, then compare whether the part of the program to be tested other than the target environment variable is modified by mistake;
[0024] If it is not modified by mistake or it is detected that the program to be tested does not have any running vulnerability, a prompt message of the target environment variable error is generated.
[0025] Optionally, the step of obtaining a target environment variable required to replace the environment variable to be modified includes:
[0026] Based on the SMI service program, generating a modification interface for the environment variable to be modified;
[0027] Based on the modification interface, a target environment variable required to replace the environment variable to be modified is obtained.
[0028] In addition, to achieve the above purpose, the present application also provides a device for rewriting environment variables in a terminal, and the device for rewriting environment variables in a terminal includes:
[0029] A recording module, used for determining the environment variables to be modified in the firmware BIOS based on the SMI service program, and recording the position numbers of the environment variables to be modified;
[0030] An acquisition module, used for acquiring a target environment variable required to replace the environment variable to be modified;
[0031] A replacement module is used to replace the to-be-modified environment variable with the target environment variable according to the position number based on the SMI service program.
[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a device for rewriting environment variables in a terminal, the device comprising: a memory, a processor, and a rewriting program for the environment variables in the terminal stored in the memory and executable on the processor, the rewriting program for the environment variables in the terminal being configured to implement the steps of the method for rewriting environment variables in the terminal as described above.
[0033] In addition, to achieve the above objectives, the present application also proposes a storage medium, on which a program for rewriting environment variables in a terminal is stored. When the program for rewriting environment variables in the terminal is executed by a processor, the steps of the method for rewriting environment variables in the terminal as described above are implemented.
[0034] The present application provides a method, device, equipment and storage medium for rewriting environment variables in a terminal. Compared with the prior art, which may involve modification of the original code, resulting in complicated modification operations of the environment variables, and easily causing the original code to have running vulnerabilities, resulting in low efficiency of modifying the environment variables, in the present application, the environment variables to be modified in the firmware BIOS are determined based on the SMI service program, and the position number of the environment variables to be modified is recorded; the target environment variable required to replace the environment variable to be modified is obtained; based on the SMI service program, the environment variable to be modified is replaced with the target environment variable according to the position number. In the present application, the SMI service program is used to replace the original environment variable to be modified with the acquired target environment variable according to the position number, wherein the position number is the position number of the environment variable to be modified in the firmware BIOS, and the user does not need to manually modify the environment variable to be modified, which can reduce the user's operation and reduce the complexity of modifying the variable to be modified. In addition, the use of the SMI service program to modify the environment variable to be modified is to replace the environment variable to be modified with the target environment variable, which will not cause the risk of modification to the original code, thereby reducing the generation of running vulnerabilities after modification, and thus improving the efficiency of modifying the environment variable. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0037] Figure 1 A schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application;
[0038] Figure 2 This is a flow chart of the first embodiment of the method for rewriting environment variables in the terminal of the present application;
[0039] Figure 3 A schematic diagram of a specific implementation flow of the method for rewriting environment variables in the terminal of this application;
[0040] Figure 4 This is a flow chart of a second embodiment of a method for rewriting environment variables in a terminal of the present application;
[0041] Figure 5 This is a flow chart of a third embodiment of a method for rewriting environment variables in a terminal of the present application;
[0042] Figure 6 This is a schematic diagram of the structural configuration of the device for rewriting environment variables in the terminal of this application.
[0043] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0044] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0045] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a device for rewriting environment variables in a terminal of a hardware operating environment involved in an embodiment of the present application.
[0046] like Figure 1 As shown, the rewriting device of the environment variables in the terminal may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0047] Those skilled in the art will understand that Figure 1 The structure shown in does not constitute a limitation on the device for rewriting environment variables in the terminal, and may include more or less components than those shown in the figure, or combine certain components, or arrange the components differently.
[0048] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module, and a rewriting program for environment variables in the terminal.
[0049] exist Figure 1In the device for rewriting environment variables in the terminal shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the device for rewriting environment variables in the terminal of the present application can be set in the device for rewriting environment variables in the terminal, and the device for rewriting environment variables in the terminal calls the rewriting program of the environment variables in the terminal stored in the memory 1005 through the processor 1001, and executes the rewriting method of the environment variables in the terminal provided in the embodiment of the present application.
[0050] The present application embodiment provides a method for rewriting environment variables in a terminal, referring to Figure 2 , Figure 2 This is a flow chart of a first embodiment of a method for rewriting environment variables in a terminal according to the present application.
[0051] It should be noted that the executor of this embodiment may be a device for rewriting the environment variables in the terminal. The device for rewriting the environment variables in the terminal may be an electronic device such as a personal computer, a smart phone, a tablet computer, or other devices that can achieve the same or similar functions. This embodiment does not limit this. In this embodiment and the following embodiments, the method for rewriting the environment variables in the terminal of this application is described by taking the device for rewriting the environment variables in the terminal as an example.
[0052] In this embodiment, the method for rewriting environment variables in the terminal includes:
[0053] Step S10, determining the environment variables to be modified in the firmware BIOS based on the SMI service program, and recording the position numbers of the environment variables to be modified.
[0054] Among them, the firmware BIOS (Basic Input Output System) contains the initialization program that needs to be run when the computer is turned on; SMI is the System Management Interface.
[0055] It should be noted that the SMI service program can be used to obtain the environment variables in the firmware BIOS, and set the environment variables to be selectable or modifiable, and set the original code of non-environment variables in the firmware BIOS to be non-selectable or non-modifiable, so as to avoid the user selecting the original code when selecting the environment variables to be modified, causing the original code to have an operational vulnerability.
[0056] The original code may be the code in the firmware BIOS except the environment variable part.
[0057] The environment variables may be some parameters used in the operating system to specify the operating environment of the operating system, such as the location of a temporary folder and the location of a system folder, etc., and are not specifically limited.
[0058] It should be noted that in order to determine the environment variables to be modified that the user selects from the fixed BIOS environment variables through the SMI service program, in order not to affect the normal use of the software corresponding to the environment variables when modifying the environment variables, it is necessary to record the position numbers that can represent the environment variables to be modified, where each environment variable corresponds to a position number, and the environment variables to be modified can be determined according to the position number, thereby avoiding modification of the original code.
[0059] In a specific implementation, the SMI service program can be used to read the code of the variables that need to be modified in the firmware BIOS, distinguish the environment variables from the original code from the code, set the environment to be modified to a modifiable mode or a separately selectable mode, set the original code to a non-modifiable mode or a non-single-selectable mode, and display the code to the user through the SMI software corresponding to the SMI service program to determine the environment variable to be modified selected by the user from the code, and record the position number of the environment variable to be modified to obtain the corresponding target environment variable according to the position number.
[0060] Step S20, obtaining the target environment variable required to replace the environment variable to be modified.
[0061] The target environment variable may be some parameters of the operating system running environment that need to be modified. For example, when a certain software is running, the folder location of the system needs to be read and needs to be modified. The folder location is the target environment variable.
[0062] It should be noted that the target environment variables can be obtained from the variable data uploaded by the user through the SMI software, so that the user uploads the target environment variables and after triggering the SMI software, the environment variables to be modified can be modified according to the number in the variable data and the recorded location number. The user does not need to perform other operations, which simplifies the user's operation steps when modifying the environment variables, thereby saving modification time and improving the modification efficiency of the environment variables.
[0063] Optionally, the way to obtain the target environment variable can also be to first obtain the user's purpose of modifying the variable to be modified, and then filter the target environment variable from the environment variable database according to the purpose and the recorded location number, and then replace the environment variable after receiving the user's confirmation information; if the target environment variable filtered from the database does not completely meet the user's needs, the user can also modify the target environment variable to improve the flexibility of modifying the environment variable, reduce the user's operation steps, reduce the user's operation difficulty, and improve the efficiency of modifying the environment variable.
[0064] In a specific implementation, variable data uploaded by the user through the SMI software is obtained. The variable data may include the target environment variables required to replace the environment variables to be modified, and the numbers of the target environment variables corresponding to the position numbers of the environment variables to be modified. After detecting that the user triggers the modify button or the upload confirmation button in the SMI software, the target environment variables corresponding to the number and the position number replace the corresponding environment variables to be modified through the SMI service program.
[0065] Furthermore, the step of obtaining the target environment variable required to replace the environment variable to be modified includes:
[0066] Step S21, generating a modification interface of the environment variable to be modified based on the SMI service program;
[0067] Step S22: based on the modification interface, obtaining the target environment variable required to replace the environment variable to be modified.
[0068] Among them, the modification interface can be an interface required for directly obtaining environment variables. The SMI service software is connected with the environment variables through the modification interface, so that the environment variables can be displayed to the user and can be selected.
[0069] It should be noted that, according to the SMI service program, a modification interface can be provided for undisclosed environment variables, so that undisclosed and disclosed environment variables can be displayed to users in the SMI software through the modification interface, so that users can modify environment variables according to their own needs and will not be restricted by undisclosed environment variables. Among them, undisclosed environment variables can be understood as environment variables that are not marked by the original manufacturer, that is, environment variables that need to be identified by users from the code.
[0070] Step S30: Based on the SMI service program, replace the environment variable to be modified with the target environment variable according to the location number.
[0071] It should be noted that each position number has a corresponding environment variable to be modified, and each position number is different, wherein the position number can be composed of the position of the variable to be modified in the code of the corresponding target software. For example, it can be the line number of the variable to be modified in the code, the byte position of the line, and the number of the target software in the entire operating system. It can also be composed of numbers, letters and / or characters to make each position number unique, and each position number can represent an environment variable to avoid the target environment variable replacing the wrong environment variable to be modified, thereby improving the modification quality of the environment variable and avoiding multiple modifications, thereby improving the modification efficiency of the environment variable.
[0072] In the specific implementation, the SMI service program can provide a modification interface for modifying the environment variables to be modified. After obtaining the target environment variables and detecting that the user has triggered the SMI software, the SMI service program will replace the target environment variables with the corresponding environment variables to be modified according to the position number, and when the firmware BIOS is re-run, it will run using the code after replacing the target environment variables.
[0073] In the specific implementation, refer to Figure 3 , the SMI software is used to record the variable (environment variable) number to be changed into the CPU register AX; the application software triggers the software SMI; the firmware BIOS processes the SMI service program; the SMI service program changes the variable. Among them, the register AX can be understood as an accumulator, which is mainly used to store data, such as operands or results in arithmetic and logical operations. It can also be used temporarily to store addresses, etc.
[0074] This embodiment provides a method for rewriting environment variables in a terminal. Compared with the prior art, which may involve modification of the original code, resulting in complicated modification operations of the environment variables, and easily causing the original code to have running vulnerabilities, resulting in low efficiency of modifying the environment variables, in this application, based on the SMI service program, the environment variables to be modified in the firmware BIOS are determined, and the position number of the environment variables to be modified is recorded; the target environment variables required to replace the environment variables to be modified are obtained; based on the SMI service program, the environment variables to be modified are replaced with the target environment variables according to the position number. In this application, the SMI service program is used to replace the original environment variables to be modified with the acquired target environment variables according to the position number, wherein the position number is the position number of the environment variables to be modified in the firmware BIOS, and the user does not need to manually modify the environment variables to be modified, which can reduce the user's operations and reduce the complexity of modifying the variables to be modified. Moreover, the use of the SMI service program to modify the environment variables to be modified is to replace the environment variables to be modified with the target environment variables, which will not cause the risk of modification to the original code, thereby reducing the generation of running vulnerabilities after modification, and thus improving the efficiency of modifying the environment variables.
[0075] refer to Figure 4 , Figure 4 This is a flow chart of the second embodiment of the method for rewriting environment variables in the terminal of the present application.
[0076] Based on the above embodiment, in this embodiment, in order to not affect the normal use of the application software corresponding to the environment variable to be modified when the variable to be modified is modified, step S10 includes:
[0077] Step S01, obtaining environment variables in the firmware BIOS based on the SMI service program;
[0078] Step S02, determining the environment variables to be modified from the environment variables;
[0079] Step S03, recording the location number of the to-be-modified environment variable to the SMI port of the SMI service program.
[0080] It should be noted that the SMI service program can obtain all environment variables in the firmware BIOS. After the user confirms the software that needs to be modified through the SMI software, the SMI service program can obtain the environment variables of the software and display the environment variables that need to be obtained to the user through the SMI software, so as to avoid displaying environment variables that are not related to the software to the user at one time, thereby reducing the user's workload and avoiding the user from selecting irrelevant environment variables when selecting the environment variables to be modified, causing the remaining software to be unusable.
[0081] For example, if the user needs to modify the environment variables of software A, the user can select the SMI service program through the SMI software to obtain the environment variables related to software A, and display the environment variables to the user through the SMI software, and then determine the environment variables to be modified selected by the user from the environment variables, and record the position number corresponding to the environment variables to be modified.
[0082] In the specific implementation, after determining the software selected by the user, the SMI service program is used to obtain the environment variables of the software in the firmware BIOS, and displayed to the user through the SMI software. Then, the environment variables to be modified selected by the user from the environment variables using the SMI software are determined, and the location number of the environment variable to be modified is recorded in the SMI port of the SMI service program, so that after the user triggers the confirmation replacement button in the SMI software, the environment variables to be modified can be modified instantly.
[0083] Optionally, in order to reduce the difficulty of modifying the environment variables and the complexity of the operation, step S01 includes:
[0084] Step S011, when the operating system is running, obtaining environment variables in the firmware BIOS based on the SMI service program.
[0085] It should be noted that when the operating system starts to start, all the codes in the firmware BIOS will be run first. After the codes in the firmware BIOS are run, the operating system will be officially run. Moreover, since the environment variables that need to be modified are in the firmware BIOS, to modify the environment variables in the firmware BIOS interface, it is necessary to enter the firmware BIOS interface when the operating system starts to start and before it officially runs. That is, the running of the code in the firmware BIOS is forcibly interrupted. Since the code is not easily terminated during the running process, it will make it difficult to enter the firmware BIOS interface. Therefore, when the operating system is running, modifying the environment variables can avoid entering the firmware BIOS interface and reduce the difficulty of modifying the environment variables.
[0086] Furthermore, in order for the user to modify any environment variable according to his / her needs and ignore the impact of the environment variable not being disclosed, step S011 includes:
[0087] Step Sa11, when the operating system is running, the original code carrying the environment variables in the firmware BIOS is retrieved through the SMI service program, and the environment variables are marked from the original code.
[0088] It should be noted that when the operating system is running, the SMI service program can be used to call the original code carrying environment variables to identify the environment variables from the original code. That is, the undisclosed environment variables can be identified through the original code, which avoids errors when users search for environment variables in the original code by themselves, facilitates users to select the environment variables to be modified, reduces the difficulty of user operation, and thereby improves the efficiency of modifying environment variables.
[0089] refer to Figure 5 , Figure 5 This is a flow chart of the third embodiment of the method for rewriting environment variables in a terminal of the present application.
[0090] Based on the above embodiment, in this embodiment, no matter how the target environment variable is obtained, there may be a situation where the target environment variable is not applicable to the target software corresponding to the modified environment variable. In order to avoid repeatedly modifying the environment variable to be modified, before step S30, the following is further included:
[0091] Step S1, simulating running the program code to be tested after the target environment variable is replaced with the environment variable to be modified;
[0092] Step S2, detecting whether the target software corresponding to the program code to be tested reports an error when the program code to be tested is run;
[0093] Step S3, if the target software does not report an error, then executing the step of replacing the environment variable to be modified with the target environment variable according to the position number based on the SMI service program.
[0094] It should be noted that, by simulating the running of the program code to be tested that is replaced with the target environment variables, and by detecting whether the target software corresponding to the program code to be tested reports an error, it is detected whether there are operational vulnerabilities in the program code to be tested. When the target software does not report an error, the environment variables to be modified are replaced with the target environment variables to avoid operational vulnerabilities in the replaced code. Not only is it necessary to find the operational vulnerabilities and modify them, but it may also be necessary to re-replace the target environment variables. Therefore, the modification efficiency of the environment variables is improved.
[0095] In the specific implementation, the process of replacing the environment variables to be modified with the target environment variables is simulated to obtain the program code to be tested, run the program code to be tested, and detect whether the target software corresponding to the program code to be tested will report an error. If no error is reported, the environment variables to be modified will be replaced with the target environment variables; if the target software reports an error, the operation vulnerabilities of the program code to be tested can be detected, and corresponding prompt information can be generated according to the operation vulnerabilities, so that users can make targeted modifications.
[0096] Optionally, in order to improve the accuracy of modifying the environment variable to be modified, after step S2, the following is further included:
[0097] Step S2a, if the target software reports an error, detecting whether the program code to be tested has an operation vulnerability;
[0098] Step S2b, if there is an operation vulnerability, comparing whether the part of the program to be tested except the target environment variable is modified by mistake;
[0099] Step S2c: If the target environment variable has not been modified by mistake or it is detected that the program to be tested does not have any running vulnerability, a prompt message of the target environment variable error is generated.
[0100] It should be noted that, since the target software reports an error because the target environment variable cannot enable the target software to run normally, it may also be because an error occurs when the target environment variable replaces the environment variable to be modified, thereby modifying part of the original code. Therefore, when the target software reports an error, it is possible to detect whether there is an operational vulnerability in the program code to be tested. If there is an operational vulnerability, it means that the part of the program code to be tested that removes the target environment variable cannot run normally, that is, the part is modified by mistake, and a prompt message indicating that the code needs to be corrected can be generated based on the mistakenly modified part; if there is no operational vulnerability in the program code to be tested, it means that the target environment variable cannot enable the target software to run normally, and a prompt message indicating that the target environment variable is unavailable can be generated, so that the user can accurately modify the corresponding part through the prompt message, thereby reducing the number of rework times and improving the efficiency of modifying the environment variables.
[0101] The present application also provides a device for rewriting environment variables in a terminal, referring to Figure 6 , the rewriting device of the environment variables in the terminal includes:
[0102] The recording module 601 is used to determine the environment variables to be modified in the firmware BIOS based on the SMI service program, and record the position number of the environment variables to be modified;
[0103] An acquisition module 602 is used to acquire a target environment variable required to replace the environment variable to be modified;
[0104] The replacement module 603 is used to replace the to-be-modified environment variable with the target environment variable according to the position number based on the SMI service program.
[0105] Optionally, the recording module 601 is further used to obtain environment variables in the firmware BIOS based on the SMI service program; determine the environment variables to be modified from the environment variables; and record the location number of the environment variables to be modified to the SMI port of the SMI service program.
[0106] Optionally, the recording module 601 is further used to obtain environment variables in the firmware BIOS based on the SMI service program when the operating system is running.
[0107] Optionally, the recording module 601 is further used to retrieve the original code carrying the environment variables in the firmware BIOS through the SMI service program when the operating system is running, and mark the environment variables from the original code.
[0108] Optionally, the simulation module 604 is used to simulate the running of the program code to be tested after the target environment variable is replaced with the corresponding environment variable to be modified; detect whether the target software corresponding to the program code to be tested reports an error when running the program code to be tested; if the target software does not report an error, execute the step of replacing the environment variable to be modified with the target environment variable according to the position number based on the SMI service program.
[0109] Optionally, the simulation module 604 is also used to detect whether there is an operational vulnerability in the program code to be tested if the target software reports an error; if there is an operational vulnerability, compare whether the part of the program to be tested other than the target environment variable is mistakenly modified; if it is not mistakenly modified or it is detected that there is no operational vulnerability in the program to be tested, generate a prompt message of the target environment variable error.
[0110] Optionally, the replacement module 603 is further used to generate a modification interface of the environment variable to be modified based on the SMI service program; and obtain a target environment variable required to replace the environment variable to be modified based on the modification interface.
[0111] The specific implementation of the device for rewriting environment variables in the terminal of the present application is basically the same as the embodiments of the method for rewriting environment variables in the terminal described above, and will not be repeated here.
[0112] An embodiment of the present application provides a storage medium, and the storage medium stores one or more programs, and the one or more programs can also be executed by one or more processors to implement the steps of any of the above-mentioned methods for rewriting environment variables in a terminal.
[0113] The specific implementation of the storage medium of the present application is basically the same as the embodiments of the method for rewriting environment variables in the above-mentioned terminal, and will not be repeated here.
[0114] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes an etc." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0115] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0116] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0117] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent mechanism or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly used in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for rewriting environment variables in a terminal, characterized in that: The method for rewriting environment variables in the terminal includes: Determine the environment variable to be modified in the firmware BIOS based on the SMI service program, and record the position number of the environment variable to be modified; Obtaining a target environment variable required to replace the environment variable to be modified; Based on the SMI service program, the environment variable to be modified is replaced with the target environment variable according to the position number.
2. The method for rewriting environment variables in a terminal according to claim 1, characterized in that: The step of determining the environment variable to be modified in the firmware BIOS based on the SMI service program and recording the position number of the environment variable to be modified includes: Get the environment variables in the firmware BIOS based on the SMI service program; Determine the environment variables to be modified from the environment variables; The location number of the to-be-modified environment variable is recorded in the SMI port of the SMI service program.
3. The method for rewriting environment variables in a terminal according to claim 2, characterized in that: The step of obtaining the environment variables in the firmware BIOS based on the SMI service program includes: When the operating system is running, the environment variables in the firmware BIOS are obtained based on the SMI service program.
4. The method for rewriting environment variables in a terminal according to claim 3, characterized in that: The step of obtaining the environment variables in the firmware BIOS based on the SMI service program when the operating system is running includes: When the operating system is running, the original code carrying the environment variables in the firmware BIOS is called through the SMI service program, and the environment variables are marked from the original code.
5. The method for rewriting environment variables in a terminal according to claim 1, characterized in that: Before the step of replacing the to-be-modified environment variable with the target environment variable according to the position number based on the SMI service program, the step further includes: Simulate running the program code to be tested after the target environment variable is replaced with the environment variable to be modified; Detecting whether a target software corresponding to the program code to be tested reports an error when the program code to be tested is run; If the target software does not report an error, the step of replacing the environment variable to be modified with the target environment variable according to the position number based on the SMI service program is executed.
6. The method for rewriting environment variables in a terminal according to claim 5, characterized in that: After the step of detecting whether the target software corresponding to the program code to be tested reports an error when the program code to be tested is run, the method further includes: If the target software reports an error, detecting whether the program code to be tested has an operation vulnerability; If there is an operational vulnerability, then compare whether the part of the program to be tested other than the target environment variable is modified by mistake; If it is not modified by mistake or it is detected that the program to be tested does not have any running vulnerability, a prompt message of the target environment variable error is generated.
7. The method for rewriting environment variables in a terminal according to any one of claims 1 to 6, characterized in that: The step of obtaining the target environment variable required to replace the environment variable to be modified includes: Based on the SMI service program, generating a modification interface for the environment variable to be modified; Based on the modification interface, a target environment variable required to replace the environment variable to be modified is obtained.
8. A device for rewriting environment variables in a terminal, characterized in that: The device for rewriting environment variables in the terminal includes: A recording module, used for determining the environment variables to be modified in the firmware BIOS based on the SMI service program, and recording the position numbers of the environment variables to be modified; An acquisition module, used for acquiring a target environment variable required to replace the environment variable to be modified; A replacement module is used to replace the to-be-modified environment variable with the target environment variable according to the position number based on the SMI service program.
9. A device for rewriting environment variables in a terminal, characterized in that: The device for rewriting environment variables in the terminal includes: a memory, a processor, and a rewriting program for environment variables in the terminal stored in the memory and executable on the processor, wherein the rewriting program for environment variables in the terminal is configured to implement the steps of the method for rewriting environment variables in the terminal as described in any one of claims 1 to 7.
10. A storage medium, characterized in that: A program for implementing a method for rewriting environment variables in a terminal is stored on the storage medium, and the program for implementing a method for rewriting environment variables in a terminal is executed by a processor to implement the steps of the method for rewriting environment variables in a terminal as described in any one of claims 1 to 7.