A vulnerability detection method, intelligent terminal and computer-readable storage medium
By constructing a calling process detection for binary programs, the problem of inability to effectively detect CWE243 vulnerabilities in the existing technology is solved, the timely discovery and repair of CWE243 vulnerabilities is achieved, and the security of the program is improved.
Patent Information
- Application Number
- CN202011500785.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-17
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2040-12-17
AI Technical Summary
Existing technology cannot effectively detect the CWE243 vulnerability, leading to the risk of being hacked.
Get the preset function symbols from the binary program by calling the preset interface, traverse the functions and build the calling process, and determine whether there is a preset sequence of calling processes, such as chroot->chdir->chroot->setresuid, etc., if it does not exist, then Detection of CWE243 vulnerability.
It realizes timely vulnerability detection of binary programs, reminds relevant personnel to make repairs, improves the security of the program, and avoids the release of vulnerabilities.
Smart Images

Figure CN112580058B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of program vulnerability detection, and in particular to a vulnerability detection method, an intelligent terminal and a computer-readable storage medium. Background Art
[0002] BAP (Binary Analysis Platform, a framework for writing program analysis tools) is a binary analysis platform tool, based on which corresponding plug-ins can be developed to analyze binary instructions.
[0003] CWE (Common Weakness Enumeration) is a list of common software and hardware security vulnerabilities developed by the community. It is a universal number with a corresponding number for each vulnerability type.
[0004] The vulnerability type represented by the CWE243 vulnerability number is: creating a chroot isolation area without changing the working directory (the chroot isolation area refers to a folder directory, and the function of the chroot isolation area is to limit permissions). The CWE243 vulnerability will be at risk of being hacked.
[0005] Examples of CWE243 vulnerability types are as follows:
[0006] chroot(" / var / ftproot"); ...
[0008] fgets(filename,sizeof(filename),network);
[0009] localfile=fopen(filename, "r");
[0010] while((len=fread(buf,1,sizeof(buf),localfile))!=EOF){
[0011] fwrite(buf, 1, sizeof(buf), network);
[0012] }
[0013] fclose(localfile);
[0014] The above code is responsible for reading the file name from the network, opening the corresponding file on the local computer, and sending the contents over the network; this code can be used to implement the ftp get command (the ftp get command allows users to get files). The ftp server calls chroot() in its initialization routine in an attempt to prevent access to files outside of / var / ftproot. However, because the server does not change the current working directory by calling chdir(" / "), an attacker can request the file ".. / .. / .. / .. / .. / .. / etc / passwd" and obtain a copy of the system password file.
[0015] There is no effective method for detecting CWE243 vulnerabilities in the prior art, and CWE243 vulnerabilities cannot be discovered in a timely manner, thus posing the risk of being hacked.
[0016] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0017] The main purpose of the present invention is to provide a vulnerability detection method, an intelligent terminal and a computer-readable storage medium, aiming to solve the problem that there is no effective method for detecting CWE243 vulnerabilities in the prior art, and CWE243 vulnerabilities cannot be discovered in time, thus posing the risk of being hacked.
[0018] To achieve the above object, the present invention provides a vulnerability detection method, which comprises the following steps:
[0019] Call the preset interface to obtain the preset function symbol from the binary program;
[0020] Traversing all functions of the binary program, if there is a function that calls the preset function, storing the function that calls the preset function in a preset variable;
[0021] Traversing all functions stored in the preset variables, obtaining all sub-functions in the functions that call preset instructions, wherein the sub-functions constitute a calling process;
[0022] Determine whether there is a calling process with a preset sequence in the calling process. If not, detect whether there is a preset vulnerability.
[0023] Optionally, in the vulnerability detection method, the preset vulnerability is a CWE243 vulnerability.
[0024] Optionally, in the vulnerability detection method, the calling process of the preset sequence is:
[0025] chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling process.
[0026] Optionally, the vulnerability detection method, wherein the step of determining whether the calling process has a calling process of a preset order, and if not, detecting whether a preset vulnerability exists, specifically includes:
[0027] Determine whether the calling process contains chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes;
[0028] If it does not exist, it means that no directory changes have been made and the CWE243 vulnerability is detected.
[0029] Optionally, the vulnerability detection method, wherein the step of determining whether the calling process has a calling process in a preset order, further comprises:
[0030] If the calling process includes chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes, it means that the directory has been changed and the CWE243 vulnerability does not exist.
[0031] Optionally, in the vulnerability detection method, the preset function symbol is a chroot function symbol.
[0032] Optionally, in the vulnerability detection method, the preset variable is a callroot variable.
[0033] Optionally, in the vulnerability detection method, the preset instruction is a call instruction.
[0034] In addition, to achieve the above-mentioned purpose, the present invention also provides a smart terminal, wherein the smart terminal includes: a memory, a processor, and a vulnerability detection program stored in the memory and executable on the processor, and when the vulnerability detection program is executed by the processor, the steps of the vulnerability detection method described above are implemented.
[0035] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a vulnerability detection program, and when the vulnerability detection program is executed by a processor, the steps of the vulnerability detection method described above are implemented.
[0036] The present invention obtains a preset function symbol from a binary program by calling a preset interface; traverses all functions of the binary program, and if there is a function that calls the preset function, stores the function that calls the preset function in a preset variable; traverses all functions stored in the preset variable, obtains all sub-functions in the function that call preset instructions, and the sub-functions constitute a calling process; determines whether there is a calling process in a preset order in the calling process, and if not, detects the presence of a preset vulnerability. The present invention detects whether the developed binary program has a CWE243 vulnerability type before the program is released to the outside world. If a CWE243 vulnerability exists, it promptly reminds relevant personnel to repair the vulnerability to improve the security of the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of a preferred embodiment of the vulnerability detection method of the present invention;
[0038] Figure 2 Schematic diagram of the operating environment of a preferred embodiment of the intelligent terminal of the present invention. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0040] The vulnerability detection method described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the vulnerability detection method includes the following steps:
[0041] Step S10: calling a preset interface to obtain a preset function symbol from the binary program.
[0042] Specifically, the vulnerability detection method of the present invention is completed by an intelligent terminal (such as a computer); wherein the preset interface is a bap find_symbol interface, and the bap find_symbol interface can obtain binary symbols; the preset function symbol is a chroot function symbol, chroot is Change Root, that is, changing the root directory location referenced when the program is executed, chroot can enhance the security of the system and limit what the user can do; the chroot function is used to change the root directory of the process, and the parameters of the chroot function represent the new process root directory. The change of the root directory of the child process does not affect the parent process. On the contrary, the change of the root directory of the parent process will affect the child process.
[0043] Among them, the binary program (i.e. binary code) is a code composed of two basic characters '0' and '1'. Among them, code element: "one bit" binary code. Code word: N code elements can be composed of different combinations, any combination is called a code word. Binary code language is also called machine language, which can be directly recognized by computers without any translation. The format and meaning of the instructions of each machine are rigidly stipulated, so it is called machine-oriented language, also known as machine language. It is the first generation of computer language, and machine language is generally different for different models of computers. Computer language directly expressed by binary code instructions, instructions are a string of codes composed of 0 and 1, they have a certain number of bits and are divided into several segments. The encoding of each segment represents different meanings. For example, the word length of a computer is 16 bits, that is, there are 16 binary numbers to form an instruction or other information. 16 0s and 1s can form various permutations and combinations, which are converted into electrical signals through lines, allowing computers to perform various operations.
[0044] Specifically, the intelligent terminal obtains the chroot function symbol from the unreleased binary program through the bap find_symbol interface.
[0045] Step S20, traverse all functions of the binary program, and if there is a function that calls the preset function, store the function that calls the preset function in a preset variable.
[0046] Specifically, the preset function is a chroot function, and the preset variable is a callroot variable; the intelligent terminal traverses all functions in the binary program through bap, and if a function calls the chroot function, the function is saved in the callroot variable.
[0047] Step S30, traverse all functions stored in the preset variables, obtain all sub-functions in the function that call the preset instructions, and the sub-functions constitute the calling process.
[0048] Specifically, the preset instruction is a call instruction. The call instruction is a subroutine to which the computer transfers. When the call instruction is executed, two operations are performed: (1) the IP of the location of the next instruction of the program is pushed into the stack; and (2) the subroutine is transferred to.
[0049] The intelligent terminal traverses all functions of the callroot variable and obtains sub-functions called by all call instructions in the function, and the sub-functions constitute a calling process.
[0050] Step S40, determining whether there is a calling process in a preset order in the calling process, and if not, detecting whether there is a preset vulnerability.
[0051] Specifically, the calling process of the preset sequence is: chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling process.
[0052] The intelligent terminal determines whether the calling process contains chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes; if not, it means that no directory change is performed and the CWE243 vulnerability is detected.
[0053] If the calling process includes chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes, it means that the directory has been changed and the CWE243 vulnerability does not exist.
[0054] That is to say, if the smart terminal changes the directory, the CWE243 vulnerability does not exist, and if the directory is not changed, the CWE243 vulnerability exists.
[0055] Furthermore, after determining that the CWE243 vulnerability is detected, the smart terminal promptly notifies relevant staff (for example, the smart terminal prompts the existence of the CWE243 vulnerability on the interface or sends information about the existence of the CWE243 vulnerability to the pre-bound electronic device carried by the staff), so that the staff can repair the CWE243 vulnerability in time and avoid the release of binary programs with the CWE243 vulnerability.
[0056] The present invention provides a method for detecting whether a developed binary program has a CWE243 vulnerability, so that the CWE243 vulnerability can be detected and repaired before the program is released to the outside.
[0057] Furthermore, if Figure 2 As shown, based on the above vulnerability detection method, the present invention also provides a smart terminal accordingly, and the smart terminal includes a processor 10, a memory 20 and a display 30. Figure 2 Only some components of the smart terminal are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0058] In some embodiments, the memory 20 may be an internal storage unit of the smart terminal, such as a hard disk or memory of the smart terminal. In other embodiments, the memory 20 may also be an external storage device of the smart terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the smart terminal. Further, the memory 20 may also include both an internal storage unit of the smart terminal and an external storage device. The memory 20 is used to store application software and various types of data installed in the smart terminal, such as the program code of the installed smart terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a vulnerability detection program 40 is stored on the memory 20, and the vulnerability detection program 40 can be executed by the processor 10, thereby realizing the vulnerability detection method in the present application.
[0059] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the vulnerability detection method.
[0060] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the smart terminal and to display a visual user interface. The components 10-30 of the smart terminal communicate with each other via a system bus.
[0061] In one embodiment, when the processor 10 executes the vulnerability detection program 40 in the memory 20, the following steps are implemented:
[0062] Call the preset interface to obtain the preset function symbol from the binary program;
[0063] Traversing all functions of the binary program, if there is a function that calls the preset function, storing the function that calls the preset function in a preset variable;
[0064] Traversing all functions stored in the preset variables, obtaining all sub-functions in the functions that call preset instructions, wherein the sub-functions constitute a calling process;
[0065] Determine whether there is a calling process with a preset sequence in the calling process. If not, detect whether there is a preset vulnerability.
[0066] Among them, the preset vulnerability is the CWE243 vulnerability.
[0067] The calling process of the preset sequence is as follows:
[0068] chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling process.
[0069] The determining whether there is a calling process in a preset order in the calling process, and if not, detecting the presence of a preset vulnerability, specifically includes:
[0070] Determine whether the calling process contains chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes;
[0071] If it does not exist, it means that no directory changes have been made and the CWE243 vulnerability is detected.
[0072] Wherein, the determining whether the calling process has a calling process in a preset order further includes:
[0073] If the calling process includes chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes, it means that the directory has been changed and the CWE243 vulnerability does not exist.
[0074] Wherein, the preset function symbol is a chroot function symbol.
[0075] Wherein, the preset variable is the callroot variable.
[0076] Wherein, the preset instruction is a call instruction.
[0077] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a vulnerability detection program, and when the vulnerability detection program is executed by a processor, the steps of the vulnerability detection method described above are implemented.
[0078] In summary, the present invention provides a vulnerability detection method, an intelligent terminal and a computer-readable storage medium, the method comprising: calling a preset interface to obtain a preset function symbol from a binary program; traversing all functions of the binary program, if there is a function calling the preset function, storing the function calling the preset function in a preset variable; traversing all functions stored in the preset variable, obtaining all sub-functions in the function that call the preset instruction, the sub-functions forming a calling process; judging whether there is a calling process in a preset order in the calling process, if not, detecting the presence of a preset vulnerability. The present invention detects whether the developed binary program has a CWE243 vulnerability type before the program is released to the outside world, and if there is a CWE243 vulnerability, promptly reminds relevant personnel to repair the vulnerability to improve the security of the program.
[0079] 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 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 "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0080] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0081] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A vulnerability detection method, It is characterized in that The vulnerability detection method comprises: Call the preset interface to obtain the preset function symbol from the binary program; Traversing all functions of the binary program, if there is a function that calls the preset function, storing the function that calls the preset function in a preset variable; Traversing all functions stored in the preset variables, obtaining all sub-functions in the functions that call preset instructions, wherein the sub-functions constitute a calling process; Determine whether there is a calling process in a preset order in the calling process, and if not, detect whether there is a preset vulnerability; The preset vulnerability is CWE243 vulnerability; The calling process of the preset sequence is as follows: chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling process.
2. The vulnerability detection method according to claim 1, It is characterized in that The determining whether there is a calling process in a preset order in the calling process, and if not, detecting the presence of a preset vulnerability, specifically includes: Determine whether the calling process contains chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes; If it does not exist, it means that no directory changes have been made and the CWE243 vulnerability is detected.
3. The vulnerability detection method according to claim 1, It is characterized in that The step of determining whether the calling process has a calling process in a preset order further includes: If the calling process includes chroot->chdir, chdir->chroot->setresuid, chdir->chroot->seteuid, chdir->chroot->setreuid and chdir->chroot->setuid calling processes, it means that the directory has been changed and the CWE243 vulnerability does not exist.
4. The vulnerability detection method according to claim 1, It is characterized in that The preset function symbol is a chroot function symbol.
5. The vulnerability detection method according to claim 1, It is characterized in that The preset variable is the callroot variable.
6. The vulnerability detection method according to claim 1, It is characterized in that The preset instruction is a call instruction.
7. A smart terminal, It is characterized in that The smart terminal includes: a memory, a processor, and a vulnerability detection program stored in the memory and executable on the processor. When the vulnerability detection program is executed by the processor, the steps of the vulnerability detection method according to any one of claims 1 to 6 are implemented.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a vulnerability detection program, and when the vulnerability detection program is executed by a processor, the steps of the vulnerability detection method according to any one of claims 1 to 6 are implemented.
