Abstract:
A computer program includes one or more computer program instructions, each computer program instruction being of one or more instruction types. Prior to execution of the computer program instructions, the computer determines respective counts for the instruction type(s) of the computer program instructions. At a time during execution of the computer program instructions, the computer determines respective counts for the instruction type(s) of the computer program instructions. The computer, in response to determining that the count for one of the instruction types determined prior to execution differs a predetermined amount from the count for the same instruction type determined during execution, makes a record that the computer program has an indicia of maliciousness.

Description:
FIELD OF THE INVENTION 
       [0001]    The present invention relates generally to detecting a malicious computer program, and more particularly to detecting malicious program instructions that are hidden in the program. 
       BACKGROUND 
       [0002]    Many computer viruses and other malware can be detected by scanning for a signature pattern of bits associated with the malware. Among the ways viruses and other types of malware are designed to escape detection by virus scanner software is to obfuscate or scramble their malicious code into an unrecognizable format within a stored executable program module. Then, as the program is actively executing, the scrambled code is unscrambled by itself into executable code so that the CPU can execute the code. For example, different parts of a sequence of malicious instructions can be scattered and fragmented in the program in an inoperable and unrecognizable form prior to execution, and repositioned and combined during execution so they become operable. This technique is referred to as virus obfuscation. The obfuscated virus can be designed so that it may take several executions of the program module before the malicious code is fully assembled and ready for execution. An object of the present invention is to detect obfuscated malware. 
       SUMMARY 
       [0003]    Embodiments of the present invention provide a system, method, and program product to determine if a computer program in a memory of a computer is malicious. The computer program includes one or more computer program instructions, each computer program instruction being of one or more instruction types. Prior to execution of the computer program instructions, the computer determines respective counts for the instruction type(s) of the computer program instructions. At a time during execution of the computer program instructions, the computer determines respective counts for the instruction type(s) of the computer program instructions. The computer, in response to determining that the count for one of the instruction types determined prior to execution differs a predetermined amount from the count for the one instruction type determined during execution, makes a record that the computer program has an indicia of maliciousness. 
         [0004]    In another embodiment, the step of making a record further includes, in response to determining that the count for one or more of the instruction types determined prior to execution differs a predetermined amount from the count for the one or more instruction type determined during execution, each of the one or more instruction types having an associated predetermined amount, making a record that the computer program has an indicia of maliciousness. 
         [0005]    In another embodiment, the step of determining during execution is performed at two or more times during execution of the computer program instructions. 
         [0006]    In yet another embodiment, the step of determining during execution is performed by a program routine that is called upon the execution of a computer program instruction of the type operating system interrupt generating program instruction. In certain embodiments, a program instruction of the type operating system interrupt generating program instruction is inserted into the computer program. 
         [0007]    In other embodiments, the predetermined amount is zero, or the predetermined amount is an integer greater than zero. 
         [0008]    In yet another embodiment, the computer, in response to determining that the count for one of the instruction types determined prior to execution differs a predetermined amount from the count for the one instruction type determined during execution, terminates or suspends execution of the program. 
     
    
     
       BRIEF DESCRIPTION OF THE SEVERAL VIEWS OF THE DRAWINGS 
         [0009]      FIG. 1  is a functional block diagram of a malware detection system in accordance with an embodiment of the present invention. 
           [0010]      FIG. 2  is a flowchart illustrating the steps of a pre-execution scanner module of  FIG. 1  in accordance with an embodiment of the present invention. 
           [0011]      FIG. 3  is a flowchart illustrating the steps of a run-time scanner module of  FIG. 1  in accordance with an embodiment of the present invention. 
           [0012]      FIG. 4  is a block diagram of hardware and software within the system of  FIG. 1 . 
       
    
    
     DETAILED DESCRIPTION 
       [0013]    Embodiments of the present invention will now be described in detail with reference to the accompanying drawings. 
         [0014]      FIG. 1  is a functional block diagram of a malware detection system  118  including a computing device  116  and a malware detection program  100 . The malware detection program  100  operates on untrusted program  102  in accordance with a preferred embodiment of the present invention to determine if untrusted program  102  contains malware. In the preferred embodiment, malware detection program  100  includes pre-execution scanner module  104 , run-time scanner module  106 , suspicious code handling routine  108 , program instructions of interest list  110 , pre-execution program instruction count table  112 , and run-time program instruction count table  114 , all installed and executing in computing device  116 . 
         [0015]    In preferred embodiments of the invention, computing device  116  can be a mainframe or mini computer, a laptop, tablet, or netbook personal computer (PC), or a desktop computer. In general, computing device  116  can be any programmable electronic device that has operating system functions capable of receiving and servicing interrupt requests from an actively running untrusted program  102 , a loader function to load a untrusted program  102 , and sufficient volatile memory to handle the software requirements of storing and running pre-execution scanner module  104 , run-time scanner module  106 , and suspicious code handling routine  108 , all as described in further detail below. 
         [0016]    Typically, untrusted program  102  is an application program. Untrusted program  102  may be downloaded from a server via a network and is loaded for execution into computer memory, for example, RAM  822 , from permanent storage, for example, tangible storage device  830 , by the load process of, for example, operating system  828 , of computing device  116  (see  FIG. 8 ). Untrusted program  102  typically results from having an executable module produced by a language compiler. Untrusted program  102  includes program instructions, typically machine instructions, and is loaded into memory for execution by the load and execute process of, for example, operating system  828 . In a preferred embodiment, untrusted program  102  is divided into different segments, such as code segments that contain executable machine instructions, and data segments that contain global and static program variables. 
         [0017]    Pre-execution scanner module  104 , the operation of which is explained in greater detail below with respect to  FIG. 2 , operates to populate pre-execution table  112  with counts of predetermined types of program instructions that might be found in the program before execution. Pre-execution table  112 , which is created as part of the program load process, contains entries for each of these types of program instructions, commonly referred to as op codes, included in program instructions of interest list  110 , which is also explained in greater detail below. When pre-execution scanner module  104  executes, it populates pre-execution table  112  with counts by instruction value of all program instructions in untrusted program  102 , prior to execution of any program instructions in the program, that are contained in program instructions of interest list  110 . In a preferred embodiment, a load and execute process of operating system  828  invokes pre-execution scanner module  104  when untrusted program  102  is loaded for execution, and before any program instructions in untrusted program  102  have been executed. 
         [0018]    Run-time scanner module  106 , the operation of which is explained in greater detail below with respect to  FIG. 3 , operates to populate run-time table  114  with counts of predetermined types of program instructions found in untrusted program  102  at certain times during its execution. Run-time table  114  is created as part of the program load process, and contains entries for each of the types of program instructions of interest as specified in program instructions of interest list  110 . Run-time scanner module  106  can execute at multiple times during the execution of untrusted program  102 , and during each execution of module  106 , populates run-time table  114  with the counts by instruction value of all program instructions in untrusted program  102 , counted at the time of execution of run-time scanner module  106 , that are contained in program instructions of interest list  110 . After run-time scanner module  106  completes a run-time count of instructions in untrusted program  102 , run-time scanner module  106  determines if there are significant differences between the pre-execution instruction counts contained in pre-execution table  112 , and the run-time instruction counts contained in run-time table  114 . Significant increases in run-time instruction counts over the pre-execution instruction counts could indicate that obfuscated malicious code may been unscrambled into executable code within untrusted program  102 . 
         [0019]    In a preferred embodiment, operating system  828  calls run-time scanner module  106  at the start of servicing of operating system interrupts generated by interrupt-generating program instructions. For example, the operating system interrupt routine that services interrupt-generating program instructions is modified to first call run-time scanner module  106  before addressing the actual reason the interrupt was generated, such as retrieving data from tangible storage device  830 . This is done because the untrusted program  102  tends to be “frozen” during the interrupt handling and presents a stable body of code from which to count program instructions. 
         [0020]    In other embodiments of the invention, pre-execution scanner module  104  inserts custom or “dummy” interrupt instructions into untrusted program  102  at regular intervals in the program code so as to cause system interrupts to allow run-time scanner module  106  to perform a scan on untrusted program  102  while it is executing. For example, a custom interrupt instruction can be a customized supervisor call (SVC) instruction on an IBM mainframe that is designed to always complete successfully, but is modified to call run-time scanner module  106  before successful completion. These custom interrupt instructions can be useful in the situation where the program module as written has few, or no, instructions that generate interrupts, or in situations where a high level of scanning is desired. The custom interrupt instructions can, for example, overlay existing instructions in untrusted program  102  at regular address intervals at load time, with the overlaid instructions saved into a save area. After a custom interrupt instruction has executed and run-time scanner module  106  has completed its scan of untrusted program  102 , the overlaid program instruction can, for example, be restored to its original location in untrusted program  102 , the program location counter in the program status word (PSW) can be rolled back to point to the location of the newly restored instruction, and program execution can resume. 
         [0021]    In certain embodiments, operating system  828  calls run-time scanner module  106  as part of the program exit and cleanup process. This has the advantage of obtaining a scan after all program instructions of untrusted program  102  have executed. The same as for scans performed during program execution, if significant increases are found in the end-of-program instruction counts over the pre-execution instruction counts, this could indicate that obfuscated malicious code may been unscrambled into executable code within untrusted program  102 . 
         [0022]    Run-time scanner module  106  calls suspicious code handling routine  108  when run-time scanner module  106  identifies a significant difference between the pre-execution instruction counts contained in pre-execution table  112 , and the run-time instruction counts contained in run-time table  114 . In a preferred embodiment, because a significant difference can indicate that new executable instructions have appeared in untrusted program  102  during execution, and that obfuscated malicious code may have been unscrambled within untrusted program  102 , a conservative approach is taken and suspicious code handling routine  108  immediately terminates execution of untrusted program  102  in accordance with the process and procedures of the computing system environment. Typically, a warning report or some other indication will also be generated indicating that suspicious code was found. In other embodiments, suspicious code handling routine  108  can, for example, log an entry in a warning report indicating that suspicious code was found, and return to normal execution of the program instructions, or suspend execution of the program instructions. Although suspicious code handling routine  108  is illustrated and described as a separate routine, suspicious code handling routine  108  can also, for example, be implemented as an integrated function within run-time scanner module  106 . 
         [0023]    In a preferred embodiment, program instructions of interest list  110  includes entries containing the instruction values of system defined machine instructions of interest. When untrusted program  102  is loaded into memory for execution by the load and execute process of operating system  828 , program instructions of interest list  110  is also loaded into memory. In a preferred embodiment, the program instructions of interest are defined at a system level, for example, by a system administrator, and at least include program instructions that can directly cause malicious harm in the computing environment. For example, the program instructions of interest typically will include program instructions related to input/output operations, such as those program instructions directed to disk writes. The program instructions of interest can be a subset of all available program instructions, or can be the entire set of available program instructions. 
         [0024]    While execution of an interrupt-generating instruction is needed for control to pass to run-time scanner module  106  for instruction count scanning, not every system defined program instruction of interest will necessarily generate a system interrupt. For example, the program instructions of interest may include certain privileged instructions that do not cause a system interrupt, certain non-privileged “sensitive” instructions that can directly result in malicious damage, or all program instructions in untrusted program  102 . An example of a sensitive instruction is the MOVE instruction, used by mainframe computers manufactured by International Business Machines Corporation (IBM), which can modify a restricted portion of system memory without creating an interrupt. Program instructions of interest list  110  would include the instruction value of the MOVE instruction, and both pre-execution table  112  and run-time table  114  would contain entries for the instruction value of the MOVE instruction. If a high degree of security is desired, program instructions of interest list  110 , and both pre-execution table  112  and run-time table  114 , can contain entries for every program instruction available in the computing environment. 
         [0025]      FIG. 2  is a flowchart illustrating the steps of pre-execution scanner module  104  of malware detection program  100  in accordance with a preferred embodiment of the present invention. As stated above, operating system  828  calls pre-execution scanner module  104  as part of the load and execute process of operating system  828  after a program has been loaded into memory for execution. In the preferred embodiment, after untrusted program  102  has been loaded into memory  822  of computing device  116 , along with program instructions of interest list  110 , pre-execution scanner module  104  reads the program header information to identify the locations of the program segments to be scanned in untrusted program  102  (step  202 ). In a preferred embodiment, pre-execution scanner module  104  scans all code segments and data segments of untrusted program  102 , as these typically are the program segments that an executing program is allowed to modify. In other embodiments of the invention, additional segment types may be scanned. In a preferred embodiment, after the program segments to be scanned are identified, pre-execution scanner module  104  sets a scan address pointer to the first byte of the first program module to be scanned, and begins scanning untrusted program  102  two bytes at a time (step  204 ). In the preferred embodiment, such as an embodiment in which computing device  116  is a mainframe computer, a machine instruction value can be either one or two bytes long. In order to insure that pre-execution scanner module  104  can detect the longest instruction value that might be contained in the scanned bytes, two bytes at a time a read. In general, any length of bytes can be read, as may be determined by the maximum instruction length for the computing environment in which the embodiment is implemented. 
         [0026]    After two bytes of a code or data segment of untrusted program  102  have been read (step  204 ), pre-execution scanner module  104  compares the two bytes to program instruction values in program instructions of interest list  110  to determine if the first byte or the combined first and second bytes match any one-byte or two-byte program instruction values contained in the entries of program instructions of interest list  110  (decision  206 ). If there is a match between the first byte or combined first and second byte value to an entry in program instructions of interest list  110 , then pre-execution scanner module  104  increments by one the instruction count value of the corresponding program instruction entry in pre-execution table  112  (step  208 ). 
         [0027]    In other embodiments, the entries in program instructions of interest list  110  are not limited to only instruction values. For example, certain entries in list  110  can be instruction values followed by specific instruction operand values. In these embodiments, the number of bytes read by pre-execution scanner module  104  (step  204 ) would need match the longest entry in list  110 . 
         [0028]    After pre-execution scanner module  104  has incremented the instruction count value of the corresponding program instruction entry in pre-execution table  112  (step  208 ), or no match was found between the first byte or the combined first and second byte value and any one-byte or two-byte program instruction values contained in the entries of program instructions of interest list  110  (decision  206 ), pre-execution scanner module  104  determines if all program segments to be scanned have been scanned (decision  210 ). If all program segments have not been scanned, then pre-execution scanner module  104  advances the scan address pointer by one byte (step  212 ) and begins a scan on the two bytes located at the new scan pointer address (step  204 ). In a preferred embodiment, after the last byte of a program segment has been scanned, the scan address pointer is advanced to the address of the first byte of the next program segment to scan. If pre-execution scanner module  104  determines that all program segments to be scanned have been scanned (decision  210 ), then pre-execution scanner module  104  ends execution. 
         [0029]      FIG. 3  is a flowchart illustrating the steps of run-time scanner module  106  of  FIG. 1  in accordance with an embodiment of the present invention. As stated above, in a preferred embodiment, operating system  828  calls run-time scanner module  106  at the start of servicing of operating system interrupts generated by interrupt-generating program instructions. When called, run-time scanner module  106  first clears all instruction count values in run-time table  114  (step  302 ). In the same manner as the execution of pre-execution scanner module  104 , run-time scanner module  106  then scans certain program segments in untrusted program  102  and determines a count by instruction value, which is stored in run-time table  114 . 
         [0030]    After the instruction counts have been cleared (step  302 ), run-time scanner module  106  reads the header information in untrusted program  102  to identify the locations of the program segments to scan in untrusted program  102  (step  304 ). Run-time scanner module  106  then sets a scan address pointer to the first byte of the first program module to be scanned, and begins scanning untrusted program  102  two bytes at a time (step  306 ). 
         [0031]    After two bytes of a code or data segment of untrusted program  102  have been read (step  306 ), run-time scanner module  106  compares the two bytes to program instruction values in program instructions of interest list  110  to determine if the first byte or the combined first and second bytes match any one-byte or two-byte program instruction values contained in the entries of program instructions of interest list  110  (decision  308 ). If there is a match between the first byte or combined first and second byte value to an entry in program instructions of interest list  110 , then run-time scanner module  106  increments by one the instruction count value of the corresponding program instruction entry in run-time table  114  (step  310 ). 
         [0032]    After run-time scanner module  106  has incremented the instruction count value of the corresponding program instruction entry in run-time table  114  (step  310 ), or no match was found between the first byte or the combined first and second byte value and any one-byte or two-byte machine instruction values contained in the entries of program instructions of interest list  110  (decision  308 ), run-time scanner module  106  determines if all program segments to be scanned have been scanned (decision  312 ). If all program segments have not been scanned, run-time scanner module  106  advances the scan address pointer by one byte (step  314 ) and begins a scan on the two bytes located at the new scan pointer address (step  306 ). In a preferred embodiment, after the last byte of a program segment has been scanned, the scan address pointer is advanced to the address of the first byte of the next program segment to scan. 
         [0033]    If run-time scanner module  106  determines that all program segments to be scanned have been scanned (decision  312 ), then run-time scanner module  106  performs a comparison of the values in run-time table  114  and pre-execution table  112  (decision  316 ). If there are differences between the pre-execution instruction counts and the run-time instruction counts, then run-time scanner module  106  determines if the differences exceed defined threshold values (decision  318 ). In a preferred embodiment, threshold values are based on the difference in instruction counts between the run-time instruction counts and the pre-execution instruction counts. 
         [0034]    Any increase in the total number of instructions between the pre-execution instruction counts and the run-time instruction counts could indicate that obfuscated malicious code may have been unscrambled into executable code within untrusted program  102 . However, there is the possibility that a program address location can be legitimately changed to a value that matches a program instruction value contained in program instructions of interest list  110 . For example, locations in data segments of untrusted program  102  may contain program variables that constantly change value as untrusted program  102  is executing. It is possible that at the time that an interrupt-generating program instruction executes and run-time scanner module  106  is called, a location in a program data segment of untrusted program  102  may happen to contain a value that matches a program instruction value contained in program instructions of interest list  110 . This is particularly true when comparing a location corresponding to the least significant byte of a program variable, which typically changes more often than the most significant bytes, to a one-byte program instruction value. This is because there are only 256 possible values for a one-byte instruction value, as opposed to over 65,000 possible values for a two-byte instruction value. 
         [0035]    A conservative approach is to define a threshold value of zero. For example, the threshold is compared to the difference in count values between the run-time total number of instructions and the pre-execution total instruction count, as determined by pre-execution scanner module  104 . If any run-time total instruction count, as determined during any iteration of the execution of run-time scanner module  106 , exceeds the pre-execution total instruction count, then the threshold of zero is exceeded (step  318 ). Suspicious code handling routine  108  is called (step  320 ), which will, for example, immediately terminate execution of untrusted program  102 . This approach may lead to an unacceptable level of false identifications of possible malicious code. 
         [0036]    An alternative approach that may lower the level of false identifications of possible malicious code is to set threshold values for total instruction counts by group or class of program instruction type. For example, program instructions in the instruction count tables  112  and  114  can be assigned to different classes, based on the likelihood that the program instruction will be present in malicious code. Instruction classes with higher likelihoods might be assigned lower threshold values above the pre-execution scan counts than instruction classes with lower likelihoods. After run-time scanner module  106  has scanned untrusted program  102 , total run-time counts by instruction class are determined. If the run-time total count for an instruction class exceeds the pre-execution total count for the class, the difference is compared to the appropriate threshold value (step  318 ) and if the threshold value is exceeded, then suspicious code handling routine  108  is called (step  320 ). Similarly, each instruction can be considered its own instruction type, and threshold values can be set on an instruction by instruction basis, or all instructions can be considered in the same class, and a threshold value for total instruction counts can be set. In other embodiments, each instruction can be of more than one instruction type, and the determination of whether to call suspicious code handling routine  108  can involve logical and arithmetic combinations of whether threshold values by instruction types are exceeded. In still other embodiments, threshold values can be determined based on percentages of instruction counts. 
         [0037]      FIG. 4  shows a block diagram of the components of a data processing system  800 ,  900 , such as computing device  116 , in accordance with an illustrative embodiment of the present invention. It should be appreciated that  FIG. 4  provides only an illustration of one implementation and does not imply any limitations with regard to the environments in which different embodiments may be implemented. Many modifications to the depicted environments may be made based on design and implementation requirements. 
         [0038]    Data processing system  800 ,  900  is representative of any electronic device capable of executing machine-readable program instructions. Data processing system  800 ,  900  may be representative of a smart phone, a computer system, PDA, or other electronic devices. Examples of computing systems, environments, and/or configurations that may represented by data processing system  800 ,  900  include, but are not limited to, mainframe computer systems, personal computer systems, server computer systems, thin clients, thick clients, hand-held or laptop devices, multiprocessor systems, microprocessor-based systems, network PCs, minicomputer systems, and distributed cloud computing environments that include any of the above systems or devices. 
         [0039]    Computing device  116  includes internal components  800  and external components  900  illustrated in  FIG. 4 . Internal components  800  includes one or more processors  820 , one or more computer-readable RAMs  822  and one or more computer-readable ROMs  824  on one or more buses  826 , and one or more operating systems  828  and one or more computer-readable tangible storage devices  830 . The one or more operating systems  828  and programs  100  and  102  in computing device  116  are stored on one or more of the respective computer-readable tangible storage devices  830  for execution by one or more of the respective processors  820  via one or more of the respective RAMs  822  (which typically include cache memory). In the embodiment illustrated in  FIG. 4 , each of the computer-readable tangible storage devices  830  is a magnetic disk storage device of an internal hard drive. Alternatively, each of the computer-readable tangible storage devices  830  is a semiconductor storage device such as ROM  824 , EPROM, flash memory or any other computer-readable tangible storage device that can store a computer program and digital information. 
         [0040]    Internal components  800  also includes a R/W drive or interface  832  to read from and write to one or more portable computer-readable tangible storage devices  936  such as a CD-ROM, DVD, memory stick, magnetic tape, magnetic disk, optical disk or semiconductor storage device. The programs  100  and  102  in computing device  116  can be stored on one or more of the respective portable computer-readable tangible storage devices  936 , read via the respective R/W drive or interface  832  and loaded into the respective hard drive  830 . 
         [0041]    Internal components  800  also includes network adapters or interfaces  836  such as a TCP/IP adapter cards, wireless wi-fi interface cards, or 3G or 4G wireless interface cards or other wired or wireless communication links. The programs  100  and  102  in computing device  116  can be downloaded to computing device  116  from an external computer via a network (for example, the Internet, a local area network or other, wide area network) and network adapters or interfaces  836 . From the network adapters or interfaces  836 , the programs  100  and  102  in computing device  116  are loaded into hard drive  830 . The network may comprise copper wires, optical fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. 
         [0042]    External components  900  can include a computer display monitor  920 , a keyboard  930 , and a computer mouse  934 . External components  900  can also include touch screens, virtual keyboards, touch pads, pointing devices, and other human interface devices. Internal components  800  also includes device drivers  840  to interface to computer display monitor  920 , keyboard  930  and computer mouse  934 . The device drivers  840 , R/W drive or interface  832  and network adapter or interface  836  comprise hardware and software (stored in storage device  830  and/or ROM  824 ). 
         [0043]    Aspects of the present invention have been described with respect to block diagrams and/or flowchart illustrations of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer instructions. These computer instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. 
         [0044]    The aforementioned programs can be written in any combination of one or more programming languages, including low-level, high-level, object-oriented or non object-oriented languages, such as Java®, Cincom Smalltalk™, C, and C++. The program code may execute entirely on the user&#39;s computer, partly on the user&#39;s computer, as a stand-alone software package, partly on the user&#39;s computer and partly on a remote computer, or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user&#39;s computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). Alternatively, the functions of the aforementioned programs can be implemented in whole or in part by computer circuits and other hardware (not shown). 
         [0045]    Based on the foregoing, computer system, method and program product have been disclosed in accordance with the present invention. However, numerous modifications and substitutions can be made without deviating from the scope of the present invention. Therefore, the present invention has been disclosed by way of example and not limitation.