<?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>PELock Blog &#187; OllyDbg</title>
	<atom:link href="http://www.pelock.com/blog/tag/ollydbg/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pelock.com/blog</link>
	<description>Assembler, software protection, code obfuscation and other crazy stuff.</description>
	<lastBuildDate>Tue, 30 Nov 2010 02:03:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Really easy scripting with ODbgScript</title>
		<link>http://www.pelock.com/blog/2007/09/06/really-easy-scripting-with-odbgscript/</link>
		<comments>http://www.pelock.com/blog/2007/09/06/really-easy-scripting-with-odbgscript/#comments</comments>
		<pubDate>Wed, 05 Sep 2007 23:30:31 +0000</pubDate>
		<dc:creator>Bartosz</dc:creator>
				<category><![CDATA[Assembler]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[ODbgScript]]></category>
		<category><![CDATA[OllyDbg]]></category>

		<guid isPermaLink="false">http://www.pelock.com/blog/2007/09/06/really-easy-scripting-with-odbgscript/</guid>
		<description><![CDATA[ODbgScript is an extension for OllyDbg debugger (note to myself: so mr smartass there&#8217;s life except SoftICE heh  )...]]></description>
			<content:encoded><![CDATA[<p><a href="http://odbgscript.sourceforge.net/">ODbgScript</a> is an extension for <a href="http://www.ollydbg.de/">OllyDbg</a> debugger (<em>note to myself: so mr smartass there&#8217;s life except SoftICE heh <img src='http://www.pelock.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </em>).</p>
<p>I was always a little bit afraid of using it becouse i thought it&#8217;s easier to write separate application than to code in this <em>weird</em> scripting language.</p>
<p>But today i need a tool to dump decrypted strings from one application (while it&#8217;s running). I wanted to start coding live dumper based on <a href="http://msdn2.microsoft.com/en-us/library/ms679303.aspx">WinApi&#8217;s debug functions</a> but i though what the heck, let&#8217;s try to do it in ODbgScript.</p>
<p>Here&#8217;s the result:</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">; declare variables</span>
        var     string_ptr
        var     file_name
        var     file_index
        var     file_size
        var     x
&nbsp;
<span style="color: #666666; font-style: italic;">; set breakpoint at the instruction where we</span>
<span style="color: #666666; font-style: italic;">; intercepts decrypted strings</span>
        <span style="color: #00007f;">bp</span>     <span style="color: #0000ff;">401020</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; initialize file_index variable</span>
        <span style="color: #00007f; font-weight: bold;">mov</span>     file_index<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; run application after setting the breakpoint</span>
again<span style="color: #339933;">:</span>
        run
&nbsp;
<span style="color: #666666; font-style: italic;">; if we're here, it means application hit the breakpoint</span>
<span style="color: #666666; font-style: italic;">; continue to execute script after breakpoint is hit</span>
<span style="color: #666666; font-style: italic;">; (don't stop in OllyDbg)</span>
        cob
&nbsp;
<span style="color: #666666; font-style: italic;">; pointer to the encrypted string is stored</span>
<span style="color: #666666; font-style: italic;">; at [ebp-14] let's grab it</span>
        <span style="color: #00007f; font-weight: bold;">mov</span>     x<span style="color: #339933;">,</span> <span style="color: #00007f;">ebp</span>
        <span style="color: #00007f; font-weight: bold;">sub</span>     x<span style="color: #339933;">,</span> <span style="color: #0000ff;">14</span>
        <span style="color: #00007f; font-weight: bold;">mov</span>     x<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>x<span style="color: #009900; font-weight: bold;">&#93;</span>
&nbsp;
        <span style="color: #00007f; font-weight: bold;">mov</span>     string_ptr<span style="color: #339933;">,</span> x
&nbsp;
<span style="color: #666666; font-style: italic;">; strings are null terminated, let's find its</span>
<span style="color: #666666; font-style: italic;">; size so we can dump it (LEN command didn't work</span>
<span style="color: #666666; font-style: italic;">; here, it always returns 0FFh)</span>
        find    string_ptr<span style="color: #339933;">,</span> #<span style="color: #0000ff;">00</span>#
&nbsp;
        <span style="color: #00007f; font-weight: bold;">cmp</span>     $RESULT<span style="color: #339933;">,</span> <span style="color: #0000ff;">0</span>
        <span style="color: #00007f; font-weight: bold;">je</span>      skip_file
&nbsp;
<span style="color: #666666; font-style: italic;">; calculate string size</span>
        <span style="color: #00007f; font-weight: bold;">mov</span>     x<span style="color: #339933;">,</span> $RESULT
        <span style="color: #00007f; font-weight: bold;">sub</span>     x<span style="color: #339933;">,</span> string_ptr
&nbsp;
        <span style="color: #00007f; font-weight: bold;">mov</span>     file_size<span style="color: #339933;">,</span> x
&nbsp;
<span style="color: #666666; font-style: italic;">; format file name for decrypted string, name it using</span>
<span style="color: #666666; font-style: italic;">; file_index value and .txt extension, eval works almost</span>
<span style="color: #666666; font-style: italic;">; like wsprintf</span>
        eval    <span style="color: #7f007f;">&quot;C:\Test\{file_index}.txt&quot;</span>
        <span style="color: #00007f; font-weight: bold;">mov</span>     file_name<span style="color: #339933;">,</span> $RESULT
&nbsp;
<span style="color: #666666; font-style: italic;">; dump memory area to the file</span>
        dm      string_ptr<span style="color: #339933;">,</span> file_size<span style="color: #339933;">,</span> file_name
&nbsp;
<span style="color: #666666; font-style: italic;">; log action</span>
        eval    <span style="color: #7f007f;">&quot;{file_index} - VA = {string_ptr},
                 SIZE = {file_size}&quot;</span>
        log     $RESULT<span style="color: #666666; font-style: italic;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; increase index value</span>
        <span style="color: #00007f; font-weight: bold;">inc</span>     file_index
&nbsp;
skip_file<span style="color: #339933;">:</span>
&nbsp;
<span style="color: #666666; font-style: italic;">; run application again after dumping</span>
        <span style="color: #00007f; font-weight: bold;">jmp</span>     again</pre></div></div>

<p>At first it might look confusing, but after playing with it for 5 minutes you will love it, especially if you know how to code in assembler.</p>
<p>And if you make mistakes in the script, don&#8217;t worry, it has its own, built-in debugger, available directly from OllyDbg so you can spot every mistake you did, trace down the script, modify its variables etc.</p>
<p>In other words viva la ODbgScript <img src='http://www.pelock.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><em>PS. And don&#8217;t ask me why i didn&#8217;t use it before <img src='http://www.pelock.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pelock.com/blog/2007/09/06/really-easy-scripting-with-odbgscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kaspersky Anti-Virus v6.0.2 vs OllyDbg</title>
		<link>http://www.pelock.com/blog/2007/06/13/kaspersky-anti-virus-v602-vs-ollydbg/</link>
		<comments>http://www.pelock.com/blog/2007/06/13/kaspersky-anti-virus-v602-vs-ollydbg/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 11:59:15 +0000</pubDate>
		<dc:creator>Bartosz</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Kaspersky]]></category>
		<category><![CDATA[OllyDbg]]></category>

		<guid isPermaLink="false">http://www.pelock.com/blog/2007/06/13/kaspersky-anti-virus-v602-vs-ollydbg/</guid>
		<description><![CDATA[I wonder how much time will it take to them to put notepad.exe on their black list (in &#8220;Virus writing editor&#8221; category)?
]]></description>
			<content:encoded><![CDATA[<p>I wonder how much time will it take to them to put notepad.exe on their black list (in &#8220;Virus writing editor&#8221; category)?</p>
<p><a href='http://www.pelock.com/blog/wp-content/uploads/2007/06/ollydbg_invader.png' title='OllyDbg Invader'><img src='http://www.pelock.com/blog/wp-content/uploads/2007/06/ollydbg_invader.thumbnail.png' alt='OllyDbg Invader' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pelock.com/blog/2007/06/13/kaspersky-anti-virus-v602-vs-ollydbg/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

