无痕 发表于 2015-9-25 16:49:39

vc++源码免杀预处理的N种方法

//自定义对齐方式
#pragma comment(linker,"/FILEALI:16")
#pragma comment(linker,"/ALIGN:16")//定义最小节的大小,数值越小程序体积越小,16为最小节,使用了这个编译器选项之后一般不能再对文件加壳

//自定义加载的库
#pragma comment(lib,"kernel32.lib")//表示链接kernel32-32.lib这个库
#pragma comment(lib,"shell32.lib")
#pragma comment(lib,"msvcrt.lib")//使用vc6.0动态链接库

//自定义函数入口
#pragma comment(linker,"/ENTRY:EntryPoint")
//更改默认的入口函数,之后就要用Exitprocess(0);才能正常退出
//如果设置入口函数为main则必须加上下面这句话
//#pragma comment(linker,"/entry:mainCRTStartup")

//设置子系统类型
#pragma comment(linker,"/subsystem:windows") //这样双击程序的时候就不会出现cmd窗口

//优化选项
#pragma comment(linker,"/opt:nowin98")
#pragma comment(linker,"/opt:ref")
#pragma comment(linker,"/OPT:ICF")

//区段合并
#pragma comment(linker,"/MERGE:.rdata=.data")//把rdata区段合并到data区段里
#pragma comment(linker,"/MERGE:.text=.data")//把text区段合并到data区段里
#pragma comment(linker,"/MERGE:.reloc=.data")//把text区段合并到data区段里
#pragma comment(linker,"/section:data,RWE")//设置区段属性 RWE是可读、可写、可执行的意思

#pragma code_seg("PAGE") //其中PAGE是区段的名称
//这个是免杀中最有用的一个编译器选项,他可以把CPP文件里的代码放到一个单独的区段里,这样在对付杀毒软件的代码查杀的时候,给我们带来了非常大的方便

//延时加载函数
#pragma comment(lib, "DELAYIMP.LIB")
#pragma comment(linker, "/DELAYLOAD:WININET.dll")
#pragma comment(linker, "/DELAYLOAD:WS2_32.dll")
#pragma comment(linker, "/DELAYLOAD:PSAPI.DLL")
#pragma comment(linker, "/DELAYLOAD:GDI32.dll")
#pragma comment(linker, "/DELAYLOAD:ADVAPI32.dll")
#pragma comment(linker, "/DELAYLOAD:SHELL32.dll")
#pragma comment(linker, "/DELAYLOAD:WINMM.dll")
#pragma comment(linker, "/DELAYLOAD:USER32.dll")
#pragma comment(linker, "/DELAYLOAD:WTSAPI32.dll")
#pragma comment(linker, "/DELAYLOAD:AVICAP32.dll")
#pragma comment(linker, "/DELAYLOAD:SHLWAPI.dll")
#pragma comment(linker, "/DELAYLOAD:IMM32.dll")
#pragma comment(linker, "/DELAYLOAD:urlmon.dll")
#pragma comment(linker, "/DELAYLOAD:OLEAUT32.dll")
#pragma comment(linker, "/DELAYLOAD:ole32.dll")
#pragma comment(linker, "/DELAYLOAD:NETAPI32.dll")
#pragma comment(linker, "/DELAY:nobind")
#pragma comment(linker, "/DELAY:unload")

//源码花指令:

__asm nop;
__asm nop;
__asm nop;
===========================================================
                __asm
                {
                        bsf eax, ecx
                              shr ah, cl
                              not ebx
                              bswap eax
                              mov bh, 0x8C
                              btr eax, 0xED
}
================================================================
      __asm
      {
                        xchg eax, eax
                        bt eax, 0xE0
                        xor ah, 0x3D
                        sub al, 0xFFFFFFB5
                        test ebx, ebp
                        xor al, al
                        xadd eax, eax
                        xadd ah, al
                        neg eax
                        imul eax, ebx, 0x78B3BBF9
                        inc eax
                        imul eax, edx, 0xF9539B11
                        and eax, 0xC7E2D3CE
                        movsx eax, si
                        bsf eax, ecx
                        movsx eax, bx
                        btc eax, 0x0B
                        dec eax
                        test bl, cl
                        mov eax, 0x2E383802
                        mov ah, 0x3D
                        mov ah, 0x8E
                        shrd eax, ebp, cl
                        movzx eax, dh
                        movsx eax, bl
                        test eax, ecx
                        shrd eax, esi, cl
                        rcl ah, 0x62
                        test edi, ecx
                        imul eax, ebp
                        bsf eax, edx
                        xadd al, ah
                        test esi, edi
                        dec al
                        bswap eax
                        dec ah
                        rep sub al, cl
      }
========================================================
      __asm
      {
                              ;检测代码开始
                mov   esi,dwAddr
                              mov   ecx,100
                              xor   eax,eax
checksum_loop:
                movzx         ebx,byte ptr
                add         eax,ebx
                rol         eax,1
                inc         esi
                loop         checksum_loop

                cmp         eax,CHECK_SUM               
                              jz      ODNotFound
                              mov   bFoundOD,1
      ODNotFound:                              
      }
============================================================
      __asm
      {
                jmp   CodeEnd   
CodeStart:   mov   eax,ecx;被保护的程序段
                         nop
                         push    eax
                         push    ecx
                         pop   ecx
                         pop   eax
CodeEnd:   
                cld               ;检测代码开始
                        mov   edi,offset CodeStart
                        mov   edx,offset CodeStart
                        mov   ecx,offset CodeEnd
                        sub   ecx,edx
                        
                        mov   al,0CCH
                        repne   scasb
                        jnz      ODNotFound
                        mov bFoundOD,1
ODNotFound:                              
      }
======================================================
__asm
{
                btr ebx, 0xF4
                xadd eax, ebx
                xchg eax, ebx
                test eax, 0x534F82BB
                sub bl, dl
                mov eax, edx
                xchg bl, al
                mov al, cl
                movzx ebx, bx
                not bh
                rcl ebx, 0x4B
                or eax, 0x393EEB01
                imul ebx, ebp, 0x5A429437
                movzx eax, si
                mov eax, 0xFC226531
                test edx, ebx
                sub bh, 0xFFFFFF82
                test al, bl
                bsr eax, ebp
                shr ebx, 0x01
                imul ebx, eax, 0xD815A07E
                sbb al, 0x7B
                test edi, edi
                repnz shl bl, cl
                movsx ebx, dx
                neg bl
                bswap ebx
                add ah, al
                not eax
                xadd bl, al
                shrd ebx, eax, cl
                movzx eax, cx
                mov bl, 0x5D
                imul ebx, esi, 0x9C792C83
                neg ah
                movzx ebx, dh
      inc eax
}
===============================================
__asm
{
                adc ah, ch
                mov eax, esi
                add al, 0x2D
                bsr eax, eax
                test al, 0x15
                dec eax
                mov eax, 0x740CFE0F
                inc eax
                bsr eax, ecx
                sbb eax, 0xAE51CAB1
                mov ah, 0xBA
                imul eax, esi
                mov eax, edx
                movsx eax, dx
                mov eax, 0x6D9E9FB6
                shld eax, ecx, cl
                shl al, 0xAA
                ror eax, 0x01
                bt eax, ebp
                rcr eax, cl
                test bh, dh
                bts eax, esi
                bsr eax, edx
                inc eax
                bsf eax, ecx
                test dl, 0x11
                or eax, esi
                adc eax, eax
                mov al, ch
                dec eax
                shl al, 0x01
                btc eax, 0x3C
                movsx eax, bx
                bsf eax, ebx
                btc eax, 0x04
                shld eax, ebp, 0x15
                imul eax, edi
                rol al, 0x01
                xadd ah, al
      not ah
}
=============================================
      __asm
      {
                shrd eax, edx, 0xA3
                        movsx eax, al
                        mov eax, edi
                        not ah
                        sbb eax, ebp
                        shrd eax, eax, cl
                        bsf eax, eax
                        bsf eax, edx
                        or eax, ecx
                        imul eax, edi
                        bt eax, 0xB8
                        sub eax, edi
                        mov ah, ah
                        mov al, bl
                        btr eax, 0x95
                        btr eax, esi
                        xor eax, 0x7E545409
                        bt eax, 0xEC
                        bswap eax
                        shld eax, esi, cl
                        sub eax, 0x30447C2E
                        shld eax, edi, cl
                        imul eax, 0xBBA11E53
                        test edi, ebp
                        and eax, 0xF4A72A6D
                        dec ah
                        shld eax, esi, 0xCD
                        movzx eax, bh
                        inc eax
                        test al, 0x70
                        movzx eax, cx
                        shr ah, 0x8B
                        cmp al, 0x58
                        or ah, dl
                        imul eax, esi
                        mov ah, ch
                        mov eax, ecx
                        not al
                        mov eax, 0xBCB63BD5
                        bsr eax, ebx
                        shrd eax, ebx, cl
                        btr eax, 0x0B
                        
}
===============================================
      __asm
      {
                jmp   CodeEnd   
CodeStart:   mov   eax,ecx;被保护的程序段
                         nop
                         push    eax
                         push    ecx
                         pop   ecx
                         pop   eax
CodeEnd:   
                cld               ;检测代码开始
                        mov   edi,offset CodeStart
                        mov   edx,offset CodeStart
                        mov   ecx,offset CodeEnd
                        sub   ecx,edx
                        
                        mov   al,0CCH
                        repne   scasb
                        jnz      ODNotFound
                        mov bFoundOD,1
ODNotFound:                              
      }

lyz1065310188 发表于 2015-9-25 17:24:19

老大,防上传代码有木有啊。

sunlizhu 发表于 2015-9-25 19:40:53

lyz1065310188 发表于 2015-9-25 17:24
老大,防上传代码有木有啊。

我有 您加我QQ 吧 免费分享你 955 124 微信haozhengtu

Cloudraker 发表于 2015-10-19 21:45:45

太深奥,还在学习中,谢谢楼主分享

243507796 发表于 2015-11-8 20:18:53

谢谢6666666666
页: [1]
查看完整版本: vc++源码免杀预处理的N种方法