all repos — site @ 3ca6e1a5d5e915e6cf17ee8d60c4ec2a36fccc5b

source for my site, found at icyphox.sh

build/blog/python-for-re-1/index.html (view raw)

  1<!DOCTYPE html>
  2<html lang=en>
  3<link rel="stylesheet" href="/static/style.css" type="text/css">
  4<link rel="stylesheet" href="/static/syntax.css" type="text/css">
  5<link rel="shortcut icon" type="images/x-icon" href="/static/favicon.ico">
  6<meta name="description" content="Building your own disassembly tooling for — that’s right — fun and profit">
  7<meta name="viewport" content="initial-scale=1">
  8<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  9<meta content="#021012" name="theme-color">
 10<meta name="HandheldFriendly" content="true">
 11<meta name="twitter:card" content="summary_large_image">
 12<meta name="twitter:site" content="@icyphox">
 13<meta name="twitter:title" content="Python for Reverse Engineering #1: ELF Binaries">
 14<meta name="twitter:description" content="Building your own disassembly tooling for — that’s right — fun and profit">
 15<meta name="twitter:image" content="/static/icyphox.png">
 16<meta property="og:title" content="Python for Reverse Engineering #1: ELF Binaries">
 17<meta property="og:type" content="website">
 18<meta property="og:description" content="Building your own disassembly tooling for — that’s right — fun and profit">
 19<meta property="og:url" content="https://icyphox.sh">
 20<meta property="og:image" content="/static/icyphox.png">
 21<html>
 22  <title>
 23    Python for Reverse Engineering #1: ELF Binaries
 24  </title>
 25<script src="//instant.page/1.1.0" type="module" integrity="sha384-EwBObn5QAxP8f09iemwAJljc+sU+eUXeL9vSBw1eNmVarwhKk2F9vBEpaN9rsrtp"></script>
 26<div class="container-text">
 27  <header class="header">
 28    
 29        <a href="/">home</a>
 30        <a href="/blog">blog</a>
 31        <a href="/reading">reading</a>
 32        <a href="https://twitter.com/icyphox">twitter</a>
 33        <a href="/about">about</a>
 34
 35  </header>
 36<body> 
 37   <div class="content">
 38    <div align="left">
 39      <p> 2019-02-08 </p>
 40      <h1> Python for Reverse Engineering #1: ELF Binaries </h1>
 41      <h2> Building your own disassembly tooling for — that’s right — fun and profit </h2>
 42      <p>While solving complex reversing challenges, we often use established tools like radare2 or IDA for disassembling and debugging. But there are times when you need to dig in a little deeper and understand how things work under the hood.</p>
 43
 44<p>Rolling your own disassembly scripts can be immensely helpful when it comes to automating certain processes, and eventually build your own homebrew reversing toolchain of sorts. At least, that’s what I’m attempting anyway.</p>
 45
 46<h3 id="setup">Setup</h3>
 47
 48<p>As the title suggests, you’re going to need a Python 3 interpreter before
 49anything else. Once you’ve confirmed beyond reasonable doubt that you do,
 50in fact, have a Python 3 interpreter installed on your system, run</p>
 51
 52<div class="codehilite"><pre><span></span><code><span class="gp">$</span> pip install capstone pyelftools
 53</code></pre></div>
 54
 55<p>where <code>capstone</code> is the disassembly engine we’ll be scripting with and <code>pyelftools</code> to help parse ELF files.</p>
 56
 57<p>With that out of the way, let’s start with an example of a basic reversing
 58challenge.</p>
 59
 60<div class="codehilite"><pre><span></span><code><span class="cm">/* chall.c */</span>
 61
 62<span class="cp">#include</span> <span class="cpf">&lt;stdio.h&gt;</span><span class="cp"></span>
 63<span class="cp">#include</span> <span class="cpf">&lt;stdlib.h&gt;</span><span class="cp"></span>
 64<span class="cp">#include</span> <span class="cpf">&lt;string.h&gt;</span><span class="cp"></span>
 65
 66<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
 67   <span class="kt">char</span> <span class="o">*</span><span class="n">pw</span> <span class="o">=</span> <span class="n">malloc</span><span class="p">(</span><span class="mi">9</span><span class="p">);</span>
 68   <span class="n">pw</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="sc">&#39;a&#39;</span><span class="p">;</span>
 69   <span class="k">for</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;=</span> <span class="mi">8</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">){</span>
 70       <span class="n">pw</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">pw</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="mi">1</span><span class="p">;</span>
 71   <span class="p">}</span>
 72   <span class="n">pw</span><span class="p">[</span><span class="mi">9</span><span class="p">]</span> <span class="o">=</span> <span class="sc">&#39;\0&#39;</span><span class="p">;</span>
 73   <span class="kt">char</span> <span class="o">*</span><span class="n">in</span> <span class="o">=</span> <span class="n">malloc</span><span class="p">(</span><span class="mi">10</span><span class="p">);</span>
 74   <span class="n">printf</span><span class="p">(</span><span class="s">&quot;password: &quot;</span><span class="p">);</span>
 75   <span class="n">fgets</span><span class="p">(</span><span class="n">in</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="n">stdin</span><span class="p">);</span>        <span class="c1">// &#39;abcdefghi&#39;</span>
 76   <span class="k">if</span><span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">in</span><span class="p">,</span> <span class="n">pw</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
 77       <span class="n">printf</span><span class="p">(</span><span class="s">&quot;haha yes!</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
 78   <span class="p">}</span>
 79   <span class="k">else</span> <span class="p">{</span>
 80       <span class="n">printf</span><span class="p">(</span><span class="s">&quot;nah dude</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
 81   <span class="p">}</span>
 82<span class="p">}</span>
 83</code></pre></div>
 84
 85<p>Compile it with GCC/Clang:</p>
 86
 87<div class="codehilite"><pre><span></span><code><span class="gp">$</span> gcc chall.c -o chall.elf
 88</code></pre></div>
 89
 90<h3 id="scripting">Scripting</h3>
 91
 92<p>For starters, let’s look at the different sections present in the binary.</p>
 93
 94<div class="codehilite"><pre><span></span><code><span class="c1"># sections.py</span>
 95
 96<span class="kn">from</span> <span class="nn">elftools.elf.elffile</span> <span class="kn">import</span> <span class="n">ELFFile</span>
 97
 98<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;./chall.elf&#39;</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
 99    <span class="n">e</span> <span class="o">=</span> <span class="n">ELFFile</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
100    <span class="k">for</span> <span class="n">section</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">iter_sections</span><span class="p">():</span>
101        <span class="k">print</span><span class="p">(</span><span class="nb">hex</span><span class="p">(</span><span class="n">section</span><span class="p">[</span><span class="s1">&#39;sh_addr&#39;</span><span class="p">]),</span> <span class="n">section</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
102</code></pre></div>
103
104<p>This script iterates through all the sections and also shows us where it’s loaded. This will be pretty useful later. Running it gives us</p>
105
106<div class="codehilite"><pre><span></span><code><span class="go">› python sections.py</span>
107<span class="go">0x238 .interp</span>
108<span class="go">0x254 .note.ABI-tag</span>
109<span class="go">0x274 .note.gnu.build-id</span>
110<span class="go">0x298 .gnu.hash</span>
111<span class="go">0x2c0 .dynsym</span>
112<span class="go">0x3e0 .dynstr</span>
113<span class="go">0x484 .gnu.version</span>
114<span class="go">0x4a0 .gnu.version_r</span>
115<span class="go">0x4c0 .rela.dyn</span>
116<span class="go">0x598 .rela.plt</span>
117<span class="go">0x610 .init</span>
118<span class="go">0x630 .plt</span>
119<span class="go">0x690 .plt.got</span>
120<span class="go">0x6a0 .text</span>
121<span class="go">0x8f4 .fini</span>
122<span class="go">0x900 .rodata</span>
123<span class="go">0x924 .eh_frame_hdr</span>
124<span class="go">0x960 .eh_frame</span>
125<span class="go">0x200d98 .init_array</span>
126<span class="go">0x200da0 .fini_array</span>
127<span class="go">0x200da8 .dynamic</span>
128<span class="go">0x200f98 .got</span>
129<span class="go">0x201000 .data</span>
130<span class="go">0x201010 .bss</span>
131<span class="go">0x0 .comment</span>
132<span class="go">0x0 .symtab</span>
133<span class="go">0x0 .strtab</span>
134<span class="go">0x0 .shstrtab</span>
135</code></pre></div>
136
137<p>Most of these aren’t relevant to us, but a few sections here are to be noted. The <code>.text</code> section contains the instructions (opcodes) that we’re after. The <code>.data</code> section should have strings and constants initialized at compile time. Finally, the <code>.plt</code> which is the Procedure Linkage Table and the <code>.got</code>, the Global Offset Table. If you’re unsure about what these mean, read up on the ELF format and its internals.</p>
138
139<p>Since we know that the <code>.text</code> section has the opcodes, let’s disassemble the binary starting at that address.</p>
140
141<div class="codehilite"><pre><span></span><code><span class="c1"># disas1.py</span>
142
143<span class="kn">from</span> <span class="nn">elftools.elf.elffile</span> <span class="kn">import</span> <span class="n">ELFFile</span>
144<span class="kn">from</span> <span class="nn">capstone</span> <span class="kn">import</span> <span class="o">*</span>
145
146<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;./bin.elf&#39;</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
147    <span class="n">elf</span> <span class="o">=</span> <span class="n">ELFFile</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
148    <span class="n">code</span> <span class="o">=</span> <span class="n">elf</span><span class="o">.</span><span class="n">get_section_by_name</span><span class="p">(</span><span class="s1">&#39;.text&#39;</span><span class="p">)</span>
149    <span class="n">ops</span> <span class="o">=</span> <span class="n">code</span><span class="o">.</span><span class="n">data</span><span class="p">()</span>
150    <span class="n">addr</span> <span class="o">=</span> <span class="n">code</span><span class="p">[</span><span class="s1">&#39;sh_addr&#39;</span><span class="p">]</span>
151    <span class="n">md</span> <span class="o">=</span> <span class="n">Cs</span><span class="p">(</span><span class="n">CS_ARCH_X86</span><span class="p">,</span> <span class="n">CS_MODE_64</span><span class="p">)</span>
152    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">md</span><span class="o">.</span><span class="n">disasm</span><span class="p">(</span><span class="n">ops</span><span class="p">,</span> <span class="n">addr</span><span class="p">):</span>        
153        <span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;0x{i.address:x}:</span><span class="se">\t</span><span class="s1">{i.mnemonic}</span><span class="se">\t</span><span class="s1">{i.op_str}&#39;</span><span class="p">)</span>
154</code></pre></div>
155
156<p>The code is fairly straightforward (I think). We should be seeing this, on running</p>
157
158<div class="codehilite"><pre><span></span><code><span class="go">› python disas1.py | less      </span>
159<span class="go">0x6a0: xor ebp, ebp</span>
160<span class="go">0x6a2: mov r9, rdx</span>
161<span class="go">0x6a5: pop rsi</span>
162<span class="go">0x6a6: mov rdx, rsp</span>
163<span class="go">0x6a9: and rsp, 0xfffffffffffffff0</span>
164<span class="go">0x6ad: push rax</span>
165<span class="go">0x6ae: push rsp</span>
166<span class="go">0x6af: lea r8, [rip + 0x23a]</span>
167<span class="go">0x6b6: lea rcx, [rip + 0x1c3]</span>
168<span class="go">0x6bd: lea rdi, [rip + 0xe6]</span>
169<span class="go">**0x6c4: call qword ptr [rip + 0x200916]**</span>
170<span class="go">0x6ca: hlt</span>
171<span class="go">... snip ...</span>
172</code></pre></div>
173
174<p>The line in bold is fairly interesting to us. The address at <code>[rip + 0x200916]</code> is equivalent to <code>[0x6ca + 0x200916]</code>, which in turn evaluates to <code>0x200fe0</code>. The first <code>call</code> being made to a function at <code>0x200fe0</code>? What could this function be?</p>
175
176<p>For this, we will have to look at <strong>relocations</strong>. Quoting <a href="http://refspecs.linuxbase.org/elf/gabi4+/ch4.reloc.html">linuxbase.org</a></p>
177
178<blockquote>
179  <p>Relocation is the process of connecting symbolic references with symbolic definitions. For example, when a program calls a function, the associated call instruction must transfer control to the proper destination address at execution. Relocatable files must have “relocation entries’’ which are necessary because they contain information that describes how to modify their section contents, thus allowing executable and shared object files to hold the right information for a process’s program image.</p>
180</blockquote>
181
182<p>To try and find these relocation entries, we write a third script.</p>
183
184<div class="codehilite"><pre><span></span><code><span class="c1"># relocations.py</span>
185
186<span class="kn">import</span> <span class="nn">sys</span>
187<span class="kn">from</span> <span class="nn">elftools.elf.elffile</span> <span class="kn">import</span> <span class="n">ELFFile</span>
188<span class="kn">from</span> <span class="nn">elftools.elf.relocation</span> <span class="kn">import</span> <span class="n">RelocationSection</span>
189
190<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;./chall.elf&#39;</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
191    <span class="n">e</span> <span class="o">=</span> <span class="n">ELFFile</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
192    <span class="k">for</span> <span class="n">section</span> <span class="ow">in</span> <span class="n">e</span><span class="o">.</span><span class="n">iter_sections</span><span class="p">():</span>
193        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">section</span><span class="p">,</span> <span class="n">RelocationSection</span><span class="p">):</span>
194            <span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;{section.name}:&#39;</span><span class="p">)</span>
195            <span class="n">symbol_table</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">get_section</span><span class="p">(</span><span class="n">section</span><span class="p">[</span><span class="s1">&#39;sh_link&#39;</span><span class="p">])</span>
196            <span class="k">for</span> <span class="n">relocation</span> <span class="ow">in</span> <span class="n">section</span><span class="o">.</span><span class="n">iter_relocations</span><span class="p">():</span>
197                <span class="n">symbol</span> <span class="o">=</span> <span class="n">symbol_table</span><span class="o">.</span><span class="n">get_symbol</span><span class="p">(</span><span class="n">relocation</span><span class="p">[</span><span class="s1">&#39;r_info_sym&#39;</span><span class="p">])</span>
198                <span class="n">addr</span> <span class="o">=</span> <span class="nb">hex</span><span class="p">(</span><span class="n">relocation</span><span class="p">[</span><span class="s1">&#39;r_offset&#39;</span><span class="p">])</span>
199                <span class="k">print</span><span class="p">(</span><span class="n">f</span><span class="s1">&#39;{symbol.name} {addr}&#39;</span><span class="p">)</span>
200</code></pre></div>
201
202<p>Let’s run through this code real quick. We first loop through the sections, and check if it’s of the type <code>RelocationSection</code>. We then iterate through the relocations from the symbol table for each section. Finally, running this gives us</p>
203
204<div class="codehilite"><pre><span></span><code><span class="go">› python relocations.py</span>
205<span class="go">.rela.dyn:</span>
206<span class="go"> 0x200d98</span>
207<span class="go"> 0x200da0</span>
208<span class="go"> 0x201008</span>
209<span class="go">_ITM_deregisterTMCloneTable 0x200fd8</span>
210<span class="go">**__libc_start_main 0x200fe0**</span>
211<span class="go">__gmon_start__ 0x200fe8</span>
212<span class="go">_ITM_registerTMCloneTable 0x200ff0</span>
213<span class="go">__cxa_finalize 0x200ff8</span>
214<span class="go">stdin 0x201010</span>
215<span class="go">.rela.plt:</span>
216<span class="go">puts 0x200fb0</span>
217<span class="go">printf 0x200fb8</span>
218<span class="go">fgets 0x200fc0</span>
219<span class="go">strcmp 0x200fc8</span>
220<span class="go">malloc 0x200fd0</span>
221</code></pre></div>
222
223<p>Remember the function call at <code>0x200fe0</code> from earlier? Yep, so that was a call to the well known <code>__libc_start_main</code>. Again, according to <a href="http://refspecs.linuxbase.org/LSB_3.1.0/LSB-generic/LSB-generic/baselib&#8212;libc-start-main-.html">linuxbase.org</a></p>
224
225<blockquote>
226  <p>The <code>__libc_start_main()</code> function shall perform any necessary initialization of the execution environment, call the <em>main</em> function with appropriate arguments, and handle the return from <code>main()</code>. If the <code>main()</code> function returns, the return value shall be passed to the <code>exit()</code> function.</p>
227</blockquote>
228
229<p>And its definition is like so</p>
230
231<div class="codehilite"><pre><span></span><code><span class="kt">int</span> <span class="nf">__libc_start_main</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span><span class="p">(</span><span class="n">main</span><span class="p">)</span> <span class="p">(</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span> <span class="o">*</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span> <span class="o">*</span><span class="p">),</span> 
232<span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span> <span class="o">*</span> <span class="n">ubp_av</span><span class="p">,</span> 
233<span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">init</span><span class="p">)</span> <span class="p">(</span><span class="kt">void</span><span class="p">),</span> 
234<span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">fini</span><span class="p">)</span> <span class="p">(</span><span class="kt">void</span><span class="p">),</span> 
235<span class="kt">void</span> <span class="p">(</span><span class="o">*</span><span class="n">rtld_fini</span><span class="p">)</span> <span class="p">(</span><span class="kt">void</span><span class="p">),</span> 
236<span class="kt">void</span> <span class="p">(</span><span class="o">*</span> <span class="n">stack_end</span><span class="p">));</span>
237</code></pre></div>
238
239<p>Looking back at our disassembly</p>
240
241<pre><code>0x6a0: xor ebp, ebp
2420x6a2: mov r9, rdx
2430x6a5: pop rsi
2440x6a6: mov rdx, rsp
2450x6a9: and rsp, 0xfffffffffffffff0
2460x6ad: push rax
2470x6ae: push rsp
2480x6af: lea r8, [rip + 0x23a]
2490x6b6: lea rcx, [rip + 0x1c3]
250**0x6bd: lea rdi, [rip + 0xe6]**
2510x6c4: call qword ptr [rip + 0x200916]
2520x6ca: hlt
253... snip ...
254</code></pre>
255
256<p>but this time, at the <code>lea</code> or Load Effective Address instruction, which loads some address <code>[rip + 0xe6]</code> into the <code>rdi</code> register. <code>[rip + 0xe6]</code> evaluates to <code>0x7aa</code> which happens to be the address of our <code>main()</code> function! How do I know that? Because <code>__libc_start_main()</code>, after doing whatever it does, eventually jumps to the function at <code>rdi</code>, which is generally the <code>main()</code> function. It looks something like this</p>
257
258<p><img src="https://cdn-images-1.medium.com/max/800/0*oQA2MwHjhzosF8ZH.png" alt="" /></p>
259
260<p>To see the disassembly of <code>main</code>, seek to <code>0x7aa</code> in the output of the script we’d written earlier (<code>disas1.py</code>).</p>
261
262<p>From what we discovered earlier, each <code>call</code> instruction points to some function which we can see from the relocation entries. So following each <code>call</code> into their relocations gives us this</p>
263
264<pre><code>printf 0x650
265fgets  0x660
266strcmp 0x670
267malloc 0x680
268</code></pre>
269
270<p>Putting all this together, things start falling into place. Let me highlight the key sections of the disassembly here. It’s pretty self-explanatory.</p>
271
272<pre><code>0x7b2: mov edi, 0xa  ; 10
2730x7b7: call 0x680    ; malloc
274</code></pre>
275
276<p>The loop to populate the <code>*pw</code> string</p>
277
278<pre><code>0x7d0:  mov     eax, dword ptr [rbp - 0x14]
2790x7d3:  cdqe    
2800x7d5:  lea     rdx, [rax - 1]
2810x7d9:  mov     rax, qword ptr [rbp - 0x10]
2820x7dd:  add     rax, rdx
2830x7e0:  movzx   eax, byte ptr [rax]
2840x7e3:  lea     ecx, [rax + 1]
2850x7e6:  mov     eax, dword ptr [rbp - 0x14]
2860x7e9:  movsxd  rdx, eax
2870x7ec:  mov     rax, qword ptr [rbp - 0x10]
2880x7f0:  add     rax, rdx
2890x7f3:  mov     edx, ecx
2900x7f5:  mov     byte ptr [rax], dl
2910x7f7:  add     dword ptr [rbp - 0x14], 1
2920x7fb:  cmp     dword ptr [rbp - 0x14], 8
2930x7ff:  jle     0x7d0
294</code></pre>
295
296<p>And this looks like our <code>strcmp()</code></p>
297
298<pre><code>0x843:  mov     rdx, qword ptr [rbp - 0x10] ; *in
2990x847:  mov     rax, qword ptr [rbp - 8]    ; *pw
3000x84b:  mov     rsi, rdx             
3010x84e:  mov     rdi, rax
3020x851:  call    0x670                       ; strcmp  
3030x856:  test    eax, eax                    ; is = 0? 
3040x858:  jne     0x868                       ; no? jump to 0x868
3050x85a:  lea     rdi, [rip + 0xae]           ; "haha yes!" 
3060x861:  call    0x640                       ; puts
3070x866:  jmp     0x874
3080x868:  lea     rdi, [rip + 0xaa]           ; "nah dude"
3090x86f:  call    0x640                       ; puts  
310</code></pre>
311
312<p>I’m not sure why it uses <code>puts</code> here? I might be missing something; perhaps <code>printf</code> calls <code>puts</code>. I could be wrong. I also confirmed with radare2 that those locations are actually the strings “haha yes!” and “nah dude”.</p>
313
314<p><strong>Update</strong>: It&#8217;s because of compiler optimization. A <code>printf()</code> (in this case) is seen as a bit overkill, and hence gets simplified to a <code>puts()</code>.</p>
315
316<h3 id="conclusion">Conclusion</h3>
317
318<p>Wew, that took quite some time. But we’re done. If you’re a beginner, you might find this extremely confusing, or probably didn’t even understand what was going on. And that’s okay. Building an intuition for reading and grokking disassembly comes with practice. I’m no good at it either.</p>
319
320<p>All the code used in this post is here: <a href="https://github.com/icyphox/asdf/tree/master/reversing-elf">https://github.com/icyphox/asdf/tree/master/reversing-elf</a></p>
321
322<p>Ciao for now, and I’ll see ya in #2 of this series — PE binaries. Whenever that is.</p>
323 
324    </div>
325    <hr />
326    <p class="muted">Questions or comments? Open an issue at <a href="https://github.com/icyphox/site">this repo</a>, or send a plain-text email to <a href="mailto:icyph0x@pm.me">icyph0x@pm.me</a>.</p>
327    <footer>
328      <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/"><img src="https://licensebuttons.net/l/by-nc-sa/4.0/80x15.png"></a>
329    </footer>
330  </body>
331  </div>
332 </html>