PMASCE-Polymorphic and Metamorphic Shellcode Creation Engine
Total Page:16
File Type:pdf, Size:1020Kb
PMASCE-Polymorphic and Metamorphic Shellcode Creation Engine Navneet Kaur Popli1 Dr. Anup Girdhar2 10.25089/MERI/2017/v11/i1/164011 ABSTRACT Signature detection is ultimately going to be of no use in the future of AVs and IDS systems. The obfuscation of several parts of the exploit code is becoming so detailed that it could become almost impossible to uncover the various layers of obfuscation and reveal the actual malicious payload. In addition to obfuscation, there are sandbox evasion techniques being followed by attackers to hide from IDS if they try to study their behaviour in a simulated environment. Also, a worm may not attack in one go but in multiple stages, probably sending a small, innocent looking code first, which prepares the system for advance attacks. The worm may become polymorphic or metamorphic depending upon the attack complexity required. Polymorphic blending enables a worm to merge with normal traffic so well that anomaly-based IDS’ are unable to discern it from normal packets. To top it all, attackers are now able to create a M:N worm which means that a worm can have many signatures, many behaviours. This is done by changing the runtime behaviour of the shellcode. In this paper we propose an engine called PMASCE- Polymorphic and Metamorphic Shellcode Creation Engine. This engine enumerates all the steps which are required to be followed to create a strong polymorphic or metamorphic shellcode. This type of shellcode is created taking into account all the defence mechanisms carried out by the detection systems currently. Once all these steps are analysed, we aim to advance the research in IDS so that the existing IDS’ can be hardened to detect all malwares- polymorphic or metamorphic, employing all kinds of techniques of the present and the future. Key Words: Malware, IDPs, sandbox, polymorphic shellcodes, obfuscation, blending, metamorphism. 1. INTRODUCTION Malwares are as old as the computer softwares themselves. Whenever there is a new creation of a software utility, there is some malware creator in some part of the world creating a malware to attack that utility. Earlier malwares were created mostly 1. Navneet Kaur Popli: Research Scholar Tilak Maharashtra Vidyapeeth Pune, India 2. Dr. Anup Girdhar: CEO, Founder Sedulity Solutions and Technologies Delhi, India MERI Journal of Management and IT Vol. 11, No. 1, October, 2017 39 for fun. lately , however, the chief reason for malware creations has been profit, revenge, tarnishing image of the competitor, leaking military secrets of a rival country or stalling all work in organizations and asking for ransom. A cyberwar is continuously taking place and we are all affected by it in one way or the other. The way we invest our resources in the creation and maintenance of new softwares, in the same manner, resources must be invested for their protection as well. Earlier, attackers used basic tools to create simple malwares. The antiviruses and IDPS systems were designed to detect and mitigate them. Today attackers have started using sophisticated tools for creation of stealth malware. These use obfuscation techniques to evade the detection systems. Creating these complex malware is no longer a very difficult task. There are easily available engines which use various obfuscation techniques and many other algorithms to evade all types of detection mechanisms. Creation of complex malwares is a full-fledged industry and it is imperative that we deal with it in an organised manner. To catch a thief, you must think like one. Therefore, to detect and mitigate these untraced malwares, we must go into the detail of their creation. In this paper an engine is proposed. It is called PMASCE- Polymorphic and Metamorphic Shellcode Creation Engine. This engine details all the steps which are undertaken to create a very strong polymorphic and metamorphic shellcode. The aim of detailing all these steps is to know in detail the techniques of the attackers so that adequate steps can be taken to harden the antivirus and IDPS systems so that they can add more policies in their existing list so as to detect and mitigate these untraced malwares. 2. LITERATURE REVIEW Michalis Polychronakis and Kostas G. Anagnostakis[9] introduce a polymorphic shellcode detection system based on network level emulation. They say that all previous detection methods fail when one or more obfuscation methods are applied to shellcodes. Therefore, executing them in an emulated environment, helps in understanding their behaviour and thus in their early detection. X Li, PKK Loh, F Tan[14] explain the working of polymorphic and metamorphic engines which successfully create an obfuscated malware which is completely undetectable by the current detection systems. JM Borello, L Mé[15] study the detection of polymorphic and metamorphic static detection mechanism and prove that it is NP-complete. Crandall and Su[16] introduce a tool called DACODA. It is an execution tool for MERI Journal of Management and IT Vol. 11, No. 1, October, 2017 40 quantitative analysis polymorphic and metamorphic malwares based on some common predicates. They study fourteen exploits and based on their results conclude that multiple tokens instead of single contiguous byte sequences should be used for analysis; and one must focus on primitives rather than vulnerabilities. Babak Bashari Rad and Maslin Masrom[17] describe the evolution of malwares from non-stealth to polymorphic and metamorphic stealth malwares. They enumerate various obfuscation techniques and explain them to show how a non-stealth malware can be converted into a polymorphic and metamorphic malware. Y. Song and Michael E. Locasto[18] describe the limitations of the current signature based techniques for the detection of polymorphic malwares. They also provide quantitative and qualitative measures to gauge the capabilities, strengths and weaknesses of polymorphic engines. Tsung-Huan Cheng, Ying-Dar Lin [19] describe five common sandbox evasion techniques which polymorphic shellcodes use to escape the dynamic detection by antivirus softwares. Fogla and Sharif [20] show various techniques to match the network statistics of anomalous traffic with normal traffic by altering the byte sequences of malicious traffic. These techniques are also proved to be feasible. Balakrishnan and Schulze[21] survey various literature on code obfuscation and observe that the the same kind of techniques which are used for protection of software can also be carefully crafted to be used for conversion of a polymorphic code into metamorphic code. Many advanced techniques have also been devised by the hackers which are almost impossible to be detected by anti malware detection systems. 3. IDEA OF RESEARCH The idea of research is to understand the advanced techniques used by the attackers nowadays to create an engine which develops strong malwares. These malwares are capable of bypassing all the antivirus and IDPS systems of the present. However, the research is not an offensive one. The aim is not the creation of strong malwares, it is to create samples for the successful testing of anti-malware and IDPS systems so that if our samples bypass these, the resultant IDPS policies can be hardened and the systems can be upgraded to counter these new and advanced malwares. Thus, this research helps in the strengthening of anti-malware systems and policies. In this paper, the steps and processes to create a strong malware, are studied. The counter steps can be created for the entire process to fail these malwares. MERI Journal of Management and IT Vol. 11, No. 1, October, 2017 41 4. WORKING OF PMASCE Working of the PMASCE engine is divided into two parts- ‘Creation of polymorphic and metamorphic shellcodes’ and ‘Using the polymorphic shellcodes for attack’. When a hacker decides to create a shellcode for attacking a target machine, he must first find out a vulnerable program for injecting his shellcode into it. Then he must create a NOP zone so that the address pointer points to the shellcode. This NOP zone has to be obfuscated to avoid detection by anti malware softwares. Then the shellcode also has to be obfuscated to avoid detection. This process makes the shellcode polymorphic. Various techniques can be employed for it. The obfuscation of code can be performed either by applying code transformations or miscellaneous transformations. After creation of the complete shellcode and the host program which carries the shellcode, now is the time for attacking the target machine. The attack has to be carried out in multiple stages. First, information about the target system has to be acquired. After entering the system based on this information, privileges have to be escalated for the shellcode to get more malicious code in the target system. A back connection to the attacker is established to provide vital information to him. A c&c component is inserted into the target. The shellcode then gets transferred to the entire network to which the target machine is attached to. After that all system variables which have been changed following the attack are restored and the system and the network is presented in the same original position. Meanwhile, sandbox-evasion techniques are also applied so as to evade detection by continuous monitoring by the antivirus softwares. All the to and fro network traffic is blended with normal traffic so that it may not look anomalous. The polymorphic shellcode is also converted to metamorphic code while still in the target machine. 4.1. CREATION OF POLYMORPHIC AND METAMORPHIC SHELLCODES As shown in Figure 1, the creation of shellcode is broadly a two step process in which first a host program is created which has some vulnerability like buffer overflow. This is the code in which the shellcode is injected. These two programs together become the payload which attacks the target computer. Both these codes have to be obfuscated so become undetectable.