C语言写花指令,[原创]写花指令-加壳脱壳-看雪论坛-安全社区|安全招聘|bbs.pediy.com...

[原创]写花指令

2013-8-16 15:41

9889

[原创]写花指令

2013-8-16 15:41

9889

花指令,就是一串用来迷惑反编译器的汇编指令,它是利用编译器线性扫描算法的缺陷来达到的,比如说反编译器读取到E8(对应CALL汇编码)这机器码,接着会往下读取四个字节的数据作为跳转地址,如果我们在写程序的时候嵌入_asm _emit 0E8,反编译器就会把下一条指令当做地址数据,不管下一条指令的四个字节是地址数据还是操作指令。

在EXE中加入花指令,只要记住程序原入口点,在程序中找个地方写一段保持堆栈平衡的花指令,然后跳转回原入口点,再用PE工具改写下入口点,使花指令开头段为程序入口点。

在源码中加入花指令,可以加个头文件,用定义的方式#define来写,在cpp中包含进来直接使用,下面是一些代码。

//添加花指令开关  注释掉 就可以无花指令调试程序

#define _start_add_FLOWER

#ifndef _start_add_FLOWER

#define _FLOWER_XX0 _asm nop

#else

#define _FLOWER_XX0 _asm \

{\

_asm jle $+0dh \               //  如果小于或等于 就跳转到当前地址加13的地址

_asm jg $+07h \               //如果大于  就跳转到当前地址加7的地址

_asm _emit 0E8h \                //花指令 程序执行前面两条指令会直接跳转过去,不会执行这条语句,只是迷惑反编译器

#endif

#ifndef _start_add_FLOWER

#define _FLOWER_XX1 _asm nop

#else

#define _FLOWER_XX1 _asm \

{\

_asm  _emit 090h\

_asm _emit 090h \

_asm _emit 090h \

_asm pushad\                   //保持堆栈平衡

_asm jmp $+36h\                //直接跳到popad处 这条指令开始往下数一共有36个字节

_asm mov ebp,esp \

_asm push -1 \

_asm push 112233h \

_asm push 332211h \

_asm mov eax,DWORD ptr fs:[0] \

_asm push eax \

_asm mov DWORD ptr fs:[0],esp \

_asm pop eax \

_asm mov dword ptr fs:[0],eax \

_asm pop eax \

_asm pop eax \

_asm pop eax \

_asm pop eax \

_asm mov ebp,eax\

_asm mov eax,401050h\

_asm push eax\

_asm _emit 0xE8\

_asm retn\

_asm popad\        // 保持堆栈平衡

}

#endif

……

可以定义从_FLOWER_XX0到_FLOWER_XX9等多个花指令

然后在CPP中使用

void test()

{

_FLOWER_XX0;

printf("you are writing flower_xx0,\n");

_FLOWER_XX1;

printf("you are writing flower_xx1,\n");

……

}

也可以定义花指令组,

#ifndef _start_add_FLOWER

#define _FLOWER_XX_GROUP0

#else

#define _FLOWER_XX_GROUP0 _FLOWER_XX0;_FLOWER_XX1;_FLOWER_XX2

#endif

第一次写,写的不好请见谅。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SEH异常的应用 SEH异常就是结构化异常处理,程序遇到SEH异常时,异常交给系统处理(这讲是一个非常负责的过程,很容易跟飞),所以利用SEH异常时可以一定程度的防止程度调试(SEH异常在壳里是很常见的)。 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push ******** //地址压入堆栈 mov eax,dword ptr fs:[0] push eax //fs[0]压入堆栈,执行完成后fs[0]指向堆栈 mov dword ptr fs:[0],esp //构造一个ERR结构 mov esi,0 //简单的赋值语句 mov eax,dword ptr ds:[esi] //产生异常 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push ******** mov eax,dword ptr fs:[0] push eax mov dword ptr fs:[0],esp mov ebx,0 div ebx ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nop push ******** mov eax,dword ptr fs:[0] push eax mov dword ptr fs:[0],esp int 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push ******** mov eax,dword ptr fs:[0] push eax mov dword ptr fs:[0],esp nop int 68 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push ******** mov eax,dword ptr fs:[0] push eax mov dword ptr fs:[0],esp nop vxdcall 134543 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push ******** mov eax,dword ptr fs:[0] push eax mov dword ptr fs:[0],esp ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push xxx push dword ptr fs:[0] mov fs:[0], esp stc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push xxx push dword ptr fs:[0] mov fs:[0], esp JMP 0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push xxx push dword ptr fs:[0] mov fs:[0], esp ret ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ push xxx push dword ptr fs:[0] mov fs:[0], esp pop ss
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值