<?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>Hack'n Roll Blog &#187; Anderson Eduardo</title>
	<atom:link href="http://blog.hacknroll.com/author/anderson/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hacknroll.com</link>
	<description>Hacking as life style!</description>
	<lastBuildDate>Sun, 25 Sep 2011 03:38:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>False Disassembly</title>
		<link>http://blog.hacknroll.com/2009/01/20/false-disassembly/</link>
		<comments>http://blog.hacknroll.com/2009/01/20/false-disassembly/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:38:56 +0000</pubDate>
		<dc:creator>Anderson Eduardo</dc:creator>
				<category><![CDATA[Sem categoria]]></category>

		<guid isPermaLink="false">http://blog.hacknroll.com/?p=59</guid>
		<description><![CDATA[Olá galera.! Como meu primeiro post no blog irei falar sobre um método que irá dificultar o disassembly de um binário. O método cria um Falso Disassembly, que irá confundir os disassemblers gerando outras instruções diferente da que irá executar colocando outros bytes juntos com o opcode correto. O código abaixo é um exemplo de [...]]]></description>
			<content:encoded><![CDATA[<p>Olá galera.! Como <a href="http://anderson.hacknroll.com">meu</a> primeiro post no blog irei falar sobre um método que irá dificultar o disassembly de um binário.</p>
<p>O método cria um <i><b>Falso Disassembly</b></i>, que irá confundir os disassemblers gerando outras instruções diferente da que irá executar colocando outros bytes juntos com o opcode correto. O código abaixo é um exemplo de um simples exit sem esse método.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #339933;">.</span>section <span style="color: #339933;">.</span>text
<span style="color: #339933;">.</span>globl _start
_start<span style="color: #339933;">:</span>
          <span style="color: #00007f; font-weight: bold;">xor</span> <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
          <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span>
          <span style="color: #00007f; font-weight: bold;">mov</span> $<span style="color: #0000ff;">0x1</span><span style="color: #339933;">,%</span><span style="color: #00007f;">al</span>
          <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span>
          <span style="color: #00007f; font-weight: bold;">int</span> $<span style="color: #0000ff;">0x80</span></pre></td></tr></table></div>

<pre>
c0d3labs# <b>objdump -d normal_exit</b>

normal_exit:     file format elf32-i386-freebsd

Disassembly of section .text:

08048074 :
 8048074:       31 c0                   xor    %eax,%eax
 8048076:       50                      push   %eax
 8048077:       b0 01                   mov    $0x1,%al
 8048079:       50                      push   %eax
 804807a:       cd 80                   int    $0x80
c0d3labs#
</pre>
<p>Agora, no exemplo abaixo, quando o disassembler for mostrar o código, irá juntar os opcodes “\xc0\xc9&#8243; com “\x31&#8243;, que é o começo do “xor %eax,%eax”, que faz a instrução “ror $0×31,%cl”(opcode “\xc0\xc9\x31&#8243;). Isso aconteçe porque a instrução “ror”(opcode “\xc0&#8243;) recebe dois argumentos. Com isso o “\xc0&#8243;, que é o final do “xor %eax,%eax”, é ignorado e passa a ser a proxima instrução.</p>
<p>A chave principal dessa idéia é alterar o entry point. No caso iremos aumentar em dois para cair diretamente no “\x31\xc0&#8243;, no caso executar o “xor %eax,%eax” e, assim, ignorar o “\xc0\xc9&#8243; que foi inserido só para confundir o disassembly.</p>
<p>E, em seguida, executar o “jmp . + 4&#8243; (opcode “\xeb\x02&#8243;), que é para pular do endereço atual mais quatro. Isso para ignorar o “\xc9\xc0&#8243; que foi inserido junto com “\xb0\x01&#8243; para o mesmo propósito, e cair diretamente no “mov $0×1,%al”(opcode “\xb0\x01&#8243;) e assim seguir adiante.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #339933;">.</span>section <span style="color: #339933;">.</span>text
<span style="color: #339933;">.</span>globl _start
_start<span style="color: #339933;">:</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc0</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc9</span>
         <span style="color: #00007f; font-weight: bold;">xor</span> <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span><span style="color: #339933;">,%</span><span style="color: #00007f;">eax</span>
         <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span>
         <span style="color: #00007f; font-weight: bold;">jmp</span> <span style="color: #339933;">.</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc0</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc9</span>
         <span style="color: #00007f; font-weight: bold;">mov</span> $<span style="color: #0000ff;">0x1</span><span style="color: #339933;">,%</span><span style="color: #00007f;">al</span>
         <span style="color: #00007f; font-weight: bold;">jmp</span> <span style="color: #339933;">.</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc9</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc0</span>
         <span style="color: #00007f; font-weight: bold;">push</span> <span style="color: #339933;">%</span><span style="color: #00007f;">eax</span>
         <span style="color: #00007f; font-weight: bold;">jmp</span> <span style="color: #339933;">.</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">4</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc0</span>
         <span style="color: #339933;">.</span><span style="color: #000000; font-weight: bold;">byte</span> <span style="color: #0000ff;">0xc9</span>
         <span style="color: #00007f; font-weight: bold;">int</span> $<span style="color: #0000ff;">0x80</span></pre></td></tr></table></div>

<pre>
c0d3labs# <b>objdump -d false_disassembly</b>

false_disassembly:     file format elf32-i386-freebsd

Disassembly of section .text:

08048074 &lt;_start&gt;:
8048074:       c0 c9 31                ror    $0x31,%cl
8048077:       c0 50 eb 02             rclb   $0x2,0xffffffeb(%eax)
804807b:       c0 c9 b0                ror    $0xb0,%cl
804807e:       01 eb                   add    %ebp,%ebx
8048080:       02 c9                   add    %cl,%cl
8048082:       c0 50 eb 02             rclb   $0x2,0xffffffeb(%eax)
8048086:       c0 c9 cd                ror    $0xcd,%cl
8048089:       80                      .byte 0x80
c0d3labs#
</pre>
<p>Para alterar o entry point, você pode mudar manualmente via qualquer editor hexadecimal no offset 0&#215;18 ou usar esse <a href="http://anderson.hacknroll.com/codes/altera_entry.php">code.</a></p>
<p>Todos os testes foram feito em um FreeBSD versão 6.2.</p>
<p>Até mais!</p>
<p>`hacknroll`</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hacknroll.com/2009/01/20/false-disassembly/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

