壳的概念、LordPE的使用、C读取PE文件初步

壳的概念、LordPE的使用、C读取PE文件初步参阅加密与解密第三版 13 1 13 2 有加壳 必有脱壳

大家好,欢迎来到IT知识分享网。

参阅 加密与解密 第三版;13.1;13.2;

    有加壳,必有脱壳。

    手动脱壳第一步是查找程序的真正入口点。

    先认识一下LordPE的使用;然后才能找OEP;此工具据说是一个很好的PE工具;这里的PE指Windows可执行文件;

壳的概念、LordPE的使用、C读取PE文件初步

壳的概念、LordPE的使用、C读取PE文件初步

壳的概念、LordPE的使用、C读取PE文件初步

下了几个LordPE;有的不能用;启动以后如下;

壳的概念、LordPE的使用、C读取PE文件初步

点 PE编辑器 按钮;加载原书13章用于练习的示例RebPE.exe;此时程序未加壳;

壳的概念、LordPE的使用、C读取PE文件初步

壳的概念、LordPE的使用、C读取PE文件初步

程序入口点是1130h;有4个区段;

使用原书第16章编写的一个加壳程序;来对上面程序加壳;

壳的概念、LordPE的使用、C读取PE文件初步

另外LordPE,点击L按钮,可查看PE文件详情;

壳的概念、LordPE的使用、C读取PE文件初步

加壳完毕;加壳后的程序被杀软认为木马;

壳的概念、LordPE的使用、C读取PE文件初步

信任;

壳的概念、LordPE的使用、C读取PE文件初步

然后用LordPE打开加壳后的exe文件;

壳的概念、LordPE的使用、C读取PE文件初步

程序入口点已经变为1300H;

壳的概念、LordPE的使用、C读取PE文件初步

并多出一个.pediy区段;按原文,此多出的区段就是外壳,相当于一个文件加载器;是否所有的壳,都会在PE里多出一个区段,就不了解;

启动ollydbg;选项;设置程序暂停点为主模块的入口点;

壳的概念、LordPE的使用、C读取PE文件初步

加载上面加壳之后的程序;按原文,因为加了壳,加载程序可能提示 所加载程序入口点超出代码范围;并没有提示;直接加载了加壳的程序;下面可以尝试查找OEP;先到这里;

壳的概念、LordPE的使用、C读取PE文件初步

因为都是对PE文件进行操作;下面先来用C#写一个程序;读取前面未加壳程序的PE信息,其中的DOS头信息;

DOS头结构是:14个word、4个word长的数组、word、word、10个word的数组、1个long;共64字节;

C#代码:

FileStream fs; fs = new FileStream("RebPE_back.exe", FileMode.OpenOrCreate, FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] dosheader = new byte[64]; dosheader = br.ReadBytes(64); textBox1.Text = "e_magic: " + BitConverter.ToString(dosheader, 0, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_cblp: " + BitConverter.ToString(dosheader, 2, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_cp: " + BitConverter.ToString(dosheader, 4, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_crlc: " + BitConverter.ToString(dosheader, 6, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_cparhdr: " + BitConverter.ToString(dosheader, 8, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_minalloc: " + BitConverter.ToString(dosheader, 10, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_maxalloc: " + BitConverter.ToString(dosheader, 12, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_ss: " + BitConverter.ToString(dosheader, 14, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_sp: " + BitConverter.ToString(dosheader, 16, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_csum: " + BitConverter.ToString(dosheader, 18, 2); textBox1.Text += Environment.NewLine; textBox1.Text += " e_ip: " + BitConverter.ToString(dosheader, 20, 2); textBox1.Text += Environment.NewLine; textBox1.Text += " e_cs: " + BitConverter.ToString(dosheader, 22, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_lfarlc: " + BitConverter.ToString(dosheader, 24, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_ovno: " + BitConverter.ToString(dosheader, 26, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_res: " + BitConverter.ToString(dosheader, 28, 8); textBox1.Text += Environment.NewLine; textBox1.Text += "e_oemid: " + BitConverter.ToString(dosheader, 36, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_oeminfo: " + BitConverter.ToString(dosheader, 38, 2); textBox1.Text += Environment.NewLine; textBox1.Text += "e_res2: " + BitConverter.ToString(dosheader, 40, 20); textBox1.Text += Environment.NewLine; textBox1.Text += "e_lfanew: " + BitConverter.ToString(dosheader, 60, 4); fs.Close(); br.Close();

添加using System.IO;

字节转换到16进制字符串使用BitConverter类;

运行情况如下;和LordPE获取的DOS头信息一致;

壳的概念、LordPE的使用、C读取PE文件初步

壳的概念、LordPE的使用、C读取PE文件初步

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/121530.html

(0)
上一篇 2025-10-23 08:20
下一篇 2025-10-23 08:33

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信