找回密码
 注册
搜索
热搜: 回贴

手动脱壳入门第十五篇 FSG 1.33,手动脱壳,脱壳技术

2010-1-30 18:25| 发布者: admin| 查看: 93| 评论: 0|原作者: 韩菱纱


手动脱壳入门第十五篇 FSG 1.33,手动脱壳,脱壳技术
2008年06月23日 星期一 下午 07:31
手动脱壳入门第十五篇 FSG 1.33



【脱文标题】 手动脱壳入门第十五篇 FSG 1.33



【脱文作者】 weiyi75[Dfcg]



【作者邮箱】 weiyi75@sohu.com



【作者主页】 Dfcg官方大本营



【使用工具】 Peid,Ollydbg,ImportREC,Loadpe



【脱壳平台】 Win2K/XP



【软件名称】 Unpackme



【软件简介】 Loveboom用VB写的一个FSG压缩的脱壳练习程序



【软件大小】 2.65 KB



【加壳方式】 FSG 1.33 -> dulek/xt



【保护方式】 FSG压缩壳



【脱壳声明】 我是一只小菜鸟,偶得一点心得,愿与大家分享:)





--------------------------------------------------------------------------------



【脱壳内容】



首先Peid查壳,为FSG 1.33 -> dulek/xt,OD载入运行,无任何异常,判断其为压缩壳。



00404B58 > BE A4014000 mov esi, fsg1_33.004001A4 //外壳入口。

00404B5D AD lods dword ptr ds:[esi]

00404B5E 93 xchg eax, ebx

00404B5F AD lods dword ptr ds:[esi]

00404B60 97 xchg eax, edi

00404B61 AD lods dword ptr ds:[esi]

00404B62 56 push esi

00404B63 96 xchg eax, esi

00404B64 B2 80 mov dl, 80

00404B66 A4 movs byte ptr es:[edi], byte ptr ds:[esi>

00404B67 B6 80 mov dh, 80

00404B69 FF13 call dword ptr ds:[ebx]

00404B6B ^ 73 F9 jnb short fsg1_33.00404B66

00404B6D 33C9 xor ecx, ecx

00404B6F FF13 call dword ptr ds:[ebx]

00404B71 73 16 jnb short fsg1_33.00404B89

00404B73 33C0 xor eax, eax

00404B75 FF13 call dword ptr ds:[ebx]

00404B77 73 1F jnb short fsg1_33.00404B98



打开内存镜像,它工作区段就是404000 resources段里面,内存镜像断点没有作用。它也没有用PUSHAD等语句,ESP定律也不能用。据说FSG 1.33还有变形版本,单步慢慢跟踪太费时间,下API断点,也慢。



对付它最好的方法就是模拟跟踪,因为它没有SEH,模拟跟踪最好不过了。



内存镜像,项目 13

地址=00404000

大小=00001000 (4096.)

Owner=fsg1_33 00400000

区段=

包含=SFX,imports,resources // 当前段是在404000里面。

类型=Imag 01001002

访问=R

初始访问=RWE





内存镜像,项目 12

地址=00401000

大小=00003000 (12288.)

Owner=fsg1_33 00400000

区段=

包含=code //Oep肯定是在Code段里面。不管FSG在SFX,imports,resources区段里面解压,循环搞什么飞机。最后肯定要跨段访问401000



Code段。

类型=Imag 01001002

访问=R

初始访问=RWE



于是,命令行下



tc eip<404000 //模拟跟踪指令。



1分钟不到,Oep就到了。



00401160 68 db 68 //Oep,点清除分析看得习惯一点。

00401161 F8 db F8

00401162 13 db 13

00401163 40 db 40 ; CHAR ’@’

00401164 00 db 00

00401165 E8 db E8

00401166 F0 db F0

00401167 FF db FF

00401168 FF db FF

00401169 FF db FF

0040116A 00 db 00

0040116B 00 db 00

0040116C 00 db 00

0040116D 00 db 00

0040116E 00 db 00

0040116F 00 db 00

00401170 30 db 30 ; CHAR ’0’

.........................................................................................



00401160 68 F8134000 push fsg1_33.004013F8 //熟悉的VB程序入口特征码,Loadpe直接脱壳。

00401165 E8 F0FFFFFF call fsg1_33.0040115A ; jmp to MSVBVM60.ThunRTMain

0040116A 0000 add byte ptr ds:[eax], al

0040116C 0000 add byte ptr ds:[eax], al

0040116E 0000 add byte ptr ds:[eax], al

00401170 3000 xor byte ptr ds:[eax], al

00401172 0000 add byte ptr ds:[eax], al

00401174 3800 cmp byte ptr ds:[eax], al

00401176 0000 add byte ptr ds:[eax], al

00401178 0000 add byte ptr ds:[eax], al

0040117A 0000 add byte ptr ds:[eax], al

0040117C 95 xchg eax, ebp

0040117D ^ 75 A7 jnz short fsg1_33.00401126

.........................................................................................



脱壳后发现程序不能运行,这时需要用Imprec修复引入函数表(Import Table)



在Oep处填1160,点IT自动搜索,然后点获输入信息,看到输入表全部有效,点修复抓取文件按钮,选择Dump的文件,修复它,正常运行。



再看看API断点找Oep,单步跟踪FSG 1.33后,大家可以走捷径,当然是下API断点。



Btw: 前提是你有过单步跟踪Fsg的经验,不然你看不懂下面是什么意思。也就是第一次学某个壳要按正常方法单步跟踪找入口体会壳,不要取巧走捷径,精通了就可以走捷径脱壳。



00404B58 > BE A4014000 mov esi, fsg1_33.004001A4 //外壳入口。

00404B5D AD lods dword ptr ds:[esi]

00404B5E 93 xchg eax, ebx

00404B5F AD lods dword ptr ds:[esi]

00404B60 97 xchg eax, edi

00404B61 AD lods dword ptr ds:[esi]

00404B62 56 push esi

00404B63 96 xchg eax, esi

00404B64 B2 80 mov dl, 80

00404B66 A4 movs byte ptr es:[edi], byte ptr ds:[esi>

00404B67 B6 80 mov dh, 80

00404B69 FF13 call dword ptr ds:[ebx]

00404B6B ^ 73 F9 jnb short fsg1_33.00404B66

00404B6D 33C9 xor ecx, ecx

00404B6F FF13 call dword ptr ds:[ebx]

00404B71 73 16 jnb short fsg1_33.00404B89

00404B73 33C0 xor eax, eax

00404B75 FF13 call dword ptr ds:[ebx]

00404B77 73 1F jnb short fsg1_33.00404B98

00404B79 B6 80 mov dh, 80

00404B7B 41 inc ecx

00404B7C B0 10 mov al, 10

.........................................................................................



命令行



bp GetModuleHandleA



77E6AB06 > 55 push ebp //中断后清除断点。

77E6AB07 8BEC mov ebp, esp

77E6AB09 837D 08 00 cmp dword ptr ss:[ebp 8], 0

77E6AB0D 0F84 31F50000 je KERNEL32.77E7A044

77E6AB13 FF75 08 push dword ptr ss:[ebp 8]

77E6AB16 E8 9EC8FFFF call KERNEL32.77E673B9

77E6AB1B 85C0 test eax, eax

77E6AB1D 74 08 je short KERNEL32.77E6AB27

77E6AB1F FF70 04 push dword ptr ds:[eax 4]

77E6AB22 E8 5B560000 call KERNEL32.GetModuleHandleW

77E6AB27 5D pop ebp

77E6AB28 C2 0400 retn 4

77E6AB2B > 55 push ebp

77E6AB2C 8BEC mov ebp, esp

77E6AB2E 6A 00 push 0

77E6AB30 FF75 18 push dword ptr ss:[ebp 18]

77E6AB33 FF75 14 push dword ptr ss:[ebp 14]

77E6AB36 FF75 10 push dword ptr ss:[ebp 10]

77E6AB39 FF75 0C push dword ptr ss:[ebp C]

77E6AB3C FF75 08 push dword ptr ss:[ebp 8]

77E6AB3F E8 132E0000 call KERNEL32.GetPrivateProfileStringW

.........................................................................................



ALT F9 执行到用户代码。



00404BE6 95 xchg eax, ebp // 到这里。

00404BE7 AC lods byte ptr ds:[esi]

00404BE8 84C0 test al, al

00404BEA ^ 75 FB jnz short fsg1_33.00404BE7

00404BEC FE0E dec byte ptr ds:[esi]

00404BEE ^ 74 F0 je short fsg1_33.00404BE0

00404BF0 79 05 jns short fsg1_33.00404BF7

00404BF2 46 inc esi

00404BF3 AD lods dword ptr ds:[esi]

00404BF4 50 push eax

00404BF5 EB 09 jmp short fsg1_33.00404C00

00404BF7 FE0E dec byte ptr ds:[esi]

00404BF9 - 0F84 61C5FFFF je fsg1_33.00401160

00404BFF 56 push esi

00404C00 55 push ebp

00404C01 FF53 04 call dword ptr ds:[ebx 4]

00404C04 AB stos dword ptr es:[edi]

00404C05 ^ EB E0 jmp short fsg1_33.00404BE7

.........................................................................................



继续下



bp GetProcAddress



77E6E6A9 > 55 push ebp //清除断点,Ctrl F9返回。

77E6E6AA 8BEC mov ebp, esp

77E6E6AC 51 push ecx

77E6E6AD 51 push ecx

77E6E6AE 53 push ebx

77E6E6AF 57 push edi

77E6E6B0 8B7D 0C mov edi, dword ptr ss:[ebp C]

77E6E6B3 BB FFFF0000 mov ebx, 0FFFF

77E6E6B8 3BFB cmp edi, ebx

77E6E6BA 0F86 D3EB0000 jbe KERNEL32.77E7D293

77E6E6C0 8D45 F8 lea eax, dword ptr ss:[ebp-8]

77E6E6C3 57 push edi

77E6E6C4 50 push eax

77E6E6C5 FF15 2413E677 call dword ptr ds:[<&NTDLL.RtlInitString>; ntdll.RtlInitString

77E6E6CB 8D45 0C lea eax, dword ptr ss:[ebp C]

77E6E6CE 50 push eax

77E6E6CF 8D45 F8 lea eax, dword ptr ss:[ebp-8]

77E6E6D2 6A 00 push 0

77E6E6D4 50 push eax

77E6E6D5 6A 00 push 0

77E6E6D7 FF75 08 push dword ptr ss:[ebp 8]

77E6E6DA E8 15B10000 call KERNEL32.77E797F4

.........................................................................................



00404BE4 FF13 call dword ptr ds:[ebx]

00404BE6 95 xchg eax, ebp

00404BE7 AC lods byte ptr ds:[esi]

00404BE8 84C0 test al, al

00404BEA ^ 75 FB jnz short fsg1_33.00404BE7

00404BEC FE0E dec byte ptr ds:[esi]

00404BEE ^ 74 F0 je short fsg1_33.00404BE0

00404BF0 79 05 jns short fsg1_33.00404BF7

00404BF2 46 inc esi

00404BF3 AD lods dword ptr ds:[esi]

00404BF4 50 push eax

00404BF5 EB 09 jmp short fsg1_33.00404C00

00404BF7 FE0E dec byte ptr ds:[esi]

00404BF9 - 0F84 61C5FFFF je fsg1_33.00401160 //这里跨段跳跃到4010000 段了,肯定是Oep入口跳转。

00404BFF 56 push esi

00404C00 55 push ebp

00404C01 FF53 04 call dword ptr ds:[ebx 4]

00404C04 AB stos dword ptr es:[edi] //返回到这里,滚动条往上看。

00404C05 ^ EB E0 jmp short fsg1_33.00404BE7

.........................................................................................



于是命令行。



g 401160



00401160 68 db 68 //Oep,点清除分析看得习惯一点。

00401161 F8 db F8

00401162 13 db 13

00401163 40 db 40 ; CHAR ’@’

00401164 00 db 00

00401165 E8 db E8

00401166 F0 db F0

00401167 FF db FF

00401168 FF db FF

00401169 FF db FF

0040116A 00 db 00

0040116B 00 db 00

0040116C 00 db 00

0040116D 00 db 00

0040116E 00 db 00

0040116F 00 db 00

00401170 30 db 30 ; CHAR ’0’

.........................................................................................



00401160 68 F8134000 push fsg1_33.004013F8 //熟悉的VB程序入口特征码,Loadpe直接脱壳。

00401165 E8 F0FFFFFF call fsg1_33.0040115A ; jmp to MSVBVM60.ThunRTMain

0040116A 0000 add byte ptr ds:[eax], al

0040116C 0000 add byte ptr ds:[eax], al

0040116E 0000 add byte ptr ds:[eax], al

00401170 3000 xor byte ptr ds:[eax], al

00401172 0000 add byte ptr ds:[eax], al

00401174 3800 cmp byte ptr ds:[eax], al

00401176 0000 add byte ptr ds:[eax], al

00401178 0000 add byte ptr ds:[eax], al

0040117A 0000 add byte ptr ds:[eax], al

0040117C 95 xchg eax, ebp

0040117D ^ 75 A7 jnz short fsg1_33.00401126

.........................................................................................



脱壳后发现程序不能运行,这时需要用Imprec修复引入函数表(Import Table)



在Oep处填1160,点IT自动搜索,然后点获输入信息,看到输入表全部有效,点修复抓取文件按钮,选择Dump的文件,修复它,正常运行。

"手动脱壳入门第十五篇"脱壳动画!

另:如果我没有记错的话,CCG的hoto前辈写的CRACKME就用了这个壳,但是变形的,有难度的。偶把它一起打包了,能脱了它并破了它,就可以去加入CCG了。




最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-29 19:25 , Processed in 0.286994 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部