<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Unintended Results &#187; tools</title>
	<atom:link href="http://joxeankoret.com/blog/tag/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://joxeankoret.com/blog</link>
	<description>Or maybe not</description>
	<lastBuildDate>Fri, 14 May 2010 23:41:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Pyew! A Python tool to analyze malware</title>
		<link>http://joxeankoret.com/blog/2010/02/08/pyew-a-python-tool-to-analyze-malware/</link>
		<comments>http://joxeankoret.com/blog/2010/02/08/pyew-a-python-tool-to-analyze-malware/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 18:37:11 +0000</pubDate>
		<dc:creator>joxean</dc:creator>
				<category><![CDATA[Malware]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://joxeankoret.com/blog/?p=80</guid>
		<description><![CDATA[Working in a disassembler with code analysis to speed up (graph) analysis of malware dumps (malware dumped from memory while running) I decided to write a tool using this core oriented to malware analysis and the result is Pyew! Pyew is a tool like radare or biew/hiew. It&#8217;s an hexadecimal viewer, disassembler for IA32 and [...]]]></description>
			<content:encoded><![CDATA[<p>Working in a disassembler with code analysis to speed up (graph) analysis of malware dumps (malware dumped from memory while running) I decided to write a tool using this core oriented to malware analysis and the result is <a href="http://code.google.com/p/pyew/">Pyew</a>!<br />
<span id="more-80"></span><br />
Pyew is a tool like <a href="http://www.radare.org" target="_blank">radare</a> or <a href="http://biew.sourceforge.net/" target="_blank">biew</a>/<a href="http://www.hiew.ru/" target="_blank">hiew</a>. It&#8217;s an hexadecimal viewer, disassembler for IA32 and AMD64 with support for PE &amp; ELF formats as well as other non executable formats, like OLE2 or PDF. In the <a href="http://code.google.com/p/pyew/" target="_blank">project&#8217;s page</a> you may find <a href="http://code.google.com/p/pyew/wiki/UsageExample" target="_blank">usage examples</a> (like the superficial analysis of some <a href="http://code.google.com/p/pyew/wiki/AnalysisMebroot" target="_blank">Mebroot dowloaders</a>) as well as the <a href="http://code.google.com/p/pyew/wiki/Features" target="_blank">features</a> of the version available for download as a package (however, I recommend you to download the bleeding edge version from the <a href="http://mercurial.selenic.com/" target="_blank">Mercurial</a> repository available <a href="http://code.google.com/p/pyew/source/checkout" target="_blank">here</a>).</p>
<p>Anyway, even when Pyew have a command line interface (and a graphical user interface is planned) it was written for batch analysis of malware. Let&#8217;s imagine the following situation: You need to analyze a bunch of malware samples, i.e. 1000 new samples. What would you do? Analyze all of them manually one per one? It&#8217;s better to write some sort of batch script to analyze the samples and get a simple report about the malwares. You may find in the <a href="http://code.google.com/p/pyew/w/list" target="_blank">wiki</a> of Pyew a <a href="http://code.google.com/p/pyew/wiki/BatchExample" target="_blank">batch script example</a> to check for some specific marks at the file header, get the API calls made at entry point or to get a list of uncommon mnemonics found in the entry point.</p>
<p>Just to show another example of Pyew in batch mode I will explain how to write a simple script to get mnemonics of instructions used commonly as antidebugs. Let&#8217;s start writting the script. First import the libraries we need:</p>
<pre lang="python">
from pyew_core import CPyew
</pre>
<p>We need to import the class CPyew from pyew_core (the kernel of Pyew). Next, write a code to handle the load of one file and, after the load, print the antidebugs found:</p>
<pre lang="python">import sys
from pyew_core import CPyew

filename = sys.argv[1]
pyew = CPyew(batch=True) # Specify that we're in batch mode
pyew.codeanalysis = True # Just in case, by default code analysis is always performed
pyew.loadFile(filename) # Load the file and read all the structures, perform code analysis, etc...

print pyew.antidebug</pre>
<p>That&#8217;s all! This simple script will take as input a file and will analyze it for mnemonics used as antidebug (like INT 3 or RDTSC). Now, it&#8217;s time to write a better script that takes a directory and recursively traverses every subdirectory to analyze all files. The final result is <a href="http://code.google.com/p/pyew/source/browse/batch_example.py">here</a></p>
<p><a href="http://code.google.com/p/pyew/source/browse/batch_example.py"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://joxeankoret.com/blog/2010/02/08/pyew-a-python-tool-to-analyze-malware/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
