Botnet Reverse Engineering And Call Sequence Recovery

Transcription

BOTNET REVERSE ENGINEERING AND CALLSEQUENCE RECOVERYP ROSENJIT S INHAA THESISINT HE D EPARTMENTOFC OMPUTER S CIENCEP RESENTED IN PARTIAL F ULFILLMENT OF THE R EQUIREMENTSF OR THE D EGREE OF M ASTER OF C OMPUTER S CIENCEC ONCORDIA U NIVERSITYM ONTRÉAL , Q UÉBEC , C ANADAF EBRUARY 2011c P ROSENJIT S INHA , 2011

CONCORDIA UNIVERSITYSchool of Graduate StudiesThis is to certify that the thesis preparedBy:Prosenjit SinhaEntitled:Botnet Reverse Engineering and Call Sequence Recoveryand submitted in partial fulfillment of the requirements for the degree ofMaster of Computer Sciencecomplies with the regulations of the University and meets the accepted standards withrespect to originality and quality.Signed by the final examining committee:Dr. Adam KrzyzakChairDr. Terry FancottExaminerDr. Benjamin FungExaminerDr. Mourad DebbabiSupervisorApproved byChair of Department or Graduate Program DirectorDean of FacultyDateFebruary 17, 2011

AbstractBotnet Reverse Engineering and Call Sequence RecoveryProsenjit SinhaThe focus on computer security has increased due to the ubiquitous use of Internet.Criminals mistreat the anonymous and insidious traits of Internet to commit monetary online fraud, theft and extortion. Botnets are the prominent vehicle for committing onlinecrimes. They provide platform for a botmaster to control a large group of infected Internetconnected computers. Botmaster exploits this large group of connected computers to sendspam, commit click fraud, install adware/spyware, flood specific network from distributedlocations, host phishing sites and steal personal credentials. All these activities pose serious threat for individuals and organizations. Furthermore, the situation demands moreattention since the research and the development of underground criminal industry is fasterthan security research industry. To cope up against the ever growing botnet threats, securityresearchers as well as Internet-users need cognizance on the recent trends and techniquesof botnets. In this thesis, we analyze in-depth by reverse engineering two prominent botnets namely, Mariposa and Zeus. The findings of the analysis may foster the knowledge ofsecurity researchers in multiple dimensions to deal with the botnet issue. To enhance theabstraction and visualization techniques of reverse engineering, we develop a tool which isused for detailed outlook of call sequences.iii

AcknowledgmentsI would like to express my sincere gratitude to my supervisor Mourad Debbabi for hisguidance and help throughout the research work. He encouraged me patiently to achievemy research successfully and develop creative thinking. I am proud to get the opportunityto work with him. I would also like to acknowledge all my co-researchers at the NationalCyber-Forensics and Training Alliance (NCFTA) CANADA, for helping in my researchwith their technical expertise. Finally, I would like to thank my wife Arundhati Sinha andmy parrents for their constant love, support and encouragement, without which this workwould not be possible.iv

ContentsList of FiguresxList of TablesxiiiList of Acronyms12xvIntroduction11.1Motivations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21.2Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51.3Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61.4Thesis Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7Malware and Malware Analysis82.1Overview of Malware . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82.1.1Viruses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92.1.2Worms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.1.3Trojans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.1.4Rootkits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11v

2.1.52.22.32.42.5Botnets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Sophistication of Botnet Techniques . . . . . . . . . . . . . . . . . . . . . 202.2.1Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.2Polymorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.3Metamorphism . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.4Multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.2.5Stealth Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . 222.2.6Anti-analysis Techniques . . . . . . . . . . . . . . . . . . . . . . . 23Reverse Engineering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252.3.1Reversing Malicious Software . . . . . . . . . . . . . . . . . . . . 262.3.2Assembly Language . . . . . . . . . . . . . . . . . . . . . . . . . 272.3.3Basic x86 Architecture . . . . . . . . . . . . . . . . . . . . . . . . 27Miscellaneous Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.4.1File Fingerprinting . . . . . . . . . . . . . . . . . . . . . . . . . . 292.4.2AV Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.4.3String Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302.4.4Packer Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Reverse Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.5.1Static Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 312.5.2Live Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . 322.5.3Disassembler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.5.4Decompiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33vi

2.5.52.63Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Behavioral Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.6.1Registry Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . 372.6.2Process Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . 382.6.3File System Monitoring . . . . . . . . . . . . . . . . . . . . . . . 392.6.4InstallSpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402.6.5SysAnalyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402.6.6Network Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . 412.6.7Capture BAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412.6.8Sandboxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422.7Literature Review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432.8Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Reversing Mariposa Botnet463.1Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.2Behavioral Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493.33.2.1Environment setup . . . . . . . . . . . . . . . . . . . . . . . . . . 493.2.2Network Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 513.2.3Sandbox Analysis. . . . . . . . . . . . . . . . . . . . . . . . . . 54Dynamic Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.3.1De-obfuscation and Decryption . . . . . . . . . . . . . . . . . . . 583.3.2Anti-debugging traps in Mariposa . . . . . . . . . . . . . . . . . . 59vii

3.443.3.3Second Layer Decryption . . . . . . . . . . . . . . . . . . . . . . 623.3.4Code Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653.3.5Injected Thread Activity . . . . . . . . . . . . . . . . . . . . . . . 71Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.4.1Spreader Module . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.4.2Uploader and Downloader Modules . . . . . . . . . . . . . . . . . 793.5Functional diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803.6Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82Zeus Crimeware Analysis834.1Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 834.2Zeus components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854.2.1C&C Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 854.2.2Bot Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 864.3Network Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934.4Reverse Engineering of Zeus . . . . . . . . . . . . . . . . . . . . . . . . . 954.54.4.1Revealing De-obfuscation . . . . . . . . . . . . . . . . . . . . . . 974.4.2Code Injection and Installation . . . . . . . . . . . . . . . . . . . . 1014.4.3After-Injection Activity . . . . . . . . . . . . . . . . . . . . . . . . 103Key Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1044.5.14.6Automated Key Extraction . . . . . . . . . . . . . . . . . . . . . . 105Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106viii

5Control Flow Visualization5.1Low-level Program Comprehension . . . . . . . . . . . . . . . . . . . . . 1105.2Tracks: The Sequence Viewer . . . . . . . . . . . . . . . . . . . . . . . . 1115.361075.2.1Static Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . 1115.2.2Dynamic Control Flow . . . . . . . . . . . . . . . . . . . . . . . . 1125.2.3Navigation History . . . . . . . . . . . . . . . . . . . . . . . . . . 1145.2.4Diagram Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 1155.2.5Design and Implementation . . . . . . . . . . . . . . . . . . . . . 115Case Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1185.3.1Obfuscation and Decryption . . . . . . . . . . . . . . . . . . . . . 1205.3.2Injection Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225.3.3Injection Preparation . . . . . . . . . . . . . . . . . . . . . . . . . 1235.3.4Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1255.3.5After Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1255.4Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1265.5Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Conclusion1316.1Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1316.2Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Appendix135ix

List of Figures2.1Simple Autorun File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.2Typical IDA Pro Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352.3IDA Pro Graphical View . . . . . . . . . . . . . . . . . . . . . . . . . . . 362.4IDAStealth Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372.5Regshot Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382.6Process Explorer Interface . . . . . . . . . . . . . . . . . . . . . . . . . . 393.7Confined Environment Structure . . . . . . . . . . . . . . . . . . . . . . . 503.8Mariposa Bot Initialization Protocol . . . . . . . . . . . . . . . . . . . . . 523.9Mariposa Bot Liveness Protocol . . . . . . . . . . . . . . . . . . . . . . . 533.10 Mariposa Bot Action Protocol . . . . . . . . . . . . . . . . . . . . . . . . 543.11 Mariposa File System Activity By GFI Sandbox . . . . . . . . . . . . . . . 553.12 Mariposa Registry Activity By GFI Sandbox . . . . . . . . . . . . . . . . . 553.13 Mariposa Network Activity By GFI Sandbox . . . . . . . . . . . . . . . . 563.14 Mariposa Decryption Phases . . . . . . . . . . . . . . . . . . . . . . . . . 573.15 Unwanted Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583.16 First Decryption Routine . . . . . . . . . . . . . . . . . . . . . . . . . . . 59x

3.17 Stack Segment Register Trap in Mariposa . . . . . . . . . . . . . . . . . . 613.18 OutputDebugString Trap in Mariposa . . . . . . . . . . . . . . . . . . . . 623.19 Second Layer Decryption . . . . . . . . . . . . . . . . . . . . . . . . . . . 633.20 Pseudocode of Second Decryption Routine . . . . . . . . . . . . . . . . . 643.21 GetProcAddress Definition . . . . . . . . . . . . . . . . . . . . . . . . . . 643.22 Fourth Decryption Routine in Assembly . . . . . . . . . . . . . . . . . . . 663.23 Pseudocode of Fourth Decryption Routine . . . . . . . . . . . . . . . . . . 673.24 Pseudocode of String Decryption Routine . . . . . . . . . . . . . . . . . . 673.25 String Decryption Routine in Assembly . . . . . . . . . . . . . . . . . . . 683.26 Process Lookup Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . 703.27 Code Injection Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . 713.28 CreateRemoteThread Function Declaration . . . . . . . . . . . . . . . . . 713.29 Magic Word Encryption/Decryption . . . . . . . . . . . . . . . . . . . . . 743.30 Autorun.inf Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763.31 Hooking in Mariposa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773.32 P2P Registry Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783.33 Mariposa Functional Diagram . . . . . . . . . . . . . . . . . . . . . . . . 814.34 Zeus Crimeware Components . . . . . . . . . . . . . . . . . . . . . . . . . 864.35 Configuration File Contents . . . . . . . . . . . . . . . . . . . . . . . . . . 884.36 Webinject.txt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 914.37 Zeus Builder Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 924.38 Zeus Builder Interface (Cleaner) . . . . . . . . . . . . . . . . . . . . . . . 93xi

4.39 Zeus Communication Pattern . . . . . . . . . . . . . . . . . . . . . . . . . 964.40 Segments of Zeus Executable . . . . . . . . . . . . . . . . . . . . . . . . . 974.41 De-ofuscated Code in The Virutal Memory . . . . . . . . . . . . . . . . . 984.42 The 8-byte Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 994.43 The Virtual Memory Used By The Second De-obfuscation Routine . . . . . 1004.44 Second De-obfuscation Result . . . . . . . . . . . . . . . . . . . . . . . . 1014.45 Zeus String Decryption Pseudocode . . . . . . . . . . . . . . . . . . . . . 1014.46 Zeus URL Decryption Pseudocode . . . . . . . . . . . . . . . . . . . . . . 1024.47 Static Configuration Structure in Zeus Binary . . . . . . . . . . . . . . . . 1055.48 Function Call Graph in IDA Pro . . . . . . . . . . . . . . . . . . . . . . . 1095.49 Zoomed Function Call Graph in IDA Pro . . . . . . . . . . . . . . . . . . 1095.50 Tracks Static Call Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . 1125.51 Communications Between IDA Pro Plugin and Tracks . . . . . . . . . . . 1195.52 Loops And Cycles in Tracks . . . . . . . . . . . . . . . . . . . . . . . . . 1215.53 Decryption Loop in Tracks . . . . . . . . . . . . . . . . . . . . . . . . . . 1225.54 Finding Process in Assembly . . . . . . . . . . . . . . . . . . . . . . . . . 1235.55 Finding Process to Inject . . . . . . . . . . . . . . . . . . . . . . . . . . . 1245.56 Code Injection Traces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1255.57 Registry Manipulation Call Sequence . . . . . . . . . . . . . . . . . . . . 1285.58 C&C Server Communication Call Sequence . . . . . . . . . . . . . . . . . 129xii

List of Tables2.1IA-32 General Purpose Registers . . . . . . . . . . . . . . . . . . . . . . . 283.2Spreading Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755.3User Requirements for Control Flow . . . . . . . . . . . . . . . . . . . . . 1105.4IDA Pro and Tracks Comparison . . . . . . . . . . . . . . . . . . . . . . . 127xiii

List of Publications P. Sinha, A. Boukhtouta, V. Velarde, and M. Debbabi. Insights from the analysisof mariposa botnet. In Proceedings of the International Conference on Risks andSecurity of Internet and Systems (CRiSIS). IEEE Press, 2010. J. Baldwin, P. Sinha, M. Salois, and Y. Coady. Progressive user interfaces for regressive analysis: Making tracks with large, low-level systems. In Proceedings ofthe Australasian User Interface Conference (AUIC). Perth, Australia, 2011. H. Binsalleh, T. Ormerod, A. Boukhtouta, P. Sinha, A. Youssef, M. Debbabi, andL.Wang. On the analysis of the zeus botnet crimeware toolkit. Proceedings of theThe International Conference on Privacy, Security and Trust (PST). IEEE Press, 2010(Best Paper Award). T. Ormerod, L. Wang, A. Boukhtouta, M. Debbabi, A. Youssef, H. Binsalleeh, A.Boukhtouta, P. Sinha. Defaming botnet toolkits: A bottom-up approach to mitigating the threat. Proceedings of the International Conference on Emerging SecurityInformation, Systems and Technologies (SECURWARE). IEEE Press, 2010.xiv

List of AcronymsEPEntry PointDDoSDistribute Denial of ServiceSCADA Supervisory Control And Data AcquisitionPLCProgrammable Logic ControllerC&CCommand and ControlHTMLHyperText Markup LanguageHTTPHyper Text Transfer ProtocolIRCInternet Relay ChatUDPUser Datagram ProtocolIPInternet ProtocolP2PPeer-to-PeerDHTDistributed Hash TableSSLSecure Socket LayerFBIFederal Bureau of InvestigationICMPInternet Control Message ProtocolGUIGraphical User Interfacexv

USBUniversal Serial BusRCEReverse Code EngineeringCPUCentral Processing UnitLIFOLast-In-First-OutTFTrap FlagSDKSoftware Development KitAPIApplication Programming InterfaceDLLDynamic Link LibraryTCPTransmission Control ProtocolFTPFile Transfer ProtocolICEIn Circuit EmulatorDCIDirect Code InjectionMSNMicrosoft NetworkURLUniform Resource LocatorPOPPost Office ProtocolPHPHypertext PreprocessorNATNetwork Address TranslationPEPortable ExecutableDIVERDynamic Interactive Views for Reverse EngineeringXMLExtensible Markup LanguageVERAVisualization of Executable for Reversing and AnalysisIDEIntegrated Development Environmentxvi

Chapter 1IntroductionThe remarkable growth of the Internet technologies over the past few years changes thelifestyle of most people. The widespread use of the Internet has altered the pattern of theworld from simple household level to businesses. The traditional ways of marketing, communication, education, and broadcasting are replaced by web-based applications and onlinesystems. People in the 21st century are more akin to perform transactions online at theirown favorable hours. However, the Internet applications are mistreated by perpetrators andhackers for committing different kinds of crimes. The extensive use of Internet motivatesthe malicious activities which took place over the past several years. Formerly maliciousprograms have been classified as viruses, worms or Trojan horses based on their behaviors. Nowadays, rather than being in a specific group, malware is often versatile and evenequipped with multiple threats. In the majority of Internet mediated cybercrimes, the usedvictimization tactics vary from simple anonymity to identity theft and impersonation.1

The advent of botnets further exacerbates the situation. A botnet is a term that designates a network of autonomous software robots (bots) compromising computers which arecontrolled by a botmaster running a command-and-control center. Botnets have becomea severe threat to the Internet security by constituting an ideal platform of a wide varietyof cyber attacks targeting identity theft, spamming, Distributed Denial of Service (DDoS)extortion and so on [83]. For example, Mariposa botnet comprised of 13 millions infectedmachines is capable to perform DDoS extortions and identity theft operations. Althoughthe existence of botnets has been a known fact for a long time, the recent growth of cybercrimes and cyber-warfares mediated by botnets has attracted the attention of IT securityresearchers.As a result, a surge of interest has been expressed in understanding, analyzing, detecting, defaming, and preventing botnet attacks. In this context, the battle between hackers/cyber criminals and IT security experts takes the allure of a non-terminating cat andmouse fight. In order to counter the escalation of hackers’ ideas and innovations, securityexperts have to understand the threats and the employed technologies, and then design andimplement techniques to mitigate the risk underlying these threats.1.1MotivationsBotnets are the root cause of many cyber crimes. They impose a severe threat to Internetusers due to their central controlling capability over a huge number of infected machines2

distributed around the globe. As of October 2009, Zeus botnet is estimated to have infected 3.6 millions computers [8]. Botnets are the main weapons of the cyber criminalsto conduct money-making fraudulent activities. Such activities can be identified as spamdistribution, hosting phishing sites, identity theft, click fraud, DDoS extortions and distributing unwanted software. According to MessageLabs [115], the average spam rate forthe year 2010 is 89.1% and botnets account for 80-90% of all spams sent globally. Rustock [57], one of the dominant botnet, is solely responsible for sending 44 billions spamsper day in the latter half of 2010 with over one million bots under its control [115]. Botnetsare used extensively for distributing malware. In year 2009, 1 in 284.2 emails containingmalware [115].Botnets equipped with techniques like polymorphism, metamorphism, encryption, obfuscation and traffic encryption are hardly detectable by anti-viruses. With the help ofpolymorphic engine, botmaster can get a complete new version of the bot by a click of themouse. In 2009, Symantec observed 90,000 unique variants of basic Zeus toolkits [18].Mariposa bot toolkit comes with a built in polymorphic engine which enables botmaster tocreate encrypted bot code using different keys.Despite significant research on botnet detection, defence, and eradication, the problemstill persists in the Internet world. Bot writers constantly enrich their tools with new sophisticated techniques. For example, a new botnet URLZone [2] is capable to alter theonline bank statement so that the victim cannot detect that his money has been stolen. Zeusbotnet also has a similar capability of hiding transactions from the targeted web sites. Thecapabilities of the botnets reach such level that now, it targets Supervisory Control and3

Data Acquisition (SCADA) systems. According to Symantec Corporation, a botnet calledStuxnet [107] searches for industrial control systems which are also known as SCADAsystems. If it finds any SCADA systems running on the compromised computer, it tries tosteal code and design projects. It is also capable to take advantage of the programming software interface to upload its own code to the Programmable Logic Controllers (PLC) [107].Considering the sophistication of botnet capabilities, there is a desideratum to understandthe inner working of the new botnets. It is important to disclose the details of how botnetswork to help the security community in general to build better defense mechanisms.The two most prominent techniques for malware analysis are behavioral analysis andcode analysis. In behavioral analysis, the activities of the malware are examined by executing the malware in a controlled environment where they are observed with some specializedsoftware. Some of the commonly used software tools for behavioral analysis are CWSandbox [70], NormanSandbox [94] and Anubis [5]. The limitations of these tools are: 1) theycannot provide a fine-grained information of register and memory access, 2) they cannotuncover certain hidden behavior, and 3) they cannot give information about the used trafficand the binary encryption algorithms. On the other side, reverse code analysis involves converting machine code into human readable assembly code and then analyzing it. Reversecode analysis can be either static using a disassember1 or dynamic with the combination ofa debugger and a disassembler.Reverse engineering is complex and time-consuming particularly in obfuscated codebases involving malware. Currently the lack of modern visualization tools of assembly1 Disassembleris used to translate machine code into assembly code4

code further exacerbates this problem. Comprehension of low-level issues such as malwarethreats often relies on dated user interfaces that actually inhibit navigation and explorationof large code bases. These user interfaces often fail to exploit visualization techniques thatcould significantly alleviate cognitive overhead. For example, the ways IDA Pro [74] represents a call diagram is not helpful for the analyzer. Actually the diagram is static withno supported execution traces or external calls. Additionally, it does not support call traceand call ordering nor does it indicate if a call occurs more than once. An initial usability survey reveals that better analysis of control flow is particularly critical for programcomprehension in the malware domain [48].1.2ObjectivesThe purpose of the research is to find out the trends and the techniques used in botnetdomain to perpetrate online crimes. We also intend to find out techniques that can ease theprocess of reverse malware analysis. More precisely, the objectives of our research are asfollows: To discuss state-of-the-art techniques regarding malware and malware analysis forproviding details about the contemporary techniques of reverse engineering. To provide the reverse engineering findings of two prominent botnets namely, Mariposa and Zeus to explore the techniques that are used in current botnets. To design and develop a control flow visualization tool for the analysis of low-levelsystems. The tool is designed to reduce the cognitive overload inherent in malware5

comprehension.1.3ContributionsThe main contributions of the thesis consist of the reverse engineering findings of twoprominent botnets and the implementation of a low-level visualization tool. In more details,our contributions are as follows: The comparative study of the state-of-the-art techniques of malware and corresponding reverse malware analysis. The comprehensive reverse engineering results of Mariposa [108] and Zeus [52] botnets. The insights from this work are meant to illustrate the know-how used in currentbotnet technologies and enable the elaboration of analysis, detection and preventiontechniques. The design and the implementation of a tool for reverse engineering, which we namedTracks [48]. Tracks works as a plugin of IDA Pro and supports the reverse anal-ysis process by facilitating and providing visual issues like navigation history anddynamic call sequences. Our tool demonstrates how improved user interfaces canleverage visualization techniques.6

1.4Thesis OrganizationThe rest of the Thesis is organized as follows. We present an overview of botnets and acomparative study of reverse engineering techniques together with the current literature inChapter 2. Using reverse engineering, we analyze Mariposa and Zeus botnets and presentthe findings in Chapter 3 and Chapter 4 respectively. In Chapter 5, we present the designand the implementation of the proposed visualization tool. Concluding remarks as well asa discussion of future works are reported in Chapter 6.7

Chapter 2Malware and Malware AnalysisWe present an overview of malware and its counterpart malware analysis. In the first partof this chapter, we introduce the various types of malicious software focusing primarilyon botnets. Then, we discuss the sophisticated techniques that are used in new types ofmalware to achieve their nefarious functionalities. At the end, we talk about different techniques of malware reverse engineering including behavioral analysis, static and live codeanalysis. We also converse about anti-debugging tricks that are generally used by malwarewriters to make the debugging process strenuous. Moreover, we present a literature reviewon related topics at the end of the chapter.2.1Overview of MalwareMalicious code is fragments of programs that can affect the confidentiality, the integrity,the data, control flow, and the functionality of a system without the explicit knowledge and8

the consent of the user [56]. Malware can get access to the compromised machine, andsend back important information to the malware controller. Over the time, the motivationof malware changes from fun to multi-million dollar business. In the early stage of thepersonal computer era, computer viruses were created for fun and to show the programmingskills. First malicious virus, namely Brain [116], appeared after the appearance of personalcomputers in 1986. Brain infects the boot sector of the floppy drive and propagates whena user boots a machine from the infected floppy. Two years after the appearance of Brain,another worm called Morris [105] infected 6000 computers. Highly propagating worms withvarious spreading mechanisms were seen in mid to late 90s. This is the time when Internetand personal computers were getting their popularity, and people started to use electronicmail system as a mean of communication. Worms like Melissa [69], i love you [85], AnnaKurnikova [65], SoBig [120] and Mydoom [90, 114] spread via electronic system in that era.The online financial transaction boom in the business world in the late 90s changed thegoals of malware writers such that to focus on organized and coordinated financial attacks.As a result, malware like Trojans, backdoors and botnets came to effect. Criminals are nowmore inclined to use controlled and combined power of botnets that spreads all over theglobe to earn money. In the following, we present a brief description of some prominentforms of malwares.2.1.1 VirusesIn IT world, the term "virus" is generally used to refer all types of malware. Viruses areself-replicating malware that can replicate itself for spreading purposes and run in the host9

machine for the intent of malicious activities. Viruses are the primitive form of malware.Viruses first appeared in 1970 in ARPANET [6]. When the computer networking is in itschildhood state, most viruses spread via removable devices mainly floppy disks. Someviruses spread by infecting executables and others by infecting boot sectors. Th

botnet reverse engineering and call sequence recovery prosenjitsinha a thesis in the department of computer science presented inpartialfulfillment of therequirements for thedegree ofmaster ofcomputer science concordia university montrÉal,quÉbec,canada february 2011 c prosenjitsinha, 2011