JSunpack is a JavaScript unpacker from iDefense, created by Blake Hartstein. JSunpack blog lists all the latest updates and research on the tool for its users to be up-to-date on what is going on with the tool.
Sample post:
Friday, January 8, 2010
Jsunpack-n update 0.3.1c: Decoding and Functionality Updates
I just released a new version of jsunpack-n, this version has some great new features! First off, it handles new decoding techniques like PDF annots. What are Annots you ask? Well, its just like getElementByID but for PDF files. This allows exploit authors to store arbitrary content within a PDF file then access that content directly from javascript using the getAnnots() function. Similarly, attackers have been using the “this.info.title” variable also! This version of jsunpack-n supports both of these new obfuscation techniques.
I also added many improvements to PDF decoding and added a few new detection rules for new exploits. You will find that I’ve also added many new sample-* files for jsunpack-n users to test with and see what jsunpack-n is capable of.
IDEA: I’ve been considering creating an svn repository to store high volumes of pcaps and malicious samples … if there is interest contact me or let me know if you would find it valuable.
Updates 2010-01-08 version 0.3.1c
1) pdf improvements
1a) handling and decoding of pdf annots (see sample-pdf-annots.file)
1b) octal-based object decoding support
1c) handling of obfuscation for this.info.title (see sample-infoTitle.pcap)
2) graphing in verbose mode now displays all nodes rather than just malicious ones, increased node limit to 60
3) bug fix for gzip python library to better handle IOError case for ‘Not a gzipped file’
Posted by jsunpack at 8:20 AM 0 comments Links to this post
JSunpack-n is the network version of JSunpack, which helps the users run it locally. Most recent version JSunpack-n v0.3.1c, can be downloaded from: http://jsunpack.jeek.org/jsunpack-n.tgz. The following post from jsunpack blog explains more about jsunpack-n:
Sunday, June 7, 2009
Very Cool jsunpack-n release: JavaScript Decoding on the Network (The Future)
My favorite tools to decode JavaScript today are for security research and often have too little impact because administrators must find URLs, submit them for research, and it requires significant additional effort. There is no current way to detect threats against a real network using these tools in an automatic manner.
Until now! I started building a tool that is useful to administrators defending networks. The main difference is that it is a completely passive JavaScript decoder to perform Intrusion Detection, by processing network traffic (either an interface or pcap file), rather than URLs.
I built a basic implementation of this concept as a new version of “jsunpack-network” or (jsunpack-n). Some of the benefits of this technique are:
* Tracks streams and decodes Transfer and Content encodings of types chunked and gzip.
* Completely passive: Don’t need to worry about User-Agents, proxies, or other tricks that attackers use to prevent analysis
* Detect if an exploit is successful: the system monitors all URLs. It can determine if an exploit would fetch another URL and when the client requests that URL, the system knows that the exploit was successful.
The source code for this project is available from http://jsunpack.jeek.org/jsunpack-n.tgz. Here is an example output using the test file (included in the jsunpack-n.tgz archive):
$ ./jsunpack-n.py sample-http-exploit.pcap
DECODED JavaScript Data
exploit_watch append hxxp://hifgejig.cn/nuc/exe.php
The exploit_watch variable tracks all URLs to track if an exploit is successful and if it is, then the script prints the associated IP addresses and URLs:
print ‘Exploit Successful ‘, tcp.addr, ‘ from URL ‘, exploit_watch[host+url]
Since this project is very new, I expect there will be a few issues and therefore you run this at your own risk. I am releasing this code as alpha/unstable, because I think that there is a lot of opportunity to improve it.
Two of the areas that are completely lacking at this point are
* signature-based detection
* pdf decoding
I am releasing a PDF decoding script with this code, available in the jsunpack-n.tgz archive called “pdf.py”; however, I haven’t integrated it with jsunpack-n yet. While this should be a simple task, I’m still testing and improving the PDF decoding, as it now only handles a few of the decoding techniques I’d like it to support.
Please leave me your comments (good or bad), to improve the project. I haven’t fully integrated jsunpack’s algorithms yet (I will soon, I promise).
Posted by jsunpack at 4:23 PM
The 2009 presentation of JSunpack shmoocon slides is available here.
JSunpack also lists 20 most recently decodings & executables, which helps the users to know what others are seeing. If someone is seeing something interesting, you could also see it in here. An example of a successful executable is as shown below:
Sections ( .text .rdata .data .ndata .rsrc )
File: MS-DOS executable PE for MS Windows (GUI) Intel 80386 32-bit
Strings:Software\Microsoft\Windows\CurrentVersion
Strings:http://nsis.sf.net/NSIS_Error
Strings:.exe
Strings:Nullsoft Install System v2.39
Size: 163944 bytes,
MD5: ac0d49c97ca2f09cc941b07a4a0e86b1
Searching for the MD5 ac0d49c97ca2f09cc941b07a4a0e86b1, in the VirusTotal HashDatabase, gave the following result [to view the result in VirusTotal, click here]:
File d029d903058ce7c7d34d680107110e228 received on 2009.12.13 11:45:46 (UTC)
Antivirus Version Last Update Result
a-squared 4.5.0.43 2009.12.13 -
AhnLab-V3 5.0.0.2 2009.12.12 -
AntiVir 7.9.1.108 2009.12.11 DR/Click.Agent.exx
Antiy-AVL 2.0.3.7 2009.12.11 Trojan/Win32.Agent.gen
Authentium 5.2.0.5 2009.12.02 W32/Trojan2.JXSQ
Avast 4.8.1351.0 2009.12.12 Win32:Adware-gen
AVG 8.5.0.427 2009.12.13 Clicker.UHH
BitDefender 7.2 2009.12.13 Generic.Adw.Rotator.B35AD0F1
CAT-QuickHeal 10.00 2009.12.12 -
ClamAV 0.94.1 2009.12.13 Trojan.BHO-3774
Comodo 3228 2009.12.13 TrojWare.Win32.TrojanClicker.Agent.exx
DrWeb 5.0.0.12182 2009.12.13 Trojan.Click.28633
eSafe 7.0.17.0 2009.12.10 Win32.DRClick.Agent
eTrust-Vet 35.1.7171 2009.12.11 -
F-Prot 4.5.1.85 2009.12.12 W32/Trojan2.JXSQ
F-Secure 9.0.15370.0 2009.12.13 Generic.Adw.Rotator.B35AD0F1
Fortinet 4.0.14.0 2009.12.13 Adware/Agent
GData 19 2009.12.13 Generic.Adw.Rotator.B35AD0F1
Ikarus T3.1.1.74.0 2009.12.13 Virus.Win32.Agent.ABKG
Jiangmin 13.0.900 2009.12.13 Adware/Clicker.jez
K7AntiVirus 7.10.918 2009.12.11 Trojan-Clicker.Win32.Agent.exx
Kaspersky 7.0.0.125 2009.12.13 Trojan-Clicker.Win32.Agent.exx
McAfee 5830 2009.12.12 potentially unwanted program Generic PUP
McAfee+Artemis 5830 2009.12.12 potentially unwanted program Generic PUP
McAfee-GW-Edition 6.8.5 2009.12.13 Heuristic.LooksLike.Win32.Packed.C
Microsoft 1.5302 2009.12.13 Adware:Win32/AdRotator
NOD32 4683 2009.12.13 a variant of Win32/Adware.GooochiBiz
Norman 6.04.03 2009.12.12 -
nProtect 2009.1.8.0 2009.12.13 -
Panda 10.0.2.2 2009.12.13 Trj/Genetic.gen
PCTools 7.0.3.5 2009.12.12 Adware.Begin2search
Prevx 3.0 2009.12.13 High Risk Worm
Rising 22.25.06.05 2009.12.13 Trojan.Win32.Undef.quy
Sophos 4.48.0 2009.12.13 AdRotate
Sunbelt 3.2.1858.2 2009.12.13 Trojan.Win32.Generic!BT
Symantec 1.4.4.12 2009.12.13 Adware.Begin2search
TheHacker 6.5.0.2.092 2009.12.12 -
TrendMicro 9.100.0.1001 2009.12.13 -
VBA32 3.12.12.0 2009.12.12 Trojan-Clicker.Win32.Agent.glr
ViRobot 2009.12.12.2085 2009.12.12 Trojan.Win32.Clicker.163944
VirusBuster 5.0.21.0 2009.12.12 Adware.Adrotator.Gen.2
Additional information
File size: 163944 bytes
MD5 : ac0d49c97ca2f09cc941b07a4a0e86b1
SHA1 : d029d903058ce7c7d34d680107110e2289cde069
SHA256: 2336dc37474b4a15f7fb100bbd3666c93f57b4bc22561db47a2f7ce923f2423b
PEInfo: PE Structure information
( base data )
entrypointaddress.: 0×3225
timedatestamp…..: 0x48A737E7 (Sat Aug 16 22:26:15 2008)
machinetype…….: 0x14C (Intel I386)
( 5 sections )
name viradd virsiz rawdsiz ntrpy md5
.text 0×1000 0×5976 0x5A00 6.47 335c19bb25cd1d02eec2b0a4eacb979c
.rdata 0×7000 0×1190 0×1200 5.18 db16645055619c0cc73276ff5c3adb75
.data 0×9000 0x1AF98 0×400 4.69 59710519e577598f785044e4d95261f4
.ndata 0×24000 0xD000 0×0 0.00 d41d8cd98f00b204e9800998ecf8427e
.rsrc 0×31000 0×908 0xA00 3.96 36426195b15a54195dc60707ed8dd004
( 8 imports )
> advapi32.dll: RegQueryValueExA, RegSetValueExA, RegEnumKeyA, RegEnumValueA, RegOpenKeyExA, RegDeleteKeyA, RegDeleteValueA, RegCloseKey, RegCreateKeyExA
> comctl32.dll: ImageList_AddMasked, ImageList_Destroy, -, ImageList_Create
> gdi32.dll: SetBkColor, GetDeviceCaps, DeleteObject, CreateBrushIndirect, CreateFontIndirectA, SetBkMode, SetTextColor, SelectObject
> kernel32.dll: CompareFileTime, SearchPathA, GetShortPathNameA, GetFullPathNameA, MoveFileA, SetCurrentDirectoryA, GetFileAttributesA, GetLastError, CreateDirectoryA, SetFileAttributesA, Sleep, GetTickCount, CreateFileA, GetFileSize, GetModuleFileNameA, GetCurrentProcess, CopyFileA, ExitProcess, SetFileTime, GetTempPathA, GetCommandLineA, SetErrorMode, LoadLibraryA, lstrcpynA, GetDiskFreeSpaceA, GlobalUnlock, GlobalLock, CreateThread, CreateProcessA, RemoveDirectoryA, GetTempFileNameA, lstrlenA, lstrcatA, GetSystemDirectoryA, GetVersion, CloseHandle, lstrcmpiA, lstrcmpA, ExpandEnvironmentStringsA, GlobalFree, GlobalAlloc, WaitForSingleObject, GetExitCodeProcess, GetModuleHandleA, LoadLibraryExA, GetProcAddress, FreeLibrary, MultiByteToWideChar, WritePrivateProfileStringA, GetPrivateProfileStringA, WriteFile, ReadFile, MulDiv, SetFilePointer, FindClose, FindNextFileA, FindFirstFileA, DeleteFileA, GetWindowsDirectoryA
> ole32.dll: CoTaskMemFree, OleInitialize, OleUninitialize, CoCreateInstance
> shell32.dll: SHGetPathFromIDListA, SHBrowseForFolderA, SHGetFileInfoA, ShellExecuteA, SHFileOperationA, SHGetSpecialFolderLocation
> user32.dll: EndDialog, ScreenToClient, GetWindowRect, EnableMenuItem, GetSystemMenu, SetClassLongA, IsWindowEnabled, SetWindowPos, GetSysColor, GetWindowLongA, SetCursor, LoadCursorA, CheckDlgButton, GetMessagePos, LoadBitmapA, CallWindowProcA, IsWindowVisible, CloseClipboard, SetClipboardData, EmptyClipboard, RegisterClassA, TrackPopupMenu, AppendMenuA, CreatePopupMenu, GetSystemMetrics, SetDlgItemTextA, GetDlgItemTextA, MessageBoxIndirectA, CharPrevA, DispatchMessageA, PeekMessageA, DestroyWindow, CreateDialogParamA, SetTimer, SetWindowTextA, PostQuitMessage, SetForegroundWindow, wsprintfA, SendMessageTimeoutA, FindWindowExA, SystemParametersInfoA, CreateWindowExA, GetClassInfoA, DialogBoxParamA, CharNextA, OpenClipboard, ExitWindowsEx, IsWindow, GetDlgItem, SetWindowLongA, LoadImageA, GetDC, EnableWindow, InvalidateRect, SendMessageA, DefWindowProcA, BeginPaint, GetClientRect, FillRect, DrawTextA, EndPaint, ShowWindow
> version.dll: GetFileVersionInfoSizeA, GetFileVersionInfoA, VerQueryValueA
( 0 exports )
TrID : File type identification
Win32 Executable MS Visual C++ (generic) (65.2%)
Win32 Executable Generic (14.7%)
Win32 Dynamic Link Library (generic) (13.1%)
Generic Win/DOS Executable (3.4%)
DOS Executable Generic (3.4%)
ssdeep: 3072:zNyah0mJdnKYMh3D0FOUGXE9d6rH1nQEh9SiwxFc1xYkKblIY9OV1Uqg:zwvhQO/oqLSiYyvKGYY4qg
Prevx Info: http://info.prevx.com/aboutprogramtext.asp?PX5=8BBFD99768C3D6E0801502CEBA5295007870E5C5
PEiD : -
packers (F-Prot): NSIS
CWSandbox: http://research.sunbelt-software.com/partnerresource/MD5.aspx?md5=ac0d49c97ca2f09cc941b07a4a0e86b1
packers (Authentium): NSIS
RDS : NSRL Reference Data Set
-
JSunpack is a huge asset to analyze botnet IPs, malwares in general, drive-by-downloads and other such malicious stuff. It could be used as a webpage analysis tool, link analysis tool, an online sandbox and for other research. Blake is presenting at Shmoocon 2010 once again, though in a new topic [the following has been copied and pasted from: http://www.shmoocon.org/presentations-all.html]:
Jsunpack-network Edition Release: JavaScript Decoding and Intrusion Detection
Blake Hartstein
Attackers using web exploits are always improving their attacks to make them more effective at exploiting the victim, avoiding detection, and generally making attacks difficult for researchers to understand. While anti-virus products often try to detect malicious content by applying filters and finding hidden content, they generally do not help researchers because the only output they produce is a name indicating whether a file is malicious.
Jsunpack-n reports vulnerabilities that attackers target and full information of decodings. Jsunpack-n contains many unique improvments to last year’s 2009 introduction of jsunpack at Shmoocon, most notably these include: release of full source code, the ability to use jsunpack-n to actively monitor network traffic (interface/packet capture file), detection of malicious content using both customizable rules and built-in detection mechanisms, pdf and swf decoding modules, and tree structures and URL tracking mechanisms.
Blake Hartstein works on the Rapid Response team at iDefense, a Verisign company. At iDefense, he is responsible for analyzing and reporting on samples of unknown malicious code and other suspicious activity. Prior to iDefense, Blake was an author of intrusion detection signatures and contributed to Emerging Threats, an open source community project that promotes a diverse Snort Signature set.
This blog post was intended to explain about the tool[JSunpack] that could be useful to you, in the process of botnet analysis. Hope you enjoyed it!
Thank you.
EF