Attack behavior detection method and device, attack behavior blocking method and device
In the real-time application self-protection environment, real-time detection and blocking of attack behaviors are achieved by obtaining and judging the characteristic information of the application class, solving the problems of long detection time and insufficient detection capabilities in the existing technology, and improving the application efficiency. real-time and security.
Patent Information
- Application Number
- CN202410663479.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-05-27
AI Technical Summary
The existing technology has poor real-time performance when detecting and blocking attack behaviors, and the detection takes a long time. In particular, the detection capability of proxy classes dynamically generated by the JVM is insufficient, resulting in low real-time performance and low reliability.
In the real-time application self-protection environment, the characteristic information of loaded or loading classes in the application is obtained, and based on these characteristic information, it is judged whether there is an attack behavior, and alarm information or blocking instructions are generated to achieve real-time detection and blocking.
It improves the real-time and reliability of application monitoring, can detect and block classes with offensive behavior in a timely manner, and improves security.
Smart Images

Figure CN118260750B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an attack behavior detection method and device, an attack behavior blocking method and device, an electronic device, and a computer-readable medium. Background Art
[0002] With the development of fileless attack methods, due to their fileless characteristics, they can effectively evade detection by traditional security equipment, causing great harm.
[0003] In the current application running environment, the general detection method is to dump the bytecode, then upload it to the server and perform detection on the server. This method has poor real-time performance and takes a long time to detect. Summary of the invention
[0004] The embodiments of the present disclosure provide a method and device for attack behavior detection, a method and device for attack behavior blocking, an electronic device, and a computer-readable medium.
[0005] In a first aspect, an embodiment of the present disclosure provides an attack behavior detection method, the method comprising: controlling an application to run in a real-time application self-protection environment; in the real-time application self-protection environment, obtaining characteristic information of a loaded class or a loaded class in the application; based on the characteristic information, determining whether the loaded class or the loaded class contains a class with attack behavior; in response to a determination that the loaded class or the loaded class contains a class with attack behavior, generating an alarm message.
[0006] In a second aspect, an embodiment of the present disclosure provides an attack behavior blocking method, the method comprising: in response to detecting a class with attack behavior in a loaded class in an application, sending an alarm message to a server, the application running in a real-time application self-protection environment; in response to receiving a blocking instruction sent by the server, blocking the class with attack behavior in the loaded class
[0007] In a third aspect, an embodiment of the present disclosure provides an attack behavior detection device, which includes: a control unit, configured to control an application to run in a real-time application self-protection environment; a feature acquisition unit, configured to acquire feature information of a loaded class or a loading class in the application in the real-time application self-protection environment; a judgment unit, configured to judge whether there is a class with attack behavior in the loaded class or the loading class based on the feature information; and a generation unit, configured to generate an alarm message in response to a judgment result that there is a class with attack behavior in the loaded class or the loading class.
[0008] In a fourth aspect, an embodiment of the present disclosure provides an attack behavior blocking device, which includes: a sending unit, configured to send an alarm message to a server in response to detecting a class with attack behavior in a loaded class in an application, and the application runs in a real-time application self-protection environment; a blocking unit, configured to block the class with attack behavior in the loaded class in response to receiving a blocking instruction sent by the server.
[0009] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any embodiment of the first aspect or the second aspect.
[0010] In a sixth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any embodiment of the first aspect or the second aspect.
[0011] The attack behavior detection method and device provided by the embodiments of the present disclosure firstly control the application to run in the real-time application self-protection environment; secondly, in the real-time application self-protection environment, obtain the characteristic information of the loaded class or the loading class in the application; thirdly, based on the characteristic information, determine whether there is a class with attack behavior in the loaded class or the loading class; finally, in response to the judgment result that there is a class with attack behavior in the loaded class or the loading class, generate an alarm information. Thus, the control application runs in the real-time application self-protection environment, and the classes in the application can be monitored conveniently, quickly and in real time. During the monitoring process, the classes with attack behavior can be detected and alarmed in time, which improves the real-time and reliability of application monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0013] Figure 1 is a flow chart of an embodiment of an attack behavior detection method according to the present disclosure;
[0014] Figure 2 is a flow chart of an embodiment of an attack behavior blocking method according to the present disclosure;
[0015] Figure 3 is a structural schematic diagram of an embodiment of an attack behavior detection device according to the present disclosure;
[0016] Figure 4 is a schematic structural diagram of an embodiment of an attack behavior blocking device according to the present disclosure;
[0017] Figure 5 The block diagram is a block diagram of an electronic device used to implement the attack behavior detection or attack behavior blocking method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0019] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0020] The existing memory horse detection technology dumps the bytecode, then matches the attack behavior rules, uploads it to the server, and performs detection after decompiling. This solution has the following disadvantages:
[0021] 1. Poor real-time performance, long detection time, lengthy and complicated process, slow server detection speed, and easy accumulation.
[0022] 2. The detection capability is insufficient for some proxy classes dynamically generated by JVM (Java Virtual Machine).
[0023] In view of the above defects, the present disclosure provides an attack behavior detection method, which can detect classes with attack behaviors in real time. Figure 1 , shows a process 100 of an embodiment of an attack behavior detection method according to the present disclosure, the attack behavior detection method comprises the following steps:
[0024] Step 101, controlling the application to run in a real-time application self-protection environment.
[0025] In this embodiment, the application is a computer program running on a computer or smart device, such as enterprise management, data analysis, medical diagnosis, education and training programs. The real-time application self-protection environment refers to the operating environment where the RASP (Runtime application self-protection) program is installed. RASP, as an attack behavior detection method, runs on the execution subject and the service process of the application program at the same time, and detects or blocks the classes in the application.
[0026] In this embodiment, when the application is implemented in JAVA language, the above step 101 includes:
[0027] Based on the JavaAgent in JDK (Java Development Kit, a software development kit for the Java language), also known as the Java probe, RASP is installed into the Java application through dynamic or static installation.
[0028] For example: the above-mentioned Java application is an educational training program. Installing the RASP program into the Java application will enable the Java application to run in a real-time application self-protection environment. The Java application will be protected by the RASP program. When there is a class of attack behavior in the Java application, the RASP program will give an alarm message.
[0029] Step 102: In the real-time application self-protection environment, characteristic information of a class that has been loaded or is being loaded in the application is obtained.
[0030] In this embodiment, the characteristic information of a class is information reflecting the characteristics of the class itself (class information), the class bytecode information, and the characteristics of the object that loads the class, wherein the class bytecode is the code generated after the class is compiled.
[0031] In this embodiment, the loaded class is a class that has been running or introduced in the real-time application self-protection environment in the application. The loading class is a class that is running or introduced in the real-time application self-protection environment in the application.
[0032] In this embodiment, when the application is a Java application, the Java Instrumentation mechanism can be used to register the ClassFileTransformer (class file converter) defined by RASP to implement the transform callback function, and scan the loaded or loading classes of the Java application in the JVM. When the class is converted again, the transform callback function of the ClassFileTransformer will be automatically triggered. The feature information of the current class can be obtained in the transform callback function.
[0033] In this embodiment, the characteristic information of the loaded class or the loading class may include the bytecode of the class, the class name, the class loading address, the class loader, the interface implemented by the class, and the inherited parent class.
[0034] Step 103: Based on the feature information, determine whether the loaded class or the loading class contains a class with attacking behavior.
[0035] In this embodiment, the above step 103 includes: matching the characteristic information of the loaded class or the loading class with the attack characteristic of the class of the pre-set attack behavior, and in response to the characteristic information of the loaded class or the loading class successfully matching the attack characteristic, determining that the loaded class or the loading class is a class with attack behavior.
[0036] Among them, the attack feature is obtained by pre-analyzing the attack situations of all classes with attack behaviors.
[0037] Optionally, the step 103 further includes: in response to the fact that the feature information of the loaded class or the loading class fails to match the attack feature, determining that the loaded class or the loading class is not a class with attack behavior.
[0038] Step 104: in response to the judgment result that a class in the loaded class or the class being loaded has an attack behavior, generate an alarm message.
[0039] In this embodiment, if it is determined that the loaded classes or the classes being loaded include classes with attack behaviors, RASP will generate alarm information using the information of the classes with attack behaviors and report it to the server.
[0040] In this embodiment, the warning information includes: class information and description information of the attack behavior. The class information includes: the class name of the class with the attack behavior, and the description information of the attack behavior is information describing the type of the attack behavior, wherein the class with the attack behavior can be a class that has been loaded in the application or a class that is being loaded in the application.
[0041] In this embodiment, RASP can have a built-in bytecode detection method, so that the bytecode detection method can be used to perform real-time detection of attack behavior classes when the class is loaded. The built-in bytecode detection technology has extremely high performance and can usually complete the detection of a class in sub-millisecond time. It also has the ability to detect loaded classes, with extremely high detection performance, and can complete the detection and analysis of thousands of classes within 500 milliseconds. RASP completes memory horse analysis and detection internally, and does not require the server's detection engine. If it is a memory horse, it will be reported, and if it is not, it will be recorded as detected. The process is very simple. Among them, when the application uses Java, the bytecode is Java bytecode, which is an intermediate code. It is a low-level language similar to assembly language and is used to execute in the JVM virtual machine.
[0042] The attack behavior detection method provided by the embodiment of the present disclosure firstly controls the application to run in the real-time application self-protection environment; secondly, in the real-time application self-protection environment, obtains the characteristic information of the loaded class or the loading class in the application; thirdly, based on the characteristic information, determines whether there is a class with attack behavior in the loaded class or the loading class; finally, in response to the judgment result that there is a class with attack behavior in the loaded class or the loading class, generates an alarm information. Thus, the control application runs in the real-time application self-protection environment, and the classes in the application can be monitored conveniently, quickly and in real time. During the monitoring process, the classes with attack behavior can be detected and alarmed in time, which improves the real-time and reliability of application monitoring.
[0043] In some optional implementations of the present disclosure, the above-mentioned loading class includes: the class of the component to be created or registered, and the characteristic information includes: stack information of the component class; based on the characteristic information, judging whether the loaded class or the loading class has a class with attack behavior includes: detecting whether the stack information satisfies the attack call condition; in response to the stack information satisfying the attack call condition, determining that the component class is a class with attack behavior.
[0044] In this optional implementation, the attack call condition is a condition for determining whether the class of the component to be created or registered is maliciously called or injected. The components newly added by various frameworks are different, and the stack information obtained is different. Therefore, the content of the attack call condition can be different.
[0045] Generally, registration is gradually called through normal methods, and attackers cannot use normal methods to inject malicious classes in most cases. There are several common characteristics: 1) using reflection, 2) injecting in jsp (JavaServer Pages, JAVA server pages), 3) injecting in the deserialization call chain / jndi (Java Naming and Directory Interface, Java Naming and Directory Interface) injection vulnerability method.
[0046] In this embodiment, the attack call condition is a condition related to the above-mentioned features. By obtaining the thread stack in the method of adding the component to be registered, the thread stack is used as the stack information, and the stack information is analyzed to see whether it meets the attack call condition, thereby detecting whether the class of the component is a malicious class.
[0047] The method for determining the class of attack behavior provided by this optional implementation mode detects whether the stack information of the component class meets the attack call condition when the class being loaded includes the class of the component to be registered. When the attack call condition is met, it is determined that the component class is a class with attack behavior, which provides a reliable implementation method for obtaining the class of attack behavior and improves the security of the application.
[0048] In some optional implementations of the present disclosure, the above-mentioned characteristic information includes: a class loading address; based on the characteristic information, determining whether a loaded class or a loading class has a class with attack behavior includes: determining whether a loaded class or a loading class has a class whose loading address is a remote address; in response to determining that a class has a class whose loading address is a remote address, determining that the class is a class with attack behavior.
[0049] Conventional, normal business classes are usually loaded from the local file system. Those from remote locations usually have problems. For example, the malicious class loading address of a memory horse injected through jndi may be http: / / xxxx.
[0050] In this optional implementation, the class loading address is an accessible address of the class file. The class files in the application are generally stored locally, and the class loading address is generally a local access address. If the class loading address is a remote address, it is determined that this class is an attack behavior class.
[0051] The method for determining the class of attack behavior provided by this optional implementation method, when the characteristic information includes: class loading address, based on the class loading address, determines whether there is a class of attack behavior in the loaded class or the class being loaded. This method can determine the behavior of attacking through remote classes, thereby improving the security of the application.
[0052] Optionally, based on the feature information, determining whether a loaded class or a loading class contains a class with attacking behavior includes: determining whether the loading addresses of all classes in the loaded class or the loading class are local addresses; in response to determining that the loading address of a class is not a local address, determining that the class is a class with attacking behavior.
[0053] In some optional implementations of the present disclosure, the above-mentioned feature information includes: class name; based on the feature information, determining whether a loaded class or a loading class has a class with attack behavior includes: determining whether a loaded class or a loading class has a class name that is empty; in response to determining that the class name of the class is not empty, determining whether the class name includes a package name; in response to determining that the class name does not include a package name, determining that the class is a class with attack behavior.
[0054] In most normal cases, the class name will be determined when the class is loaded. However, in some memory horse injection scenarios, since defineClass is called directly without specifying the class name, the class name is determined by the bytecode when the class is loaded. This is an obvious feature of some memory horse malicious classes. Therefore, malicious classes can be effectively screened out by judging whether the class name is empty.
[0055] For applications implemented by Java, normal business codes generally contain package names. For example, "com.qt.pkgName" in com.qt.pkgName.className is the package name, while many memory horse malicious classes do not contain package names, but directly a class name className.
[0056] In this optional implementation, the class name is the complete name of the class including the package name, and the class names of the classes in the application are all complete names with package names. If the class name is empty or does not include the package name, then the class is determined to be an attack behavior class.
[0057] In this optional implementation, for Java applications, the class name is the name of the class, corresponding to the file name of the .class file generated after the class is compiled; the package name is the name of the package where the class is located, generally corresponding to the name of the file path where the generated .class file is located, and the package name can be obtained by separating the path levels with .
[0058] This optional implementation provides a method for determining classes with attacking behavior. When the characteristic information includes a class name, the method determines whether a loaded class or a loading class has a class with attacking behavior based on the class name. This method can determine whether there is a class with attacking behavior among all classes of the application, thereby improving the security of the application.
[0059] Optionally, judging whether a loaded class or a loading class has an attacking behavior class based on the feature information further includes: in response to judging that the class name of a class is empty, determining that the class is an attacking behavior class.
[0060] In some optional implementations of the present disclosure, the above-mentioned determining, based on feature information, whether a loaded class or a loading class has an attacking class includes: in response to determining that the class name includes a package name, determining whether the class name is in a blacklist; in response to determining that the class name is in the blacklist, determining that the class is a class with attacking behavior.
[0061] In this embodiment, the blacklist refers to the content in the blacklist pre-configured by the server. The server can support customers to customize the blacklist. After RASP is installed, it will obtain the blacklist from the server. The server will also notify RASP after it is updated. When the blacklist is updated, RASP will re-obtain the blacklist. The content of the blacklist is a regular expression of the class name.
[0062] The method for determining a class with attacking behavior provided by this optional implementation, when the characteristic information includes: class name, first determines that the class name includes the package name, and then determines whether the class name is in the blacklist. If it is in the blacklist, the class in the blacklist is determined to be a class with attacking behavior. It can effectively determine whether a loaded class or a class being loaded has an attacking behavior, thereby improving the security of the application.
[0063] In some optional implementations of the present disclosure, the above-mentioned determining, based on feature information, whether a loaded class or a loading class contains a class with attacking behavior further includes: in response to determining that the class name includes a package name, determining whether the class name conforms to a dynamic web page script feature; in response to determining that the class name conforms to a dynamic web page script feature, determining that the class is a class with attacking behavior.
[0064] In this optional implementation, the dynamic web page script refers to the programming language used to design interactive web pages that runs on the server. When the application is implemented in JAVA language, the dynamic web page script feature refers to the servlet-related component class created by jsp, whose class name has jsp features, such as org.apache.jsp.xxxx_jsp, and inherits the Servlet-related interface, which is a class injected by jsp, and is determined to be a class with attack behavior.
[0065] The method for determining a class with attacking behavior provided by this optional implementation, when the characteristic information includes: class name, first if it is determined that the class name includes the package name, then determine whether the type meets the characteristics of a dynamic web page script, and when the class name meets the characteristics of a dynamic web page script, determine that the class is a class with attacking behavior, which provides a reliable implementation method for obtaining the class with attacking behavior and improves the security of the application.
[0066] In some optional implementations of the present disclosure, the above-mentioned feature information includes: the bytecode of the class; based on the feature information, determining whether a loaded class or a loading class has a class with attack behavior includes: simulating the execution process of the bytecode to obtain the execution result of the execution process; based on the execution result, determining whether a loaded class or a loading class has a class with attack behavior.
[0067] In this optional implementation, the bytecode of a class refers to the file content after the class file is compiled, which is an instruction format that can be executed on the JVM. When the application is implemented in Java, the bytecode of the class is Java bytecode.
[0068] In this optional implementation, after parsing the bytecode format, each instruction called by the bytecode can be obtained. These instructions are detected to analyze whether they are malicious calls, thereby determining the class with attack behavior.
[0069] In this optional implementation, the above-mentioned simulation of the bytecode execution process and the execution result of the execution process include: simulating and analyzing the bytecode execution process, setting a virtual virtual value for an unknown variable, simulating all JVM instruction operations in the bytecode, simulating the role of instructions between each virtual value, processing the taint propagation data between variables based on the role of the instructions, performing reasoning analysis of various reflection methods, and determining whether there are malicious method calls or suspicious reflection method calls. If there are malicious method calls or suspicious method reflection calls, an execution result indicating the presence of malicious method calls or suspicious method reflection calls is obtained.
[0070] In this optional implementation, suspicious reflection methods are related to specific network frameworks and can be divided into the following categories: reflection call methods; reflection field acquisition methods; reflection methods that cannot be inferred and analyzed; and obfuscated reflection method calls. Among them, reflection call methods refer to: when malicious classes are usually injected, they are not normal method calls and require a lot of reflection, such as the characteristics of malicious classes injected into Servlet type memory horses.
[0071] Reflection method to obtain fields usually requires a lot of reflection when injecting malicious classes. For example, the normal method of obtaining fields is to use the GETFIELD instruction, while the reflection method is getField / getDeclaredField. Analyze the getField / getDeclaredField instruction to get the name of the field that getField actually wants to obtain. For example, filterConfigs, which does not exist in normal code, is a typical feature of malicious classes that inject filter-type memory into the memory.
[0072] The above reflection call method and reflection field acquisition method both specify the method name clearly, but in many cases the method name is obfuscated (that is, the obfuscated reflection method call) or the reflected method or reflected field cannot be analyzed (the reflected method cannot be analyzed).
[0073] In this optional implementation, the class corresponding to the malicious method or suspicious method in the execution result of the malicious method call or suspicious method reflection call is regarded as the class with attack behavior.
[0074] The method for determining a class with attacking behavior provided by this optional implementation, when the characteristic information includes: the bytecode of the class, obtains the execution result by simulating the execution process of the bytecode, and determines the class with attacking behavior in the loaded class or the class being loaded based on the execution result.
[0075] The method for determining the class of attack behavior provided by this optional implementation method, when the characteristic information includes the bytecode of the class, determines the class with attack behavior in the loaded class or the class being loaded by simulating the execution process of the bytecode, thereby providing a reliable implementation method for obtaining the class of attack behavior and improving the security of the application.
[0076] Optionally, the above-mentioned characteristic information includes: the bytecode of the class can be a proxy class or a class dynamically generated by the JVM, and the above-mentioned determination of whether the loaded class or the loading class has an attack behavior based on the characteristic information includes: performing a whitelist detection on the bytecode of the class can be a proxy class or a class dynamically generated by the JVM. Among them, the whitelist refers to the normal format of the pre-set bytecode, and the false alarm of the application can be specifically added to the whitelist and sent to the RASP to avoid false alarms and erroneous interception.
[0077] In this optional implementation, by analyzing the bytecode of the proxy class and the reflection class dynamically generated by the JVM, whitelist detection and filtering are performed, which effectively avoids false positives of the proxy class and the reflection class dynamically generated by the JVM. In addition, because it is a whitelist mode, targeted bypassing and missed reports are effectively avoided.
[0078] In traditional technology, memory horse detection is to dump the bytecode, then match the attack behavior rules, and upload it to the server. There is no ability to intercept and block the attack behavior class.
[0079] Therefore, in order to effectively prevent classes with attack behaviors in applications, the present disclosure provides an attack behavior blocking method to block the operation of classes with attack behaviors. Figure 2 , a process 200 of an embodiment of the attack behavior blocking method disclosed in the present invention, the attack behavior blocking method comprises the following steps:
[0080] Step 201: In response to detecting that a class loaded in an application has attack behavior, sending an alarm message to a server.
[0081] In this embodiment, the above-mentioned warning information includes: class information of the attack behavior class, description information of the attack behavior, etc., and whether the class with the attack behavior is a loaded class or a class being loaded in the application can be determined through the loaded sub-information.
[0082] In this embodiment, the warning information may be the warning information issued after the above-mentioned attack behavior detection method detects that the loaded class or the loading class includes a class with attack behavior.
[0083] In this embodiment, the execution subject on which the attack behavior blocking method runs may be RASP.
[0084] Optionally, when a class with attack behavior is detected being loaded in the application, an alarm message is sent to the server.
[0085] Step 202: In response to receiving a blocking instruction sent by the server, blocking classes with attack behaviors in loaded classes.
[0086] In this embodiment, the blocking instruction can be an emergency blocking instruction. The server operator can click the emergency blocking on the interface, and the server sends the blocking instruction to the RASP. After receiving the blocking instruction, the RASP blocks the classes with attack behaviors in the loaded classes in the following ways: (1) usually preventing the execution of any method of the malicious class; (2) for the classes with Filter / Valve attack behaviors in the loaded classes (such as memory horse malicious classes), some code logic of the Java application framework is modified by inserting stubs to skip the execution of the Filter / Value type memory horse malicious classes.
[0087] The attack behavior blocking method provided in this embodiment sends an alarm message to the server in response to a class with attack behavior in the loaded classes in the application; after receiving the blocking instruction sent by the server, the class with attack behavior in the loaded classes is blocked, which provides a reliable implementation method for blocking the class with attack behavior and ensures the security of the application.
[0088] In some embodiments of the present disclosure, the above-mentioned attack behavior blocking method also includes: in response to detecting that there is a class with no attack behavior in the loaded classes in the application, detecting whether there is a class with attack behavior in the classes being loaded in the application; in response to detecting that there is a class with attack behavior in the classes being loaded in the application, obtaining switch status information of a blocking switch; in response to the switch status information being in an open state, blocking the class with attack behavior in the classes being loaded.
[0089] In this embodiment, the application runs in a real-time application self-protection environment, and the attack behavior blocking method runs on the execution subject which may be RASP.
[0090] In this embodiment, the blocking switch is used to indicate whether the blocking function is turned on. When the application runs in a real-time application self-protection environment, the blocking switch can be a switch configured in the RASP. The switch status information of the blocking switch is generally status identification information that identifies whether the switch is turned on or off. When the switch status information of the blocking switch is in the on state, it indicates that the attack behavior class can be blocked; when the switch status information of the blocking switch is in the off state, it indicates that the attack behavior class can be loaded normally.
[0091] In this embodiment, in response to the switch status information being on, blocking the class with attack behavior in the class being loaded includes: in response to the switch status information being on, modifying the bytecode format of the class with attack behavior to an incorrect format to prevent the JVM from loading the class with attack behavior.
[0092] Optionally, the above attack behavior blocking method further includes: when the class being loaded includes: the class of the component to be created or registered, if the switch state information of the blocking switch is on, throwing an exception to prevent the creation or registration of the component.
[0093] Optionally, the above-mentioned attack behavior blocking method further includes: in response to receiving a setting instruction sent by the server, matching the switch state information of the blocking switch according to the setting instruction to obtain the switch state information of the blocking switch.
[0094] In this embodiment, the blocking switch is a switch variable, and usually only an alarm cannot achieve blocking. The server can send a setting instruction to configure the switch state of the blocking switch to the RASP, that is, the setting instruction is used to set the switch state information of the blocking switch. After receiving the setting instruction, the RASP extracts the new configuration value in the setting instruction and updates the switch state information of the blocking switch.
[0095] The attack behavior blocking method provided by the embodiment of the present disclosure controls the application to run in a real-time application self-protection environment, and can detect in real time when the class is loaded. If a malicious memory horse is detected and the blocking switch is turned on, the loading of the malicious class can be blocked in real time. After the class has been loaded, all methods of the malicious class can be plugged through hot patches and the blocking ability of the memory horse, and the execution of any method of the malicious class can be prohibited, and other methods can be used to block it, providing an efficient blocking method for memory horses.
[0096] Further references Figure 3 As an implementation of the attack behavior detection method shown in the above figures, the present disclosure provides an embodiment of an attack behavior detection device. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0097] like Figure 3 As shown, an embodiment of the present disclosure provides an attack behavior detection device 300, and the device 300 includes: a control unit 301, a feature acquisition unit 302, a judgment unit 303, and a generation unit 304. Among them, the above-mentioned control unit 301 can be configured to control the application to run in a real-time application self-protection environment. The above-mentioned feature acquisition unit 302 can be configured to obtain feature information of a loaded class or a loading class in the application in the real-time application self-protection environment. The above-mentioned judgment unit 303 can be configured to judge whether there is a class with attack behavior in the loaded class or the loading class based on the feature information. The above-mentioned generation unit 304 can be configured to generate an alarm message in response to the judgment result that the loaded class or the loading class has a class with attack behavior.
[0098] In this embodiment, the specific processing of the control unit 301, the feature acquisition unit 302, the judgment unit 303, and the generation unit 304 and the technical effects thereof can be referred to in the respective Figure 1 Corresponding to step 101, step 102, step 103, and step 104 in the embodiment.
[0099] In some embodiments, the above-mentioned loading class includes: the class of the component to be created or registered, and the above-mentioned characteristic information includes: the stack information of the component class; the above-mentioned judgment unit 303 is further configured to: detect whether the stack information meets the attack call condition; in response to the stack information meeting the attack call condition, determine that the component class is a class with attack behavior.
[0100] In some embodiments, the above-mentioned characteristic information includes: class name; the above-mentioned judgment unit 303 is further configured to: judge whether there is a class whose class name is empty in the loaded class or the loading class; in response to judging that the class name of the class is not empty, judge whether the class name of the class includes the package name; in response to judging that the class name of the class does not include the package name, determine that the class is a class with attack behavior.
[0101] In some embodiments, the judgment unit 303 is further configured to: in response to judging that the class name includes a package name, judge whether the class name is in the blacklist; in response to judging that the class name is in the blacklist, determine that the class is a class with attack behavior.
[0102] In some embodiments, the judgment unit 303 is further configured to: in response to determining that the class name includes a package name, determine whether the class name conforms to the characteristics of a dynamic web page script; in response to determining that the class name conforms to the characteristics of a dynamic web page script, determine that the class is a class with attack behavior.
[0103] In some embodiments, the above-mentioned characteristic information includes: the bytecode of the class; the above-mentioned judgment unit 303 is further configured to: simulate the execution process of the bytecode to obtain the execution result of the execution process; based on the execution result, determine whether there is a class with attack behavior in the loaded class or the loading class.
[0104] The attack behavior detection device provided by the embodiment of the present disclosure, first, the control unit 301 controls the application to run in the real-time application self-protection environment; secondly, the feature acquisition unit 302 obtains the feature information of the loaded class or the loading class in the application in the real-time application self-protection environment; thirdly, the judgment unit 303 judges whether there is a class with attack behavior in the loaded class or the loading class based on the feature information; finally, the generation unit 304 generates an alarm message in response to the judgment result that there is a class with attack behavior in the loaded class or the loading class. Thus, the application is controlled to run in the real-time application self-protection environment, and the classes in the application can be monitored conveniently, quickly and in real time. During the monitoring process, the classes with attack behavior can be detected and alarmed in time, which improves the real-time and reliability of application monitoring.
[0105] In order to effectively block classes with attack behaviors in applications, and as an implementation of the attack behavior blocking methods shown in the above figures, the present disclosure provides an embodiment of an attack behavior blocking device. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0106] like Figure 4 As shown, an embodiment of the present disclosure provides an attack behavior detection device 400, which includes: a sending unit 401 and a blocking unit 402. The sending unit 401 can be configured to send an alarm message to a server in response to detecting a class with attack behavior in a loaded class in an application, and the application runs in a real-time application self-protection environment. The blocking unit 402 can be configured to block a class with attack behavior in a loaded class in response to receiving a blocking instruction sent by the server.
[0107] In this embodiment, the specific processing of the sending unit 401 and the blocking unit 402 and the technical effects thereof can be referred to in Figure 2 Corresponding to step 201 and step 202 in the embodiment.
[0108] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0109] Figure 5A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0110] like Figure 5 As shown, the device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0111] A number of components in the device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0112] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as attack behavior detection or attack behavior blocking methods. For example, in some embodiments, the attack behavior detection or attack behavior blocking method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the attack behavior detection or attack behavior blocking method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform attack behavior detection or attack behavior blocking methods in any other appropriate manner (eg, by means of firmware).
[0113] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0114] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable attack behavior detection device or an attack behavior blocking device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package and partially on a remote machine, or entirely on a remote machine or server.
[0115] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0116] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0117] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0118] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0119] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
Claims
1. A method for detecting attack behavior, It is characterized in that Methods include: Control applications run in a real-time application self-protection environment; In the real-time application self-protection environment, obtaining characteristic information of a class that has been loaded or is being loaded in the application; The characteristic information includes: the bytecode of the class; Based on the feature information, determine whether the loaded class or the loading class has a class with attacking behavior; based on the feature information, determine whether the loaded class or the loading class has a class with attacking behavior, including: simulating the execution process of the bytecode to obtain the execution result of the execution process; based on the execution result, determine whether the loaded class or the loading class has a class with attacking behavior; simulating the execution process of the bytecode to obtain the execution result of the execution process includes: setting a virtual virtual value for an unknown variable, simulating all JVM instruction operations in the bytecode, obtaining the role played by the instructions between each virtual value, processing the taint propagation data between variables based on the role, performing reasoning analysis of various reflection methods, determining whether there is a malicious method call or a suspicious reflection method call, and if there is a malicious method call or a suspicious method reflection call, obtaining the execution result of the malicious method call or the suspicious method reflection call; In response to the judgment result that the loaded class or the loading class has an attacking behavior, an alarm message is generated.
2. The method according to claim 1, in, The loading class includes: a class of a component to be created or registered, and the characteristic information includes: stack information of the class of the component; the class for judging whether the loaded class or the loading class has attack behavior based on the characteristic information includes: Detecting whether the stack information meets the attack call condition; In response to the stack information satisfying an attack calling condition, it is determined that the class of the component is a class having an attack behavior.
3. The method according to claim 1, in, The characteristic information includes: a class loading address; and based on the characteristic information, determining whether the loaded class or the loading class has an attack behavior class includes: Determine whether a loading address of a class in the loaded class or the loading class is a remote address; In response to determining that the loading address of a class is a remote address, the class is determined to be a class with attack behavior.
4. The method according to claim 1, in, The characteristic information includes: class name; the class for judging whether the loaded class or the loading class has attack behavior based on the characteristic information includes: Determine whether the class name of a class in the loaded class or the loading class is empty; In response to determining that the class name of the class is not empty, determining whether the class name of the class includes a package name; In response to determining that the class name of the class does not include a package name, the class is determined to be a class with attack behavior.
5. The method according to claim 4, in, The step of judging whether the loaded class or the loading class has an attack behavior based on the feature information further includes: In response to determining that the class name of the class includes a package name, determining whether the class name of the class is in a blacklist; In response to determining that the class name of the class is in the blacklist, the class is determined to be a class with attack behavior.
6. The method according to claim 4, in, The step of judging whether the loaded class or the loading class has an attack behavior based on the feature information further includes: In response to determining that the class name of the class includes a package name, determining whether the class name of the class conforms to a dynamic web page script feature; In response to determining that the class name of the class meets the dynamic web page script feature, the class is determined to be a class with attack behavior.
7. A method for blocking aggressive behavior, the method include: In response to detecting a class with attack behavior in a loaded class in an application by the attack behavior detection method according to any one of claims 1 to 6, sending an alarm message to a server, wherein the application is running in a real-time application self-protection environment; In response to receiving the blocking instruction sent by the server, the class with attack behavior in the loaded classes is blocked.
8. The method according to claim 7, further comprising: include: In response to detecting that there is no class with attack behavior in the loaded classes of the application, detecting whether there is a class with attack behavior in the classes being loaded in the application; In response to detecting that a class having attack behavior is being loaded in the application, obtaining switch state information of a blocking switch; In response to the switch state information being in an open state, classes with attack behaviors among the classes being loaded are blocked.
9. An attack behavior detection device, the device include: a control unit configured to control the application to run in a real-time application self-protection environment; A feature acquisition unit is configured to acquire feature information of a loaded class or a loading class in the application in the real-time application self-protection environment; The characteristic information includes: the bytecode of the class; A judgment unit is configured to judge whether the loaded class or the loading class has a class with attacking behavior based on the feature information; the judgment unit is further configured to: simulate the execution process of the bytecode to obtain the execution result of the execution process; based on the execution result, judge whether the loaded class or the loading class has a class with attacking behavior; the judgment unit is further configured to: set a virtual virtual value for an unknown variable, simulate all JVM instruction operations in the bytecode, obtain the role played by the instructions between the virtual values, process the taint propagation data between variables based on the role, perform reasoning analysis of various reflection methods, judge whether there is a malicious method call or a suspicious reflection method call, and if there is a malicious method call or a suspicious method reflection call, obtain the execution result of the malicious method call or the suspicious method reflection call; The generating unit is configured to generate warning information in response to the judgment result that the class in the loaded class or the loading class has attack behavior.
10. An aggressive behavior blocking device, the device include: a sending unit configured to send an alarm message to a server in response to detecting a class with attack behavior in a loaded class in an application by the attack behavior detection device according to claim 9, wherein the application is running in a real-time application self-protection environment; The blocking unit is configured to block the class with attack behavior in the loaded class in response to receiving the blocking instruction sent by the server.
11. An electronic device, include: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.
12. A computer readable medium having a computer program stored thereon, in, When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
