The Power of Obfuscation Techniques in Malicious Javascript Code: a Measurement Study

The Power of Obfuscation Techniques in Malicious Javascript Code: a Measurement Study

The Power of Obfuscation Techniques in Malicious JavaScript Code: A Measurement Study Wei Xu, Fangfang Zhang and Sencun Zhu Department of Computer Science and Engineering The Pennsylvania State University, University Park Email:fwxx104, fuz104, [email protected] Abstract the detection of anti-virus software and to hide its malicious intent. JavaScript based attacks have been reported as the To better understand the usage of obfuscation tech- top Internet security threats in recent years. Since niques in malicious JavaScript code, we first survey most of the Internet users rely on anti-virus software the obfuscation techniques that have been observed in to protect themselves from malicious JavaScript code, the wild and categorize them based on the operations attackers exploit JavaScript obfuscation techniques to performed by these techniques. Then we conduct a evade the detection of anti-virus software. To better measurement study, in which we first analyze the understand the obfuscation techniques adopted by ma- statistics of the usage of different obfuscation tech- licious JavaScript code, we conduct a measurement niques by manually examining a set of real world study. We first categorize observed JavaScript obfusca- malicious JavaScript samples. Meanwhile, we also tion techniques. Then we conduct a statistic analysis study the effectiveness of different obfuscation tech- on the usage of different categories of obfuscation niques in evading popular anti-virus software. Based techniques in real-world malicious JavaScript samples. on the results of the measurement study, we are able We also study the detection effectiveness of 20 most to provide an in-depth analysis on the cause of the popular anti-virus software against obfuscation tech- popularity of obfuscation techniques among malicious niques. Based on the results, we analyze the cause of JavaScript code; the choice of obfuscation techniques the popularity of obfuscation in malicious JavaScript among malicious JavaScript code. code; the reason behind the choice of obfuscation We acknowledge that obfuscation techniques are not techniques and the difference between benign obfus- exclusive to malicious JavaScript code. For example, cation and malicious obfuscation. Moreover, we also we find some benign Web pages (e.g., the frontpage provide suggestions for designing effective obfuscation of yahoo.com) also use obfuscation to prevent code detection approaches in future. plagiarism. Therefore, we also discuss the difference between obfuscation techniques adopted by benign 1. Introduction JavaScript code and malicious JavaScript code in this paper. JavaScript based attacks have been reported as the The goal of this work is not to address the top Internet security threats in recent years [23]. By problem of detecting obfuscated malicious JavaScript exploiting numerous vulnerabilities in various Web code. However, we believe our results and analysis applications, attackers can launch a wide range of at- capture many characteristics of obfuscated malicious tacks such as cross-site scripting (XSS) [17], cross-site JavaScript code and therefore can be leveraged in request forgery (CSRF) [19], drive-by downloads [24], developing new detection approaches. etc. To defend against malicious JavaScript code, most The rest of the paper is organized as follows. Section Internet users rely on the anti-virus software. Unfor- 2 describes a categorization of obfuscation techniques. tunately, the effectiveness of static signature based Section 3 presents the results of our measurement anti-virus software is often thwarted by obfuscation study on the usage of obfuscation techniques and techniques. In fact, malicious JavaScript code has been the effectiveness of evading state of the art anti-virus increasingly applying obfuscation techniques to evade software. Section 4 presents our analysis, followed by function myfunction(txt) function var xs = "ite("; var lw = "lo w"; { _i23fdfcnj (_fdji230fdj) document.write(“Hello world”); alert(txt); //_32akfaj0ufa var ao = "doc"; var tc = "nt.wr"; } {// _dafaljfamfdn (a) var mystring = "Hello World!"; alert ( _fdji230fdj) ;//_dkfahajkla13 var zg = "orl"; myfunction(mystring); } var mv ="\"Hel"; var _dfeakia1f92 //_gcvdseaepk var rn = "d\")"; = "Hello World!"; //_gpqkjk3424pkl var dg = "ume"; _i23fdfcnj(_dfeakia1f92); var mystring=document; mystring. write (“Hello world”); eval(ao + dg + tc+ xs + mv + (a) (b) lw + zg + rn); (c) (b) Figure 1. An Example of Randomization Tech- niques.(a)is the original code and (b) is the obfus- cated ocde Figure 2. Examples of string data obfuscation. (a) is the original code; (b) uses string splitting obfuscation; (c) uses keyword substitution related work in Section 5. We conclude in Section 6. 2. Categorizing Observed Obfuscation Data Obfuscation: Data obfuscation is to convert Techniques in Malicious JavaScript Code a variable or a constant into the computational results of one or several variables or constants. Two data ob- fuscation techniques have been wildly applied to string In order to study the usage of obfuscation techniques object. One is string splitting. The other one is keyword in a more systematic way, we first classify the ob- substitution. String splitting is to convert a string into served obfuscation techniques into the following four the concatenation of several substrings. String splitting categories based on the operations performed by them. is usually used along with document.write() or eval() Randomization Obfuscation: Attackers may ran- functions to execute the concatenated strings in a domly insert or change some elements of JavaScript browser. Attackers could change the order of substrings codes without changing the semantics of the codes. and assign random variable names to them to make the Common techniques include whitespace randomiza- code even harder to understand. Another obfuscation tion [16], comments randomization and variable and approach is to use a variable to substitute JavaScript function names randomization. keywords. Examples are shown in Figure 2. Figure 2(a) Whitespace randomization is to randomly insert is the original code1. Figure 2(b) uses string splitting whitespace characters, including space character, tab, obfuscation, where substrings are in a random order line feed, form feed and carriage return, in JavaScript to make the code harder to understand and detect. code. Comments randomization randomly inserts arbi- Figure 2(c) uses keyword substitution, where keyword trarily created comments into JavaScript codes. These “document” is represented by variable “mystring”. two take the advantage of the fact that JavaScript in- Besides strings, numbers are another object of data terpreters ignore whitespace characters and comments. obfuscation. For example, i = 10 can be rewritten in Variable and function name randomization replaces many ways: i = 5 ∗ 2, i = 11 − 1 or i = 1000=100, variable names or function names by randomly created etc. strings with non-obvious meanings. Usually two or Encoding Obfuscation: Normally, there are 3 ways more randomization methods are used together to to encode original code. The first way is to convert improve the possibility of evading detections. Figure 1 the code into escaped ASCII characters, unicode or gives a demonstration of these two JavaScript obfus- hexadecimal representations. The second method uses cation techniques. Figure 1(a) is the original code and customized encoding functions, where attackers usu- Figure 1(b) is the obfuscated one. Strings highlighted ally use an encoding function to create the obfuscated by red rectangles are randomized variable names and code and attach a decoding function to decode it function names. Strings starting with “//” are com- during execution. Figure 3 shows an example using ments created randomly. Whitespace randomization hexadecimal representation to implement encoding. In generates line feed in the end of the first line between Figure 4, we give a simple example of how to ob- “function” and “ i23fdcnj”, tab in the second line fuscate JavaScript codes by customized encoding and between “ i23fdcnj” and “( fdji230fdj)”, etc. These two pieces of code have the exactly same semantics, 1. If not specified, we will use this code as the original code in but have different static patterns. all the following examples in this section var i = 111; var i =0; decoding functions: Figure 4(a) is the encoding func- i = i+1; for(i=0;i<=10000;i++) tion, which increases the Unicode of each character by if(i<10) { 1, where “document.write(‘Hello world!’)” is encoded { if(i==1) into “epdvnfou/xsjuf)(Ifmmp!xpsme(*”; Figure 4(b) is alart("Warning"); { } document.write('Hello world'); the obfuscated code, which first applies a decoding document.write('Hello world'); } function, and then executes the decoded instructions. i = i+1; } In addition, some standard encryption and decryption (a) (b) methods can be employed to do JavaScript obfuscation. Figure 5. Examples of logic structure obfuscation. For example, JScript.Encode is a method created by (a)inserts independent instructions; (b)uses addi- Microsoft to encode JavaScript code. It can be used to tional conditional branches. protect source code as well as to evade detection. eval("\x64\x6f\x63\x75\x6d\x65\x6e\x74\x2e\x77\x72\x69\x74\ x65\x28\x27\x48\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64\x21\ 3. Measurement Study x27\x29"); Figure 3. An example of obfuscation using hex- Given the categorization, we study the usage of adecimal representation. obfuscation in malicious JavaScript

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us