When we start to check the PDF files that exist in our Pc or Laptop we may use antivirus scanner but in this days it seems not good enough to detect malicious PDF that counties a shell code because, as attacker mostly encrypt it’s count -ant to bypass the antivirus scanner and in many times target a zero day vulnerability that exit in Adobe Acrobat reader or in updated version. Before we start analyze malicious PDF we going to have a simple look at PDF structures as to understand how the shell code work and where it locate.
PDF components
PDF Header The first line of pdf show the pdf format version the most important line that give to you the basic information of the pdf file for example “%PDF-1.4 means that file fourth version.
PDF Body The body pdf file consist of objects that compose contents of the document, these objects include fonts, images, annotations, text streams and user can put invisible objects or elements, this objects can interactive with pdf features like animation, security features. The body of the pdf supports two types of numbers (integers, real numbers).
The Cross-Reference Table (xref table) The cross- reference counties links of all objects and elements that exist on file format, you can use this feature to see other pages contents (when the users update the PDF the cross-reference table gets updated automatically).
The Trailer The trailer contains links to cross-reference table and always ends up with %%EOF to identify the end of a PDF file the trailer enables a user to navigate to the next page by clicking on the link provided.
Malicious PDF through Metasploit Now after we have talking a tour inside PDF file format and what it contains we will start to install old version of Adobe Acrobat reader 9.4.6 and 10 through to 10.1.1 that will be vulnerable to Adobe U3D Memory Corruption Vulnerability. This exploit are exist in Metasploit framework so we going to create the malicious PDF and analysis it in KALI Linux distribution. Start opens the terminal and type msfconsole. We going to setting some Metasploit variables to be sure that everything is working fine. *After choosing the exploit type we going to choose the payload that will execute during exploitation in the remote target and open Meterpreter session. The file has been saved on /root/.msf4/local.
So we going to move the file to Desktop for easier located by typing in the terminal root@kali :~# cd /root/.msf4/local root@kali :~# mv msf.pdf /root/Desktop
PDFid Now we going to use pdfid to see what the pdf continue of elements and objects and JavaScript and see if something interesting to analyze. The PDF has only one page maybe its normal. There are several JavaScript objects inside… this is very strange. There is also an OpenAction object which will execute this malicious JavaScript So we going to use peepdf.
Peepdf Peepdf its python tool very powerful for PDF analysis, the tool provide all necessary components that security researcher need in PDF analysis without using many tools to do that, it support encryption, Object Streams, Shellcode emulation, Javascript Analysis, and for Malicious PDF it Shows potential Vulnerabilities, Shows Suspicious Elements, Powerful Interactive Console, PDF Obfuscation (bypassing AVs), Decoding: hexadecimal – ASCII and HEX search.
Analysis If we going to start analysis go to the directory of the PDF file then start with syntax /usr/bin/peepdf–f msf.pdf. *choose the LHOST which is our IP address and we can view through typing ifconfig in new terminal *finally we type exploit to create the PDF file with configuration we created before
We use –f option to avoid errors and force the tool to ignore them. This the default output but we see some interesting things first one we see is the highlighted one object 15 continue JavaScript code and we have also one object 4 continue two executing elements (/AcroForm & /OpenAction) and the last one is /U3D showing to us Known Vulnerability for now we will start to explore this objects by getting an interactive console by typing syntax /usr/bin/peepdf –i msf.pdf
The tree commands shows the logical structure of the file, and starting explore object 4 (/Acro-Form). When we type object 4 it gave you another objects to explore for now we didn’t see any impotent information or seems suspicious except object 2 (XFA array) that gave us the element <fjdklsaj fodpsaj fopjdsio> and seems to us not continue something special. Let’s move to the another object (Open Action). Now we can see JavaScript code, that will be executed when the pdf file will be opened. The other part of the JavaScript code is barely obfuscated like writing some variables in hex and in this code we can see a heap spraying with shell code plus some padding bytes. The attackers typically use unicode to encode their shell code and then use the unescape function to translate the unicode representation to binary content (now we are sure that defiantly a malicious pdf)
Defend We defend our network from that type of malicious files by providing strong e-mail and web filter, IPS and by application control: disable JavaScript and Disable PDF rendering in browsers, Block PDF readers from accessing file system and Network resources. Security awareness.
|
ليست هناك تعليقات:
إرسال تعليق