|
[讨论]DNGuard HVM还有人搞么?最新4.5版本
“但是不知道MSIL在HVMRun64.dll的位置”:运行库里没有msil代码或者加密后的代码,这些内容都在被保护后的程序集里面。 |
|
[原创]看雪 2023·KCTF 年度赛 Crackme by 心学
tgcwc htg老师您好,购买了您的.net课程,怎么下载课件和加入微信群,麻烦您了?请联系 Editor@看雪 进入微信群,课件可从课程里的课件栏目下的附件处下载。 |
|
|
|
[原创] KCTF 2023 第三题 wp - 98k
按下F5,弹出Warning消息框“ Sorry, you do not have a decompiler for the current file. You can decompile code for the following processor(s): ARM64, x64, x86 ” |
|
|
|
|
|
[原创]看雪 2023·KCTF 年度赛 Crackme by 心学
题目的相关资料已完成。 |
|
[原创]看雪 2023·KCTF 年度赛 Crackme by 心学
好的,我得完善下可能存在的多解问题。 |
|
[原创]二次筛法研究学习笔记
有没有继续在深入讲解数域筛法,SNFS或GNFS,感觉太难理解了。 |
|
[原创]二次筛法研究学习笔记
内容不错,由浅入深 |
|
|
|
[求助]yafu因式分解工具
如果电脑里存在一个集成显卡(无CUDA),一个独立显卡(有CUDA),那么如何在 factmsieve.py 设置了? USE_CUDA = True GPU_NUM = 2 将会造成读取集成显卡失败,因为没有集成显卡里没有CUDA |
|
[原创] 看雪 2022 KCTF 秋季赛 第八题 商贸往来 wp
把算法全分析出来了。 |
|
|
|
[原创]看雪 2022·KCTF 春季赛 > 第五题 危机四伏 by 心学
2022-10-14 2325 发现新的匹配方式: 看来需要现对等效代码做一个替换,然后再用通用的方式来处理,这里还是涉及到长跳转的处理。 lea esp, [esp-4] jmp ...... mov [esp+8+var_8], edi ///等效为 【push edi】 等效为 【push edi】 ---------------------------------- mov eax, [esp+0Ch+var_C] ///等效为 【pop eax】 jmp loc_12F11B lea esp, [esp+4] 等效为 【pop eax】 seg000:000089C8 loc_89C8: ; CODE XREF: sub_1DC2DF:loc_58E65↓j seg000:000089C8 pushf seg000:000089C9 jmp loc_1EBF44 seg000:001EBF44 loc_1EBF44: ; CODE XREF: sub_1DC2DF-1D3916↑j seg000:001EBF44 pushf seg000:001EBF45 jmp loc_7961A seg000:0007961A loc_7961A: ; CODE XREF: seg000:001BE3E8↓j seg000:0007961A ; sub_1DC2DF+FC66↓j seg000:0007961A lea esp, [esp-4] seg000:0007961E mov [esp+8+var_8], edi ///等效为 【push edi】 seg000:00079621 jmp loc_1F1B2E seg000:001F1B2E loc_1F1B2E: ; CODE XREF: sub_1DC2DF-162CBE↑j seg000:001F1B2E lea esp, [esp-4] seg000:001F1B32 mov [esp+0Ch+var_C], eax ///等效为 【push eax】 seg000:001F1B35 jmp loc_85EEC seg000:00085EEC loc_85EEC: ; CODE XREF: sub_1DC2DF+15856↓j seg000:00085EEC jmp loc_20B1E8 seg000:0020B1E8 loc_20B1E8: ; CODE XREF: sub_1DC2DF:loc_85EEC↑j seg000:0020B1E8 xor eax, eax seg000:0020B1EA jmp loc_1A1C4 seg000:0001A1C4 loc_1A1C4: ; CODE XREF: sub_1DC2DF+2EF0B↓j seg000:0001A1C4 jmp loc_E2395 seg000:000E2395 loc_E2395: ; CODE XREF: sub_1DC2DF:loc_1A1C4↑j seg000:000E2395 ; seg000:loc_7AB77↑j seg000:000E2395 cmp eax, 6 seg000:000E2398 jmp loc_86E48 seg000:00086E48 loc_86E48: ; CODE XREF: sub_1DC2DF-F9F47↓j seg000:00086E48 jz loc_82FF5 seg000:00086E4E jmp loc_6F4B4 seg000:0006F4B4 loc_6F4B4: ; CODE XREF: sub_1DC2DF-155491↓j seg000:0006F4B4 inc eax seg000:0006F4B5 jmp loc_21BB65 seg000:0021BB65 loc_21BB65: ; CODE XREF: sub_1DC2DF-16CE2A↑j seg000:0021BB65 adc edi, 17EF568Dh seg000:0021BB6B pushf 【新的嵌套循环】 seg000:0021BB6C jmp loc_1440CF seg000:001440CF loc_1440CF: ; CODE XREF: sub_1DC2DF+3F88D↓j seg000:001440CF jmp loc_15C847 seg000:0015C847 loc_15C847: ; CODE XREF: sub_1DC2DF:loc_1440CF↑j seg000:0015C847 push ebx seg000:0015C848 push eax seg000:0015C849 jmp loc_273C72 ------ seg000:00082FF5 loc_82FF5: ; CODE XREF: seg000:0007AB7D↑j seg000:00082FF5 ; sub_1DC2DF:loc_86E48↓j seg000:00082FF5 mov eax, [esp+0Ch+var_C] ///等效为 【pop eax】 seg000:00082FF8 jmp loc_12F11B seg000:0012F11B loc_12F11B: ; CODE XREF: sub_1DC2DF-1592E7↑j seg000:0012F11B lea esp, [esp+4] seg000:0012F11F pushf 【新的嵌套循环】 seg000:0002042D loc_2042D: ; CODE XREF: sub_1DC2DF-AD1BF↓j seg000:0002042D push edx seg000:0002042E push ecx seg000:0002042F jmp loc_2606FB |
|
[原创]看雪 2022·KCTF 春季赛 > 第五题 危机四伏 by 心学
dump2.exe:第二段代码是32bit,里面有大量花指令,需要进行清除之后,才方便进行程序逻辑分析。 花指令的特征主要有如下几处: 一、连续的指令 1、ebp、esp还原【是后面的特例】 seg000:000CC824 014 55 push ebp seg000:000CC825 018 89 E5 mov ebp, esp seg000:000CC827 018 8D 64 24 FC lea esp, [esp-4] seg000:000CC82B 01C 89 EC mov esp, ebp seg000:000CC82D 01C 5D pop ebp 2、esp还原【是后面的特例】 seg000:000C5FBA 01C 52 push edx seg000:000C5FBB 020 8D 64 24 04 lea esp, [esp+4] 3、无用指令【待核实,只有一处】 seg000:0021C40D 84 56 C7 test [esi-39h], dl seg000:0021C410 08 00 or [eax], al
1、ebp、esp还原【中间嵌入长跳转】 seg000:000CC824 014 55 push ebp seg000:000CC825 018 89 E5 mov ebp, esp seg000:000CC827 018 8D 64 24 FC lea esp, [esp-4] seg000:000CC82B 01C 89 EC mov esp, ebp seg000:000CC82D 01C 5D pop ebp 2、esp还原【中间嵌入长跳转】 seg000:000C5FBA 01C 52 push edx seg000:000C5FBB 020 8D 64 24 04 lea esp, [esp+4] 3、pushf、popf还原【中间嵌入长跳转】 seg000:002A0496 loc_2A0496: ; CODE XREF: seg000:00000001↑j seg000:002A0496 9C pushf seg000:002A0497 51 push ecx seg000:002A0498 50 push eax seg000:002A0499 31 C0 xor eax, eax seg000:002A049B seg000:002A049B loc_2A049B: ; CODE XREF: seg000:002A04B3↓j seg000:002A049B 83 F8 03 cmp eax, 3 seg000:002A049E 74 15 jz short loc_2A04B5 seg000:002A04A0 40 inc eax seg000:002A04A1 81 E9 2E CD 9B A2 sub ecx, 0A29BCD2Eh seg000:002A04A7 81 C9 07 48 0C 20 or ecx, 200C4807h seg000:002A04AD 81 D9 2B 22 BB B1 sbb ecx, 0B1BB222Bh seg000:002A04B3 72 E6 jb short loc_2A049B seg000:002A04B5 seg000:002A04B5 loc_2A04B5: ; CODE XREF: seg000:002A049E↑j seg000:002A04B5 58 pop eax seg000:002A04B6 59 pop ecx seg000:002A04B7 9D popf 4、pushf、popf还原【中间嵌入长跳转、还嵌套自身】 seg000:002AE278 9C pushf seg000:002AE279 E9 5E 37 FB FF jmp loc_2619DC seg000:002619DC loc_2619DC: ; CODE XREF: seg000:002AE279↓j seg000:002619DC 52 push edx seg000:002619DD 51 push ecx seg000:002619DE 9C pushf 【此处 嵌套了自身】 seg000:002619DF 50 push eax seg000:002619E0 52 push edx seg000:002619E1 31 D2 xor edx, edx seg000:002619E3 seg000:002619E3 loc_2619E3: ; CODE XREF: seg000:002619F8↓j seg000:002619E3 83 FA 0A cmp edx, 0Ah seg000:002619E6 74 12 jz short loc_2619FA seg000:002619E8 42 inc edx seg000:002619E9 05 3F 86 3A 6F add eax, 6F3A863Fh seg000:002619EE 0D 99 24 DF 25 or eax, 25DF2499h seg000:002619F3 05 D0 BA 30 4B add eax, 4B30BAD0h seg000:002619F8 7E E9 jle short loc_2619E3 seg000:002619FA seg000:002619FA loc_2619FA: ; CODE XREF: seg000:002619E6↑j seg000:002619FA 5A pop edx seg000:002619FB 58 pop eax seg000:002619FC 9D popf seg000:002619FD E9 B6 62 EC FF jmp loc_127CB8 seg000:00127CB8 loc_127CB8: ; CODE XREF: seg000:002619FD↓j seg000:00127CB8 31 C9 xor ecx, ecx seg000:00127CBA seg000:00127CBA loc_127CBA: ; CODE XREF: seg000:000FAD33↑j seg000:00127CBA 83 F9 06 cmp ecx, 6 seg000:00127CBD 55 push ebp seg000:00127CBE 89 E5 mov ebp, esp seg000:00127CC0 8D 64 24 FC lea esp, [esp-4] seg000:00127CC4 89 EC mov esp, ebp seg000:00127CC6 5D pop ebp seg000:00127CC7 E9 E0 48 F4 FF jmp loc_6C5AC seg000:0006C5AC loc_6C5AC: ; CODE XREF: seg000:00127CC7↓j seg000:0006C5AC 0F 84 15 0A FF FF jz loc_5CFC7 seg000:0006C5B2 41 inc ecx seg000:0006C5B3 E9 78 7B 1B 00 jmp loc_224130 seg000:00224130 loc_224130: ; CODE XREF: seg000:0006C5B3↑j seg000:00224130 81 FA 6B 15 C8 6D cmp edx, 6DC8156Bh seg000:00224136 81 E2 38 42 C7 AF and edx, 0AFC74238h seg000:0022413C E9 EC 6B ED FF jmp loc_FAD2D seg000:000FAD2D loc_FAD2D: ; CODE XREF: seg000:0022413C↓j seg000:000FAD2D 81 DA FA A1 7F 86 sbb edx, 867FA1FAh seg000:000FAD33 0F 80 81 CF 02 00 jo loc_127CBA seg000:000FAD39 E9 89 22 F6 FF jmp loc_5CFC7 seg000:0005CFC7 loc_5CFC7: ; CODE XREF: seg000:loc_6C5AC↓j seg000:0005CFC7 ; seg000:000FAD39↓j seg000:0005CFC7 59 pop ecx seg000:0005CFC8 5A pop edx seg000:0005CFC9 E9 54 CF 1E 00 jmp loc_249F22 seg000:00249F22 loc_249F22: ; CODE XREF: seg000:0005CFC9↑j seg000:00249F22 9D popf seg000:00249F23 8D 64 24 04 lea esp, [esp+4] seg000:00249F27 E9 4B AA E9 FF jmp loc_E4977 seg000:000E4977 loc_E4977: ; CODE XREF: seg000:00249F27↓j seg000:000E4977 E9 C5 2E 1A 00 jmp loc_287841 seg000:00287841 loc_287841: ; CODE XREF: seg000:loc_E4977↑j seg000:00287841 9D popf 这两个花指令的简略特征是: 9C pushf 52 push edx 51 push ecx 31 C9 xor ecx, ecx 83 F9 08 cmp ecx, 8 【JZ 后续代码 的最后一个有条件跳转会 跳转到此处】 0F 84 A2 17 E4 FF jz loc_E9020 59 pop ecx 5A pop edx 9D popf 【JZ】后续代码 特征1: 47 inc edi 81 EA 4A 0A 6A C8 sub edx, 0C86A0A4Ah 81 F2 F7 12 2D EE xor edx, 0EE2D12F7h 81 EA C6 07 02 1C sub edx, 1C0207C6h 0F 89 FB E3 13 00 jns loc_1D2296 特征2: 43 inc ebx 1D F3 63 58 CC sbb eax, 0CC5863F3h 25 DC C9 C5 7F and eax, 7FC5C9DCh 05 C8 9D D9 2E add eax, 2ED99DC8h 0F 8D FB 01 FA FF jge loc_1A7C7E 特征3: 41 inc ecx 3D 7C AA 0E E6 cmp eax, 0E60EAA7Ch 35 93 5A FA 84 xor eax, 84FA5A93h 1D 64 15 D9 23 sbb eax, 23D91564h 0F 88 B0 7F EA FF js loc_158A72 特征4: 41 inc ecx 81 D2 B7 D6 07 45 adc edx, 4507D6B7h 81 CA 5A 03 73 78 or edx, 7873035Ah 81 C2 10 EA 7D 71 add edx, 717DEA10h 0F 88 E1 61 03 00 js loc_1CC00A 特征5: 41 inc ecx 15 CB 30 92 03 adc eax, 39230CBh 25 86 2C C9 70 and eax, 70C92C86h 15 17 1C 96 C5 adc eax, 0C5961C17h 0F 86 FE 34 11 00 jbe loc_2077A4 现在需要对其进行批量消除 1、首先去除固定的连续指令序列,这个较为简单,也能很快去除。 2、其次去除带有跳转的不连续指令序列,这个较为麻烦,需要分析指令。 3、检查,是否有遗漏,或是错误删除。 在消除过程中:注意需要将JZ处指令,改成JMP,强制跳转过去【可有效避免F5时垃圾代码生成】;将pushf处指令改为jmp,直接跳转到popf之后的指令【跳出花指令干扰】。 留出疑问: 1、尝试,不对垃圾指令进行nop,是否能够避免错误? 2、代码里面存在 自加密解密,那采用nop会存在错误。。。 附python代码:仅供参考,去除完成之后,发现代码存在问题,一是没有全部清除干净,二是存在错误指令,疑似删错。 ############################################################################## #清除单个:注意主线的JMP保留【0-8】、支线的JMP消除【9-13】。 def clearSingle(patternList): #考虑清除 # 全部清0,将 jz 设置为 jmp if len(patternList)<=0: return for p in patternList: #实际上是第5条指令,如果有重复的JZ,那就需要只处理第5条指令。 if p[1].upper() == "JZ": #修改机器码 JMP if idc.get_wide_byte(p[0]) == 0x74: ida_bytes.patch_byte(p[0],0xEB) elif idc.get_wide_word(p[0])==0x840F: ida_bytes.patch_word(p[0],0xE990) continue else: #nop #my_nop(p[0],NextHead(p[0]))#有可能误删 nextAddr = idaapi.decode_insn(idaapi.insn_t(),p[0]) + p[0] my_nop(p[0],nextAddr) ###或者再进一步搜索一下,直接将分支都nop,但是如何才能得知回到循环了? ####修改首地址,跳转到末尾 def ModifySingle(patternList,endAddrIndex): if len(patternList)<=0: return startAddr = patternList[0][0] endAddr = patternList[endAddrIndex][0] insn = idaapi.insn_t() endAddr = idaapi.decode_insn(insn,endAddr) + endAddr PrintInfo2("#"*10+"修改首位地址,使其跳转到尾部。") PrintInfo2("startAddr=0x{:X},endAddr=0x{:X}".format(startAddr,endAddr)) patch_byte(startAddr,0xE9) ######################### ## startAddr = 0x2A0496 ## endAddr = 0x2A04B8 ## ## endAddr = 0x2A048D ######################### #### diffValue = endAddr - startAddr - 5 ####支持负数处理 value = struct.unpack('>L', struct.pack('l', diffValue))[0] & 0xFFFFFFFF #value = 0x1d000000 bytesValue = struct.pack('>L',value) #bytesValue = b'\x1d\x00\x00\x00' #strValue = bytesValue.hex() #strValue = '1d000000' #value = hex(value)[2:] idaapi.patch_bytes(startAddr+1,bytesValue)
最后于 2022-8-31 13:13
被htg编辑
,原因:
|