首页
社区
课程
招聘
[原创]第二题分析
发表于: 2016-11-5 19:34 9303

[原创]第二题分析

2016-11-5 19:34
9303
bp GetWindowTextA就可以到达获取注册码的关键点

00401482  /$  55            push    ebp
00401483  |.  8BEC          mov     ebp, esp
00401485  |.  83EC 10       sub     esp, 0x10
00401488  |.  8365 FC 00    and     dword ptr [ebp-0x4], 0x0
0040148C  |.  8365 F4 00    and     dword ptr [ebp-0xC], 0x0
00401490  |.  8D45 F4       lea     eax, dword ptr [ebp-0xC]
00401493  |.  50            push    eax
00401494  |.  8D45 FC       lea     eax, dword ptr [ebp-0x4]
00401497  |.  50            push    eax
00401498  |.  E8 4D030000   call    004017EA    ; 这个call获取注册码并判断长度为16位,还有确保在字符0-9,a-z,A-Z之中
0040149D  |.  59            pop     ecx
0040149E  |.  85C0          test    eax, eax
004014A0  |.  59            pop     ecx
004014A1  |.  74 7D         je      short 00401520
004014A3  |.  56            push    esi
004014A4  |.  BE 00010000   mov     esi, 0x100
004014A9  |.  56            push    esi
004014AA  |.  E8 FBA00100   call    0041B5AA
004014AF  |.  56            push    esi
004014B0  |.  68 64D84200   push    0042D864
004014B5  |.  50            push    eax
004014B6  |.  8945 F8       mov     dword ptr [ebp-0x8], eax
004014B9  |.  E8 12A10100   call    <alloc_heap>
004014BE  |.  0FB605 1CD242>movzx   eax, byte ptr [0x42D21C]
004014C5  |.  83C4 10       add     esp, 0x10
004014C8  |.  8B0D 50984300 mov     ecx, dword ptr [0x439850]
004014CE  |.  8975 F0       mov     dword ptr [ebp-0x10], esi
004014D1  |.  50            push    eax
004014D2  |.  8D45 F0       lea     eax, dword ptr [ebp-0x10]
004014D5  |.  50            push    eax
004014D6  |.  8D45 F8       lea     eax, dword ptr [ebp-0x8]
004014D9  |.  50            push    eax
004014DA  |.  E8 439F0100   call    <copy_memory>   ;这名字是我自己注释的,名字不一定正确,大意就是往 buffer里复制n个字节,基本上这个代码配套都是这样,上面还有一个alloc_heap
004014DF  |.  85C0          test    eax, eax
004014E1  |.  5E            pop     esi
004014E2  |.  74 0F         je      short 004014F3
004014E4  |.  68 20030000   push    0x320
004014E9  |.  FF75 F8       push    dword ptr [ebp-0x8]   ;这里显示“正在注册”信息,0x320应该是sleep时间吧
004014EC  |.  E8 CFFCFFFF   call    004011C0
004014F1  |.  59            pop     ecx
004014F2  |.  59            pop     ecx
004014F3  |>  837D F8 00    cmp     dword ptr [ebp-0x8], 0x0
004014F7  |.  74 09         je      short 00401502
004014F9  |.  FF75 F8       push    dword ptr [ebp-0x8]
004014FC  |.  E8 B7A00100   call    0041B5B8
00401501  |.  59            pop     ecx
00401502  |>  8B0D 50984300 mov     ecx, dword ptr [0x439850]
00401508  |.  8D45 F4       lea     eax, dword ptr [ebp-0xC]
0040150B  |.  50            push    eax
0040150C  |.  8D45 FC       lea     eax, dword ptr [ebp-0x4]
0040150F  |.  50            push    eax
00401510  |.  E8 DC990100   call    0041AEF1                       ; 这是关键call
00401515  |.  85C0          test    eax, eax
00401517  |.  74 1A         je      short 00401533
00401519  |.  E8 39000000   call    00401557
0040151E  |.  EB 18         jmp     short 00401538
00401520  |>  837D FC 00    cmp     dword ptr [ebp-0x4], 0x0
00401524  |.  74 12         je      short 00401538
00401526  |.  FF75 FC       push    dword ptr [ebp-0x4]
00401529  |.  E8 E2A30100   call    0041B910
0040152E  |.  85C0          test    eax, eax
00401530  |.  59            pop     ecx
00401531  |.  76 05         jbe     short 00401538
00401533  |>  E8 CC000000   call    00401604
00401538  |>  8B0D 50984300 mov     ecx, dword ptr [0x439850]
0040153E  |.  8D45 F4       lea     eax, dword ptr [ebp-0xC]
00401541  |.  50            push    eax
00401542  |.  8D45 FC       lea     eax, dword ptr [ebp-0x4]
00401545  |.  50            push    eax
00401546  |.  E8 619F0100   call    0041B4AC    ; 这个是关键的算法call,最后看
0040154B  |.  33C0          xor     eax, eax
0040154D  |.  C9            leave
0040154E  \.  C3            retn



这个cm里的字符串都是加密的,无法用od找到字符串,这里就略过详细的加密,我也没看
直接看关键call
...
0041AF51  |.  FF75 F8       push    dword ptr [ebp-0x8]
0041AF54  |.  68 64DA4200   push    0042DA64
0041AF59  |.  50            push    eax
0041AF5A  |.  E8 71060000   call    <alloc_heap>
0041AF5F  |.  0FB605 04D242>movzx   eax, byte ptr [0x42D204]
0041AF66  |.  83C4 0C       add     esp, 0xC
0041AF69  |.  8BCE          mov     ecx, esi
0041AF6B  |.  50            push    eax
0041AF6C  |.  8D45 F8       lea     eax, dword ptr [ebp-0x8]
0041AF6F  |.  50            push    eax
0041AF70  |.  8D45 FC       lea     eax, dword ptr [ebp-0x4]
0041AF73  |.  50            push    eax
0041AF74  |.  E8 A9040000   call    <copy_memory>
0041AF79  |.  53            push    ebx
0041AF7A  |.  53            push    ebx
0041AF7B  |.  FF75 F8       push    dword ptr [ebp-0x8]
0041AF7E  |.  FF75 FC       push    dword ptr [ebp-0x4]
0041AF81  |.  FF76 10       push    dword ptr [esi+0x10]
0041AF84  |.  E8 FFAAFEFF   call    <decrypt>                 ; 解密lua脚本,经过这个call后的[esp-0x4]处内存就是编译成字节码的lua脚本了,看图
0041AF89  |.  83C4 14       add     esp, 0x14
0041AF8C  |.  395D FC       cmp     dword ptr [ebp-0x4], ebx
0041AF8F  |.  8BF8          mov     edi, eax

...


下图就是解密出来的lua脚本,经过编译的,然而头文件被修改,让你无法使用luadec来反编译它,需要还原头,也比较简单,只要把\x1bls\x11改成\x1bLuaS就行了,为什么是‘S',因为看这个头文件结构应该使用的是5.3版本的lua,所以是'S',还好作者没有改lua字节码,否则要疯。



改完保存下来,使用luadec反编译出来看看,如下图:


现在看完lua脚本并没有发现里面有明文,算法也没在里面,所以还得往程序里看,
图上提到的fnGetRegSnToVerify和fnCalcUserInputRegSnAfterEnc函数是关键,所以要在程序里找到这两个函数。
c向lua注册函数一般要这样:
lua_pushcfunction(xxxx);
lua_setglobal(xxx,'fun');
这样就注册了fun函数,所以我们要找到lua_setglobal的所在,根据特征码找到地址0x40412e是lua_setglobal,下断后运行直接fnCalcUserInputRegSnAfterEnc字眼在堆栈窗口中出现,返回后就能发现函数地址了,lua_setglobal是没有显示这个函数地址的,但是他跟上面的lua_pushcfunction配套,所以回溯上去就能看到:
0041AE15  |.  53            push    ebx
0041AE16  |.  68 A2194000   push    <fnGetRegSnToVerify>   ;这里就是地址了
0041AE1B  |.  FF76 10       push    dword ptr [esi+0x10]
0041AE1E  |.  E8 F38EFEFF   call    00403D16          ;这是lua_pushcfunction
0041AE23  |.  FF75 F0       push    dword ptr [ebp-0x10]
0041AE26  |.  FF76 10       push    dword ptr [esi+0x10]
0041AE29  |.  E8 0093FEFF   call    0040412E    ;这是lua_setglobal
0041AE2E  |.  83C4 14       add     esp, 0x14
0041AE31  |>  395D F0       cmp     dword ptr [ebp-0x10], ebx


以上同理,找到fnGetRegSnToVerify后下断这两个函数,输入注册码后回车注册
先断在了fnGetRegSnToVerify:
004019A2 > .  FF7424 04     push    dword ptr [esp+0x4]
004019A6   .  E8 F11C0000   call    0040369C
004019AB   .  85C0          test    eax, eax
004019AD   .  59            pop     ecx
004019AE   .  75 13         jnz     short 004019C3
004019B0   .  6A 20         push    0x20
004019B2   .  68 44D24200   push    0042D244
004019B7   .  FF7424 0C     push    dword ptr [esp+0xC]
004019BB   .  E8 50220000   call    00403C10    ; 这是给lua堆栈压入数据的函数,也就是这个函数没有参数,只有一个返回值,还是一个字符串,是上面的42d244
004019C0   .  83C4 0C       add     esp, 0xC
004019C3   >  6A 01         push    0x1
004019C5   .  58            pop     eax
004019C6   .  C3            tern


其实上面的42d244处的0x20字节就是注册码的,不过不是明文
0042D244  A4 47 98 0C 9E 40 D7 F6 EB 76 6E 6D 7E A3 3E EB  ?濦做雟nm~??
0042D254  D5 51 30 06 7D C0 FB 6C C2 7A 43 C5 A4 C9 B1 FD  誕0}利l聑C扭杀?


再运行后断到fnCalcUserInputRegSnAfterEnc:
004019C7 >/.  55            push    ebp
004019C8  |.  8BEC          mov     ebp, esp
004019CA  |.  51            push    ecx
004019CB  |.  51            push    ecx
004019CC  |.  8365 F8 00    and     dword ptr [ebp-0x8], 0x0
004019D0  |.  8365 FC 00    and     dword ptr [ebp-0x4], 0x0
004019D4  |.  56            push    esi
004019D5  |.  57            push    edi
004019D6  |.  8B7D 08       mov     edi, dword ptr [ebp+0x8]
004019D9  |.  57            push    edi
004019DA  |.  E8 BD1C0000   call    0040369C
004019DF  |.  83F8 01       cmp     eax, 0x1
004019E2  |.  59            pop     ecx
004019E3  |.  75 51         jnz     short 00401A36
004019E5  |.  8D45 FC       lea     eax, dword ptr [ebp-0x4]
004019E8  |.  50            push    eax
004019E9  |.  6A 01         push    0x1
004019EB  |.  57            push    edi
004019EC  |.  E8 C5410000   call    00405BB6   ;从lua脚 本看到这个函数是有一个参数的
004019F1  |.  8BF0          mov     esi, eax
004019F3  |.  83C4 0C       add     esp, 0xC
004019F6  |.  85F6          test    esi, esi
004019F8  |.  74 3C         je      short 00401A36
004019FA  |.  FF75 FC       push    dword ptr [ebp-0x4]
004019FD  |.  E8 A89B0100   call    0041B5AA
00401A02  |.  85C0          test    eax, eax
00401A04  |.  59            pop     ecx
00401A05  |.  8945 F8       mov     dword ptr [ebp-0x8], eax
00401A08  |.  74 2C         je      short 00401A36
00401A0A  |.  FF75 FC       push    dword ptr [ebp-0x4]
00401A0D  |.  56            push    esi
00401A0E  |.  50            push    eax
00401A0F  |.  E8 BC9B0100   call    <alloc_heap>
00401A14  |.  8B0D 50984300 mov     ecx, dword ptr [0x439850]
00401A1A  |.  83C4 0C       add     esp, 0xC
00401A1D  |.  8D45 FC       lea     eax, dword ptr [ebp-0x4]
00401A20  |.  50            push    eax
00401A21  |.  8D45 F8       lea     eax, dword ptr [ebp-0x8]
00401A24  |.  50            push    eax
00401A25  |.  E8 46980100   call    0041B270   ; 这个是加密的关键点
00401A2A  |.  85C0          test    eax, eax
00401A2C  |.  74 08         je      short 00401A36
00401A2E  |.  FF75 FC       push    dword ptr [ebp-0x4]
00401A31  |.  FF75 F8       push    dword ptr [ebp-0x8] ; 这个就是我们输入的注册码的地址,如果要爆破的话在这里把上面42d244里的0x20个字节粘贴进去就行了
00401A34  |.  EB 07         jmp     short 00401A3D
00401A36  |>  6A 01         push    0x1
00401A38  |.  68 44104300   push    00431044
00401A3D  |>  57            push    edi
00401A3E  |.  E8 CD210000   call    00403C10   ;这里返回计算好的注册码给lua
00401A43  |.  83C4 0C       add     esp, 0xC
00401A46  |.  6A 01         push    0x1
00401A48  |.  58            pop     eax
00401A49  |.  5F            pop     edi
00401A4A  |.  5E            pop     esi
00401A4B  |.  C9            leave
00401A4C  \.  C3            retn



上面的函数并不计算注册码,而是在上面提到的关键算法call里:
跟进来后会找到这里,
0041B3D3  |.  8365 FC 00    and     dword ptr [ebp-0x4], 0x0
0041B3D7  |.  8D8D 54FFFFFF lea     ecx, dword ptr [ebp-0xAC]
0041B3DD  |.  FF37          push    dword ptr [edi]
0041B3DF  |.  FF36          push    dword ptr [esi]
0041B3E1  |.  FF75 10       push    dword ptr [ebp+0x10]
0041B3E4  |.  E8 AE7CFEFF   call    00403097      ; 关键算法call
0041B3E9  |.  FF37          push    dword ptr [edi]   
0041B3EB  |.  8D8D 54FFFFFF lea     ecx, dword ptr [ebp-0xAC]
0041B3F1  |.  FF36          push    dword ptr [esi]   
0041B3F3  |.  E8 787CFEFF   call    00403070      
0041B3F8  |.  33C9          xor     ecx, ecx
0041B3FA  |.  3B06          cmp     eax, dword ptr [esi]



反正你会跟到这里,主要的算法就在这里
0040315B  /$  55            push    ebp
0040315C  |.  8BEC          mov     ebp, esp
0040315E  |.  83EC 1C       sub     esp, 0x1C
00403161  |.  8365 FC 00    and     dword ptr [ebp-0x4], 0x0
00403165  |.  57            push    edi
00403166  |.  8BF9          mov     edi, ecx
00403168  |.  837F 08 00    cmp     dword ptr [edi+0x8], 0x0
0040316C  |.  0F86 3C010000 jbe     004032AE
00403172  |.  53            push    ebx
00403173  |.  56            push    esi
00403174  |>  8B75 FC       /mov     esi, dword ptr [ebp-0x4]     ;外循环两次,一次运算16个字节
00403177  |.  8B87 94000000 |mov     eax, dword ptr [edi+0x94]
0040317D  |.  0377 04       |add     esi, dword ptr [edi+0x4]
00403180  |.  8D9F 90000000 |lea     ebx, dword ptr [edi+0x90]
00403186  |.  C745 F4 10000>|mov     dword ptr [ebp-0xC], 0x10
0040318D  |.  2906          |sub     dword ptr [esi], eax
0040318F  |.  8B87 98000000 |mov     eax, dword ptr [edi+0x98]
00403195  |.  2946 08       |sub     dword ptr [esi+0x8], eax
00403198  |>  8B4E 08       |/mov     ecx, dword ptr [esi+0x8]    ; 内循环16次,以dword为单位进行xor运算
0040319B  |.  8B46 0C       ||mov     eax, dword ptr [esi+0xC]
0040319E  |.  DD05 70E24200 ||fld     qword ptr [0x42E270]
004031A4  |.  894E 0C       ||mov     dword ptr [esi+0xC], ecx
004031A7  |.  8B4E 04       ||mov     ecx, dword ptr [esi+0x4]
004031AA  |.  894E 08       ||mov     dword ptr [esi+0x8], ecx
004031AD  |.  8B0E          ||mov     ecx, dword ptr [esi]
004031AF  |.  51            ||push    ecx
004031B0  |.  51            ||push    ecx
004031B1  |.  8906          ||mov     dword ptr [esi], eax
004031B3  |.  8BC1          ||mov     eax, ecx
004031B5  |.  DD1C24        ||fstp    qword ptr [esp]
004031B8  |.  894E 04       ||mov     dword ptr [esi+0x4], ecx
004031BB  |.  8945 F8       ||mov     dword ptr [ebp-0x8], eax
004031BE  |.  E8 C18A0100   ||call    0041BC84
004031C3  |.  DD5D EC       ||fstp    qword ptr [ebp-0x14]
004031C6  |.  DD05 68E24200 ||fld     qword ptr [0x42E268]
004031CC  |.  DD1C24        ||fstp    qword ptr [esp]
004031CF  |.  E8 B08A0100   ||call    0041BC84
004031D4  |.  DC7D EC       ||fdivr   qword ptr [ebp-0x14]
004031D7  |.  59            ||pop     ecx
004031D8  |.  59            ||pop     ecx
004031D9  |.  E8 AE8B0100   ||call    0041BD8C
004031DE  |.  50            ||push    eax
004031DF  |.  8BCF          ||mov     ecx, edi
004031E1  |.  E8 3A030000   ||call    00403520
004031E6  |.  50            ||push    eax
004031E7  |.  8B45 F8       ||mov     eax, dword ptr [ebp-0x8]
004031EA  |.  8D4C00 01     ||lea     ecx, dword ptr [eax+eax+0x1]
004031EE  |.  0FAFC8        ||imul    ecx, eax
004031F1  |.  51            ||push    ecx
004031F2  |.  8BCF          ||mov     ecx, edi
004031F4  |.  E8 67030000   ||call    <fn_rol>        ; 循环左移
004031F9  |.  DD05 70E24200 ||fld     qword ptr [0x42E270]
004031FF  |.  51            ||push    ecx
00403200  |.  51            ||push    ecx
00403201  |.  8945 F8       ||mov     dword ptr [ebp-0x8], eax
00403204  |.  8B46 0C       ||mov     eax, dword ptr [esi+0xC]
00403207  |.  DD1C24        ||fstp    qword ptr [esp]
0040320A  |.  8945 F0       ||mov     dword ptr [ebp-0x10], eax
0040320D  |.  E8 728A0100   ||call    0041BC84
00403212  |.  DD5D E4       ||fstp    qword ptr [ebp-0x1C]
00403215  |.  DD05 68E24200 ||fld     qword ptr [0x42E268]
0040321B  |.  DD1C24        ||fstp    qword ptr [esp]
0040321E  |.  E8 618A0100   ||call    0041BC84
00403223  |.  DC7D E4       ||fdivr   qword ptr [ebp-0x1C]
00403226  |.  59            ||pop     ecx
00403227  |.  59            ||pop     ecx
00403228  |.  E8 5F8B0100   ||call    0041BD8C
0040322D  |.  50            ||push    eax
0040322E  |.  8BCF          ||mov     ecx, edi
00403230  |.  E8 EB020000   ||call    00403520
00403235  |.  50            ||push    eax
00403236  |.  8B45 F0       ||mov     eax, dword ptr [ebp-0x10]
00403239  |.  8D4C00 01     ||lea     ecx, dword ptr [eax+eax+0x1]
0040323D  |.  0FAFC8        ||imul    ecx, eax
00403240  |.  51            ||push    ecx
00403241  |.  8BCF          ||mov     ecx, edi
00403243  |.  E8 18030000   ||call    <fn_rol>
00403248  |.  50            ||push    eax
00403249  |.  8BCF          ||mov     ecx, edi
0040324B  |.  8945 F0       ||mov     dword ptr [ebp-0x10], eax
0040324E  |.  E8 CD020000   ||call    00403520
00403253  |.  50            ||push    eax
00403254  |.  8B06          ||mov     eax, dword ptr [esi]
00403256  |.  2B43 FC       ||sub     eax, dword ptr [ebx-0x4]
00403259  |.  8BCF          ||mov     ecx, edi
0040325B  |.  50            ||push    eax
0040325C  |.  E8 19030000   ||call    <fn_ror>           ; 循环右移
00403261  |.  3345 F8       ||xor     eax, dword ptr [ebp-0x8]
00403264  |.  FF75 F8       ||push    dword ptr [ebp-0x8]
00403267  |.  8BCF          ||mov     ecx, edi
00403269  |.  8906          ||mov     dword ptr [esi], eax
0040326B  |.  E8 B0020000   ||call    00403520
00403270  |.  50            ||push    eax
00403271  |.  8B46 08       ||mov     eax, dword ptr [esi+0x8]
00403274  |.  2B03          ||sub     eax, dword ptr [ebx]
00403276  |.  8BCF          ||mov     ecx, edi
00403278  |.  50            ||push    eax
00403279  |.  E8 FC020000   ||call    <fn_ror>
0040327E  |.  3345 F0       ||xor     eax, dword ptr [ebp-0x10]
00403281  |.  83EB 08       ||sub     ebx, 0x8
00403284  |.  FF4D F4       ||dec     dword ptr [ebp-0xC]
00403287  |.  8946 08       ||mov     dword ptr [esi+0x8], eax
0040328A    ^ 0F85 08FFFFFF |\jnz     00403198
00403290  |.  8B47 0C       |mov     eax, dword ptr [edi+0xC]
00403293  |.  8345 FC 10    |add     dword ptr [ebp-0x4], 0x10
00403297      2946 04       |sub     dword ptr [esi+0x4], eax    ;最后的两个dword将减去上面提到的表中的数据进行简单的隐藏
0040329A      8B47 10       |mov     eax, dword ptr [edi+0x10]
0040329D      2946 0C       |sub     dword ptr [esi+0xC], eax
004032A0  |.  8B45 FC       |mov     eax, dword ptr [ebp-0x4]
004032A3  |.  3B47 08       |cmp     eax, dword ptr [edi+0x8]
004032A6  |.^ 0F82 C8FEFFFF \jb      00403174
004032AC  |.  5E            pop     esi
004032AD  |.  5B            pop     ebx
004032AE  |>  5F            pop     edi
004032AF  |.  C9            leave
004032B0  \.  C3            retn



具体算法描述如下,
输入'1234567890abcdefg'
将注册码放到32字节的buffer当中进入以上算法函数,
每次计算16字节,前后16字节没有任何关系
每次运算按dword单位
以便方便阐述,按1234来说明,总共16字节
1 , 2, 3, 4
0)取出1,2分别减去0x7faf076d,0x9bd7fa4c
1)以dword为单位循环右移,变成4, 1, 2, 3
2)取出1,计算 n1 = fn_rol(1,5)
3)取出2,计算 n2 = fn_rol(2,5)
4)加密4,n1 xor fn_ror(4-k[0], f(n2))
5)加密5,n2 xor fn_ror(5-k[1], f(n1))
6)从1)开始循环16次
7)2、4减去0x5bf76637,0x4748da7a进行简单隐藏

表达能力有限,看代码吧,还原了这个加密call:
DWORD fn2( DWORD a )
{
	return (a << (32 - 5)) >> (32 - 5);
}

DWORD fn_rol( DWORD a1, DWORD a2 )
{
	return (a1 << a2) | (a1 >> (32 - a2));
}

DWORD fn_ror( DWORD a1, DWORD a2 )
{
	return (a1 >> a2) | (a1 << (32 - a2));
}

void calc( DWORD* data )
{
	DWORD k1 = 0x7faf076d;
	DWORD k2 = 0x9bd7fa4c;
	DWORD k3 = 0x5bf76637;
	DWORD k4 = 0x4748da7a;

	DWORD kt[] = {0xA44342FC, 0xB2727654, 0xD3F9119F, 0x8CF04F52, 0x446564BE, 0xB4D40A2E, 0x02966467, 0xA3F2BAA5, 0x89D93040, 0xDC4B368C, 
		0x454D2FAB, 0xC40795D7, 0xE198FD3B, 0x2F7D2F02, 0x3709AADB, 0xAC882BD2, 0x20559BF5, 0x69B501F6, 0xA9D14F98, 0xDC9E4070, 
		0x1FB97D2B, 0x14A0B21F, 0xEAE1495F, 0xD8411E50, 0x94D622EA, 0xCD568FE5, 0x32106336, 0x09F7F01F, 0x5E5CF6D9, 0xBE2F25A0, 
		0x2E9C6392, 0xBBEA6DD1};

	data[0] -= k1;
	data[2] -= k2;
	DWORD* pkt = &kt[31];
	for( int i = 0; i < 16; ++ i )
	{
		DWORD tmp = data[3];
		memcpy( (char*)data + 4, data, 12 );
		data[0] = tmp;

		DWORD n1 = fn_rol(data[1] * (2 * data[1] + 1), fn2(5));
		DWORD n2 = fn_rol(data[3] * (2 * data[3] + 1), fn2(5));

		//DWORD p = fff((double)fn_ror(n1, fn2(5)));

		data[0] = n1 ^ fn_ror(data[0] - *(pkt-1), fn2(n2));
		data[2] = n2 ^ fn_ror(data[2] - *pkt, fn2(n1));

		pkt -= 2;
	}
data[1] -= k3;
data[3] -= k4;
}


想要注册成功主要是还原42d244处那32个字节得到明文的注册码,所以逆算法如下:
...
        data[1] += k3;
	data[3] += k4;
	DWORD* pkt = kt;
	for( int i = 0; i < 16; ++ i )
	{
		DWORD n1 = fn_rol(data[1] * (2 * data[1] + 1), fn2(5));
		DWORD n2 = fn_rol(data[3] * (2 * data[3] + 1), fn2(5));

		DWORD a = data[0] ^ n1;
		a = fn_rol(a, fn2(n2));
		a += *pkt;
		data[0] = a;

		a = data[2] ^ n2;
		a = fn_rol(a, fn2(n1));
		a += *(pkt+1);
		data[2] = a;

		pkt += 2;

		DWORD tmp = data[0];
		memcpy( data, (char*)data + 4, 12);
		data[3] = tmp;
	}

	data[0] += k1;
	data[2] += k2;
...


把注册码密码经过这个运算后发现居然没有明文,后来在fnCalcUserInputRegSnAfterEnc里发现返回给lua判断的注册码跟加密运算后的不一样,还有一层加密,具体的就不看了,因为是xor加密,所以在调试的时候直接替换了正确的密文注册码进行一次xor加密后再用以上代码还原就得到了明文注册码stK5CKpBsw7TPF45

以上,谢谢观看

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

上传的附件:
收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 1355
活跃值: (339)
能力值: ( LV13,RANK:920 )
在线值:
发帖
回帖
粉丝
2
对称算法采用了RC6
2016-11-6 12:10
0
雪    币: 221
活跃值: (1140)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
RC6
2022-6-22 21:37
0
游客
登录 | 注册 方可回帖
返回
//