Summary of the invention
The embodiment of the invention provides a kind of event-handling methods and device and storage medium and electronic device.
According to one embodiment of present invention, a kind of event-handling method is provided, comprising: receive target detecting
In the case where event, the target information for receiving the subject thread of object event is obtained;Object event is judged using target information
Whether triggered by user's operation behavior;If it is, allowing the corresponding operation of subject thread performance objective event;If not,
Then forbid the corresponding operation of subject thread performance objective event.
Further, whether target information includes current stack information, judge object event by user using target information
Operation behavior is triggered, comprising: judges whether the current stack information of subject thread matches with default storehouse feature, wherein
Default storehouse feature is the feature extracted in the stack information for receiving the thread of user's operation behavior in advance;Wherein, such as
Fruit matching, it is determined that object event is triggered by user's operation behavior.
Further, after determining that object event triggered by user's operation behavior, this method further include: by target
Target collection is added in thread, wherein further includes true in the process of operating system and thread using preset rules in target collection
The active process and active thread made, preset rules include: the response message received for input equipment window interface
Thread is active thread, and the sub thread by the active thread creation in target collection is active thread, by the master in target collection
The subprocess of dynamic thread creation is active process, and the main thread by the active process in target collection is active thread;And
After judging whether the current stack information of subject thread matches with default storehouse feature, this method further include: if not
Match, then judge subject thread whether in target collection, wherein if subject thread is not in target collection, it is determined that target
Event is triggered by user's operation behavior.
Further, in the case where judging subject thread not in target collection, this method further include: to score
Whether journey recalls specified level, and judge the thread of each level in target collection, wherein if it is, object event is
It is triggered by user's operation behavior, if it is not, then object event is triggered by user's operation behavior.
Further, it in the case that the process in target collection or thread terminate, is deleted in target collection corresponding
Process or thread.
Further, before the target information for obtaining the subject thread for receiving object event, this method further include: benefit
Whether it is called with the objective function of Hook mechanism monitor operating system, wherein receive target if it is, determining to detect
Event.
Further, objective function is used to open file destination, and target information includes the requested power of invocation target function
Limit, before judging whether object event is triggered by user's operation behavior using target information, this method further include: judgement is adjusted
It whether include read right or write permission to the content of file destination with the requested permission of objective function, wherein if it is,
Judge whether object event is triggered by user's operation behavior using target information, if it is not, then subject thread is allowed to call mesh
Mark function.
Further, objective function is used to open file destination, is forbidding the corresponding behaviour of subject thread performance objective event
Before work, this method further include: judge whether file destination is dragged, replicate or paste, wherein if it is, allowing target
Thread dispatching objective function, if not, forbidding subject thread invocation target function.
Further, before judging whether object event is triggered by user's operation behavior using target information, the party
Method further include: judge whether object event is executed by specified bug code, wherein if it is, subject thread is forbidden to execute mesh
The corresponding operation of mark event, if it is not, then judging whether object event is triggered by user's operation behavior using target information.
According to another embodiment of the invention, a kind of event processing apparatus is provided, comprising: acquiring unit is used for
It detects in the case where receiving object event, obtains the target information for receiving the subject thread of object event;Judging unit,
For judging whether object event is triggered by user's operation behavior using target information;First execution unit, be used for if so,
Then allow the corresponding operation of subject thread performance objective event;Second execution unit, for if it is not, then subject thread is forbidden to hold
The corresponding operation of row object event.
According to still another embodiment of the invention, a kind of storage medium is additionally provided, meter is stored in the storage medium
Calculation machine program, wherein the computer program is arranged to execute the step in any of the above-described embodiment of the method when operation.
According to still another embodiment of the invention, a kind of electronic device, including memory and processor are additionally provided, it is described
Computer program is stored in memory, the processor is arranged to run the computer program to execute any of the above-described
Step in embodiment of the method.
Event-handling method provided in an embodiment of the present invention proposes a kind of technical solution of new event-handling method,
Judge whether the object event that receives is user's operation behavior, that is, to receive object event subject thread whether be
Active thread described in the embodiment of the present invention is judged, to take different processing plans according to the difference of judging result
Slightly, using from it is different in the prior art by the way of intercept event, solve to be likely to result in the related technology accidentally virus exist
The problem of malicious act on backstage is identified as the normal behaviour that user actively initiates and lets pass, and loses so as to cause user, reaches
Improve the effect of checking and killing virus accuracy rate.
Embodiment 1
Embodiment of the method provided by the embodiment of the present application one can mobile terminal, computer equipment, server or
It is executed in similar arithmetic unit.For running on a computing device, Fig. 1 is that a kind of computer of the embodiment of the present invention is set
Standby hardware block diagram.As shown in Figure 1, computer equipment may include one or more (only showing one in Fig. 1) processing
Device 102 (processing unit that processor 102 can include but is not limited to Micro-processor MCV or programmable logic device FPGA etc.) and
Memory 104 for storing data, optionally, above-mentioned computer equipment can also include the transmission device for communication function
106 and input-output equipment 108.It will appreciated by the skilled person that structure shown in FIG. 1 is only to illustrate, simultaneously
The structure of above-mentioned computer equipment is not caused to limit.For example, computer equipment may also include than shown in Fig. 1 more or more
Few component, or with the configuration different from shown in Fig. 1.
Memory 104 can be used for storing computer program, for example, the software program and module of application software, such as this hair
The corresponding computer program of event-handling method in bright embodiment, processor 102 are stored in memory 104 by operation
Computer program realizes above-mentioned method thereby executing various function application and data processing.Memory 104 may include
High speed random access memory, may also include nonvolatile memory, as one or more magnetic storage device, flash memory or its
His non-volatile solid state memory.In some instances, memory 104 can further comprise remotely setting relative to processor 102
The memory set, these remote memories can pass through network connection to mobile terminal 10.The example of above-mentioned network includes but not
It is limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Transmitting device 106 is used to that data to be received or sent via a network.Above-mentioned network specific example may include
The wireless network that the communication providers of computer equipment provide.In an example, transmitting device 106 includes a Network adaptation
Device (Network Interface Controller, referred to as NIC), can be connected by base station with other network equipments to
It can be communicated with internet.In an example, transmitting device 106 can for radio frequency (Radio Frequency, referred to as
RF) module is used to wirelessly be communicated with internet.
A kind of event-handling method for running on computer equipment is provided in the present embodiment, and Fig. 2 is according to the present invention
The flow chart of the event-handling method of embodiment, as shown in Fig. 2, the process includes the following steps:
Step 201, detect receive object event in the case where, obtain and receive the score of the object event
The target information of journey;
Step 202, judge whether the object event is triggered by user's operation behavior using the target information;
Step 203, if it is, allowing the corresponding operation of subject thread performance objective event;
Step 204, if it is not, then forbidding the corresponding operation of subject thread performance objective event.
Event can be triggered by operation behavior of the user to input equipment (for example, mouse, keyboard etc.), can also be by malice
Program triggering, in embodiments of the present invention, provides a kind of event-handling method, by whether judging the object event that monitors
For user's operation behavior initiate event, to determine whether the corresponding operation of performance objective event.
Event can drive operating system to execute certain service and function (operation), for example, event can be opening file,
It can be triggered by modes such as the one file triggering of user's left double click or draggings, opening file can be reading file attribute
Or file content or written document etc..
In embodiments of the present invention, object event refers to preassigned event, opens file as described above, due to
Family normal operating file or rogue program, which steal, destroys file requires to be first turned on file, therefore, implements by the present invention
When the method that example provides is applied to the field of protection data safety, it is possible to specify object event is the event for opening file.
Monitor whether that the concrete mode for receiving object event can be determined according to the case where specific needs and operating system.
For example, the corresponding message of object event can whether be received by monitor operating system to judge, if received pair
The message answered, determination monitors object event, if not receiving corresponding message, determination does not monitor object event.
For another example, the corresponding operation of specified object event usually requires to call the function (service) of providing to operating system,
In turn, objective function (the object event needs of Hook (hook) mechanism monitor operating system of operating system offer are provided
The function of the operating system of calling) whether it is called, if monitoring that objective function is called, it is determined that receive target thing
Part.
For example, by object event be open file for, can with the api function NtCreateFile of Hook operating system,
NtOpenFile etc., to intercept the event for opening file.
It should be noted that Hook mechanism is a kind of monitoring method, the behavior of invocation target function can be intercepted, and is adjusted
With filter function predetermined, in embodiments of the present invention, filter function is used to judge to receive the score of object event
Whether journey is active thread, if it is, allowing the corresponding operation of subject thread performance objective event, if it is not, then forbidding mesh
The corresponding operation of graticule journey performance objective event.
Subject thread refers to the thread for receiving object event.Thread is the minimum unit that program executes stream, is in process
An entity.Detect receive object event in the case where, obtain receive object event subject thread target
Information.Target information may include the stack information of subject thread, for permission of object event request etc..
When judging whether object event is triggered by user's active operation behavior, the user collected in advance can use actively
The feature that the thread stacks information (call stack information) of operation behavior extracts is matched with subject thread stack information.
Specifically, collecting the stack information for receiving the thread of user's operation behavior in advance, the feature of stack information is extracted,
And extract the key element of stack information: such as storehouse calls serial number, module name, function name, function offset, sums up formatting
Data, be stored in storehouse feature database.The formation of storehouse feature database may include manually participating in.
It is matched using each storehouse feature in storehouse feature database with the current stack information of subject thread, if mesh
The current stack information of graticule journey matches with any default storehouse feature in storehouse feature database, it is determined that subject thread is main
Moving-wire journey.
In embodiments of the present invention, a kind of concept for becoming " active thread " is proposed, to use householder for indicating to exist
The thread of dynamic operation behavior, in addition, active thread can also include by there are the threads of user's active operation behavior to be created
Once the response message for input equipment window interface was received in the main thread and operating system of sub thread or subprocess
Thread.It should be noted that active thread is not equal to main thread, main thread typically refers to stand when a process is created
A thread of operation is carved, and active process defined in the embodiment of the present invention is related with user's active operation behavior.
In turn, if any default storehouse feature in the current stack information and storehouse feature database of subject thread not
Match, can continue with subject thread whether be by active thread creation sub thread or by active thread creation son into
Whether the main thread and thread of journey, which received for modes such as the response messages of input equipment window interface, is continued to judge mesh
Whether graticule journey is active thread.
A kind of optional implementation method is to establish and update target collection, includes known in operating system in target collection
Active thread and active process, specifically, after determining that subject thread is active thread using storehouse characteristic matching, by mesh
Graticule journey is added to target collection, and active process and active thread in operating system are determined using following rule:
1. receiving the thread for the response message of input equipment window interface is active thread;
2. the sub thread by the active thread creation in target collection is active thread;
3. the subprocess by the active thread creation in target collection is active process;
4. the main thread by the active process creation in target collection is active thread.
Wherein, rule 1. can message dispatch api function DispatchMessage be real by the way that Hook operating system is called
It is existing, in the case where determining that message dispatch api function returns to the response message for the input equipment window interface of subject thread,
Determine that subject thread is main moving-wire journey.
It 2., 3., 4. for rule, can be by creating the Basic API of process, thread in Hook operating system (such as
NtCreateUserProcess and NtCreateThreadEx) Lai Shixian.
Target collection is added in the active thread and active process determined according to above-mentioned four kinds of rules.That is, object set
Include the active process determined of above-mentioned four kinds of rules in conjunction, and after receiving object event, utilize any default heap
The successful active thread of stack characteristic matching.
It should be noted that if the stack information of subject thread and default storehouse feature mismatch, and subject thread exists
In target collection, then n (predetermined value) a level of subject thread is further recalled, if the thread of n level is all in target
In set, just finally determine that object event triggers (that is, subject thread is main moving-wire journey) by user's operation behavior, otherwise, such as
Fruit traces back to the thread of some level not in target collection, it is determined that object event is not triggered by user's operation behavior.
In the case where thering is process or thread to be moved to end in an operating system, judge whether in target collection, if it is,
Corresponding process or thread are deleted in target collection.
After judging object event by user's operation behavior triggering, allow subject thread performance objective event corresponding
Operation, otherwise, forbids the corresponding operation of subject thread performance objective event.Further, in performance objective event pair each time
After the operation answered, work log can recorde, and be sent to server-side for further analyzing.
Optionally, in order to accelerate the response speed to object event, treatment effeciency is improved, is judging mesh using target information
Before whether mark event is triggered by user's operation behavior, it can first judge object event whether by specifying bug code (such as
Shellcode it) executes, if it is judged that object event is executed by specified bug code, then executes and judged using target information
Whether object event is triggered by user's operation behavior, otherwise, it is determined that object event is executed by rogue program, not by with
Family operation behavior executes, and forbids the corresponding operation of performance objective event.
Event-handling method provided in an embodiment of the present invention proposes a kind of technical solution of new event-handling method,
Judge whether the object event that receives is user's operation behavior, that is, to receive object event subject thread whether be
Active thread described in the embodiment of the present invention is judged, to take different processing plans according to the difference of judging result
Slightly, using from it is different in the prior art by the way of intercept event, solve to be likely to result in the related technology accidentally virus exist
The problem of malicious act on backstage is identified as the normal behaviour that user actively initiates and lets pass, and loses so as to cause user, reaches
Improve the effect of checking and killing virus accuracy rate.
It is used to handle the opening text in Windows operating system with event-handling method provided in an embodiment of the present invention below
The process of the scene of part event is specifically described as follows:
In a first aspect, illustrating the foundation/renewal process in stacked data library: being collected into the thread of user's normal operating file
Stack information extracts Partial key element therein, such as storehouse calls serial number, module name, function name, function offset, and
It is formatted, summarizes storehouse feature using the key element of formatting.After obtaining storehouse feature, storehouse feature is added
Library, there are many storehouse features of user's active operation behavior for storage in storehouse feature database.
Second aspect illustrates active process, foundation/renewal process of sets of threads: in turn, as shown in figure 3, using as follows
Rule determines whether thread is main moving-wire journey:
1. the message dispatch api function DispatchMessage that Hook operating system is called, receives for input equipment
The thread of the response message of window interface is active thread;
2. Hook operating system creates the Basic API such as NtCreateThreadEx of thread, by active process, sets of threads
In the sub thread of active thread creation be active thread;
3. Hook operating system creates the Basic API such as NtCreateUserProcess of process, by active process, thread
The subprocess of active thread creation in set is active process;
4. Hook operating system creates the Basic API such as NtCreateThreadEx of thread, by active process, sets of threads
In the main thread of active process creation be active thread.
In addition, as shown in figure 3, further include the thread using storehouse feature database successful match in active process, sets of threads,
Specifically, specified event is intercepted, for example, api function NtCreateFile, NtOpenFile etc. of Hook operating system, to block
Cut the event for opening file, obtain the stack information of thread, and with any one storehouse characteristic matching in storehouse feature database at
In the case where function, determine that thread is main moving-wire journey, and active process, sets of threads is added.
The third aspect illustrates the process that monitoring is opened the event of file and handled, as shown in Figure 4:
Using Hook intercept operating system provide open file service api function such as NtCreateFile,
NtOpenFile etc. before calling the service for opening file, is intercepted and captured when there is the event for opening file to occur and is opened file event
Relevant information, the stack information of permission including request and corresponding thread (including current API Calls procedural information).
If it is determined that the permission of request does not include the permission that reads or writes of demand file content, then allows to execute and opens file,
If it is determined that the permission of request includes the permission that reads or writes of demand file content, then first judge whether the event is shellcode
Execute, if it is, forbid open file, if it is not, then judge opening file event whether by user's active operation
Behavior is triggered, that is, judgement receives and opens whether the thread of file event is main moving-wire journey.
When judging whether opening file event is triggered by the operation behavior of user's active, using in storehouse feature database
Each storehouse feature is matched with the stack information for the thread for opening file, if there is the storehouse feature of successful match, then
It determines that thread is main moving-wire journey, that is, opening file is user's active operation behavior, allows to open file and otherwise judge thread
Whether in active process, sets of threads.If it is judged that whether thread is in active process, sets of threads, it is also necessary to recall
Specified level, verifies each layer line journey of backtracking whether in active process, sets of threads, if, it is determined that based on thread
Moving-wire journey.
If current thread is not active thread, or the thread for any level recalled is not active thread, into one
Step judges whether file is dragged, duplication or pastes, if it is, determine that opening file is user's active operation behavior, it is no
Then, it prevents to execute to open file.
Further, when forbidding opening file each time, recoding daily log, and server-side is sent to for further
Analysis.
Through the above description of the embodiments, those skilled in the art can be understood that according to above-mentioned implementation
The method of example can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but it is very much
In the case of the former be more preferably embodiment.Based on this understanding, technical solution of the present invention is substantially in other words to existing
The part that technology contributes can be embodied in the form of software products, which is stored in a storage
In medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, calculate
Machine, server or network equipment etc.) execute method described in each embodiment of the present invention.
Embodiment 2
A kind of event processing apparatus is additionally provided in the present embodiment, and the device is for realizing above-mentioned event-handling method
Embodiment and optional embodiment, the descriptions that have already been made will not be repeated.As used below, term " module " can be with
Realize the combination of the software and/or hardware of predetermined function.Although device described in following embodiment is preferably come with software real
It is existing, but the realization of the combination of hardware or software and hardware is also that may and be contemplated.
Fig. 5 is a kind of structural block diagram of optional event processing apparatus according to an embodiment of the present invention, as shown in figure 5, should
Device includes: acquiring unit 10, judging unit 20, the first execution unit 30 and the second execution unit 40.
Wherein, acquiring unit be used for detect receive object event in the case where, acquisition receive object event
The target information of subject thread;Judging unit is used to judge whether object event is touched by user's operation behavior using target information
Hair;First execution unit is used for if it is, allowing the corresponding operation of subject thread performance objective event;Second execution unit is used
In if it is not, then forbidding the corresponding operation of subject thread performance objective event.
Optionally, target information includes current stack information, and judging unit includes: first judgment module, for judging mesh
Whether the current stack information of graticule journey matches with default storehouse feature, wherein default storehouse feature is to receive in advance
The feature extracted in the stack information of the thread of user's operation behavior, wherein if it does, then determining that subject thread is actively
Thread.
Optionally, the device further include: adding module, for determining that object event is triggered by user's operation behavior
Later, target collection is added in subject thread, wherein further include the process using preset rules in operating system in target collection
With the active process and active thread determined in thread, preset rules include: to receive for input equipment window interface
The thread of response message is active thread, and the sub thread by the active thread creation in target collection is active thread, by target
The subprocess of active thread creation in set is active process, and the main thread by the active process in target collection is active line
Journey;And second judgment module, for judge in first judgment module subject thread current stack information and default storehouse
In the unmatched situation of feature, judge subject thread whether in target collection, wherein if subject thread is not in target collection
In, it is determined that object event is triggered by user's operation behavior.
Optionally, the device further include: backtracking module, for judging situation of the subject thread not in target collection
Under, specified level is recalled to subject thread;Third judgment module, for judging the thread of each level whether in target collection
In, wherein if it is, object event is triggered by user's operation behavior, if it is not, then object event is grasped by user
Make behavior to be triggered.
Optionally, the device further include: removing module, in target collection process or thread terminate the case where
Under, corresponding process or thread are deleted in target collection.
Optionally, the device further include: monitoring modular, for obtaining the score for receiving object event in acquiring unit
Before the target information of journey, whether it is called using the objective function of Hook mechanism monitor operating system, wherein if it is,
It determines to detect and receives object event.
Optionally, it is used to open file destination in objective function, target information includes the requested power of invocation target function
In the case where limit, the device further include: the 4th judgment module, for judging that object event is using target information in judging unit
It is no triggered by user's operation behavior before, judge whether the requested permission of invocation target function includes in file destination
The read right or write permission of appearance, wherein if it is, judging object event whether by user's operation behavior institute using target information
Triggering, if it is not, then allowing subject thread invocation target function.
Optionally, in the case where objective function is used to open file destination, the device further include: the 5th judgment module,
For before forbidding the corresponding operation of subject thread performance objective event, judging whether file destination is dragged, duplication or viscous
Patch, wherein if it is, allowing subject thread invocation target function, if not, forbidding subject thread invocation target function.
Optionally, the device further include: the 6th judgment module, for using target information judge object event whether by
Before user's operation behavior triggers, judge whether object event is executed by specified bug code, wherein if it is, forbidding
The corresponding operation of subject thread performance objective event, if it is not, then judging whether object event is grasped by user using target information
Make behavior to be triggered.
Event processing apparatus provided in an embodiment of the present invention judges whether the object event received is user's operation row
For, that is, whether be that active thread described in the embodiment of the present invention judges to the subject thread for receiving object event,
To taking different processing strategies according to the difference of judging result, using from it is different in the prior art by the way of intercept thing
Part solves the malicious act being likely to result in the related technology Wu by virus on backstage and is identified as the normal of user's active initiation
Behavior and let pass, so as to cause user loss the problem of, achieved the effect that improve checking and killing virus accuracy rate.
It should be noted that above-mentioned modules can be realized by software or hardware, for the latter, Ke Yitong
Following manner realization is crossed, but not limited to this: above-mentioned module is respectively positioned in same processor;Alternatively, above-mentioned modules are with any
Combined form is located in different processors.