📄 chap8-1-6.htm.primary
字号:
<html>
<head>
<title>Crack Tutorial</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="style/css.css" type="text/css">
<link rel="stylesheet" href="../STYLE/Css.css" type="text/css">
</head>
<body bgcolor="white" text="#000000" link="#004080" vlink="#004080" background="../image/Back.gif">
<p><a href="../catalog.htm">目录</a>>>第8章</p>
<p align="center" class="shadow1Copy"><b class="p3">第8章 压缩与脱壳</b></p>
<table width="80%" border="0" cellspacing="0" cellpadding="3" align="center" bgcolor="#bcbcbc" bordercolor="#111111" class="shadow1">
<tr>
<td class="shadow1" width="20%">
<div align="center"><a href="Chap8-1.htm"><font color="#FFFFFF">第一节 PE文件格式</font></a></div>
</td>
<td class="shadow1" width="20%">
<div align="center"><a href="Chap8-2.htm"><font color="#FFFFFF">第二节 认识脱壳</font></a></div>
</td>
<td class="shadow1" width="20%">
<div align="center"><a href="Chap8-3-1.htm"><font color="#FFFFFF">第三节 自动脱壳</font></a></div>
</td>
<td class="shadow1" width="20%">
<div align="center"><a href="Chap8-4.htm"><font color="#FFFFFF">第四节 手动脱壳</font></a></div>
</td>
<td class="shadow1" width="20%">
<div align="center"><a href="Chap8-5.htm"><font color="#FFFFFF">第五节 脱壳高级篇</font></a></div>
</td>
</tr>
</table>
<p align="center"><span class="p9"><b>第一节 PE文件格式</b></span></p>
<table width="80%" border="1" align="center" bgcolor="#efefef" cellpadding="5" cellspacing="0" bordercolor="#111111">
<tr>
<td>1、<a href="Chap8-1-1.htm">PE文件格式一览 </a></td>
<td>2、<a href="Chap8-1-2.htm">检验PE文件的有效性 </a> </td>
<td><span class="p9"><span class="p9">3、<span class="p9"><a href="Chap8-1-3.htm">File
Header(文件头)</a></span></span></span></td>
<td>4、<a href="Chap8-1-4.htm">Optional Header</a></td>
</tr>
<tr>
<td>5、<a href="Chap8-1-5.htm">Section Table</a></td>
<td>6、<a href="Chap8-1-6.htm">Import Table</a></td>
<td>7、<a href="Chap8-1-7.htm">Export Table</a></td>
<td> </td>
</tr>
</table>
<h1 align="center"><font color="#000000" face="Arial, Helvetica, sans-serif">PE</font><font color="#000000">教程</font><font color="#000000" face="Arial, Helvetica, sans-serif">6:
Import Table</font><font color="#000000">(引入表)</font></h1>
<p><font size="2" color="#000000">本课我们将学习引入表。先警告一下,对于不熟悉引入表的读者来说,这是一堂又长又难的课,所以需要多读几遍,最好再打开调试器来好好分析相关结构。各位,努力啊!</font></p>
<p><font size="2" color="#000000">下载</font><font color="#000000"><a href="technology/pe-tut06.zip"
style="text-decoration:none"><font size="2"><b>范例</b></font></a><font
size="2">。</font></font></p>
<h3><font color="#000000">理论<font face="MS Sans Serif">:</font></font></h3>
<p><font size="2" color="#000000">首先,您得了解什么是引入函数。一个引入函数是被某模块调用的但又不在调用者模块中的函数,因而命名为</font><font size="2" face="MS Sans Serif" color="#000000">"import</font><font size="2" color="#000000">(引入)</font><font size="2" face="MS Sans Serif" color="#000000">"</font><font size="2" color="#000000">。引入函数实际位于一个或者更多的</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">里。调用者模块里只保留一些函数信息,包括函数名及其驻留的</font><font size="2" face="MS Sans Serif" color="#000000">DLL</font><font size="2" color="#000000">名。现在,我们怎样才能找到</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">文件中保存的信息呢</font><font size="2" face="MS Sans Serif" color="#000000">?
</font><font size="2" color="#000000">转到<b> </b></font><font color="#000000" size="2" face="MS Sans Serif"><b>data
directory</b> </font><font size="2" color="#000000">寻求答案吧。再回顾一把,下面就是 </font><font size="2" face="MS Sans Serif" color="#000000">PE
header:</font></p>
<blockquote>
<p><font size="2" face="Fixedsys" color="#000000">IMAGE_NT_HEADERS STRUCT<br>
Signature dd ?<br>
FileHeader IMAGE_FILE_HEADER <><br>
OptionalHeader IMAGE_OPTIONAL_HEADER <><br>
IMAGE_NT_HEADERS ENDS</font></p>
</blockquote>
<p><font size="2" face="MS Sans Serif" color="#000000">optional header </font><font size="2" color="#000000">最后一个成员就是
</font><font size="2" face="MS Sans Serif" color="#000000">data directory</font><font size="2" color="#000000">(数据目录)</font><font size="2" face="MS Sans Serif" color="#000000">:</font></p>
<p><font face="Fixedsys" color="#000000">IMAGE_OPTIONAL_HEADER32 STRUCT<br>
.... <br>
LoaderFlags dd ? <br>
NumberOfRvaAndSizes dd ? <br>
DataDirectory IMAGE_DATA_DIRECTORY 16 dup(<>) <br>
IMAGE_OPTIONAL_HEADER32 ENDS </font></p>
<p><font size="2" face="MS Sans Serif" color="#000000">data directory </font><font size="2" color="#000000">是一个
</font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_DATA_DIRECTORY</b>
</font><font size="2" color="#000000">结构数组,共有</font><font size="2" face="MS Sans Serif" color="#000000">16</font><font size="2" color="#000000">个成员。如果您还记得节表可以看作是</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">文件各节的根目录的话,也可以认为
</font><font size="2" face="MS Sans Serif" color="#000000">data directory </font><font size="2" color="#000000">是存储在这些节里的逻辑元素的根目录。明确点,</font><font size="2" face="MS Sans Serif" color="#000000">data
directory </font><font size="2" color="#000000">包含了</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">文件中各重要数据结构的位置和尺寸信息。
每个成员包含了一个重要数据结构的信息。</font></p>
<table border="1" cellpadding="2">
<tr bgcolor="#FFFFFF">
<th width="55"><font size="2"
face="MS Sans Serif">Member</font> </th>
<th width="162"><font size="2"
face="MS Sans Serif">Info inside</font></th>
</tr>
<tr>
<td align="center" width="55" bgcolor="#999900"><font
size="2" face="MS Sans Serif">0</font> </td>
<td align="center" width="162" bgcolor="#999900"><font
size="2" face="MS Sans Serif">Export symbols</font></td>
</tr>
<tr>
<td align="center" width="55" bgcolor="#999900"><font
size="2" face="MS Sans Serif">1</font> </td>
<td align="center" width="162" bgcolor="#999900"><font
size="2" face="MS Sans Serif">Import symbols</font></td>
</tr>
<tr>
<td align="center" width="55" bgcolor="#999900"><font
size="2" face="MS Sans Serif">2</font> </td>
<td align="center" width="162" bgcolor="#999900"><font
size="2" face="MS Sans Serif">Resources</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">3</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Exception</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">4</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Security</font></td>
</tr>
<tr>
<td align="center" width="55" bgcolor="#999900"><font
size="2" face="MS Sans Serif">5</font> </td>
<td align="center" width="162" bgcolor="#999900"><font
size="2" face="MS Sans Serif">Base relocation</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">6</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Debug</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">7</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Copyright string</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">8</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Unknown</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">9</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Thread local storage (TLS)</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">10</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Load configuration</font></td>
</tr>
<tr>
<td align="center" width="55" bgcolor="#999900"><font
size="2" face="MS Sans Serif">11</font> </td>
<td align="center" width="162" bgcolor="#999900"><font
size="2" face="MS Sans Serif">Bound Import</font></td>
</tr>
<tr>
<td align="center" width="55" bgcolor="#999900"><font
size="2" face="MS Sans Serif">12</font> </td>
<td align="center" width="162" bgcolor="#999900"><font
size="2" face="MS Sans Serif">Import Address Table</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">13</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">Delay Import</font></td>
</tr>
<tr>
<td align="center" width="55"><font size="2"
face="MS Sans Serif">14</font> </td>
<td align="center" width="162"><font size="2"
face="MS Sans Serif">COM descriptor</font></td>
</tr>
</table>
<p><font size="2" color="#000000">上面那些金色显示的是我熟悉的。了解 </font><font size="2" face="MS Sans Serif" color="#000000">data
directory </font><font size="2" color="#000000">包含域后,我们可以仔细研究它们了。</font><font size="2" face="MS Sans Serif" color="#000000">data
directory </font><font size="2" color="#000000">的每个成员都是 </font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_DATA_DIRECTORY</b>
</font><font size="2" color="#000000">结构类型的,其定义如下所示</font><font size="2" face="MS Sans Serif" color="#000000">:</font></p>
<p><font face="Fixedsys" color="#000000">IMAGE_DATA_DIRECTORY STRUCT <br>
VirtualAddress dd ? <br>
isize dd ? <br>
IMAGE_DATA_DIRECTORY ENDS </font></p>
<p><font color="#000000" size="2" face="MS Sans Serif"><b>VirtualAddress</b> </font><font size="2" color="#000000">实际上是数据结构的相对虚拟地址</font><font size="2" face="MS Sans Serif" color="#000000">(RVA)</font><font size="2" color="#000000">。比如,如果该结构是关于</font><font size="2" face="MS Sans Serif" color="#000000">import
symbols</font><font size="2" color="#000000">的,该域就包含指向</font><font color="#000000" size="2" face="MS Sans Serif"><b>IMAGE_IMPORT_DESCRIPTOR
</b></font><font size="2" color="#000000">数组的</font><font size="2" face="MS Sans Serif" color="#000000">RVA</font><font size="2" color="#000000">。
<br>
</font><font color="#000000" size="2" face="MS Sans Serif"><b>isize </b></font><font size="2" color="#000000">含有</font><font color="#000000" size="2" face="MS Sans Serif"><b>VirtualAddress</b></font><font size="2" color="#000000">所指向数据结构的字节数。</font></p>
<p><font size="2" color="#000000">下面就是如何找寻</font><font size="2" face="MS Sans Serif" color="#000000">PE</font><font size="2" color="#000000">文件中重要数据结构的一般方法</font><font size="2" face="MS Sans Serif" color="#000000">:</font></p>
<ol>
<li><font size="2" color="#000000">从 </font><font size="2" face="MS Sans Serif" color="#000000">DOS
header </font><font size="2" color="#000000">定位到 </font><font size="2" face="MS Sans Serif" color="#000000">PE
header</font></li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -