找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 9496|回复: 5

[hack] 时隔10年,公布routeros算号机源码

[复制链接]
发表于 2019-4-20 22:22:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
routeros  3.0 它的7位序列号生成算法是根据硬盘的序列号信息和硬盘mbr第256字节处的信息综合后,产生序列号。
所以当时利用这个漏洞(实际上就是crc32碰撞),穷举mbr的信息,产生指定的序列号。然后用这个序列号的注册码就可以注册了。当时的算号器在:
http://bbs.routerclub.com/thread-42847-1-1.html
以下代码使用vc编译。
运行结果大概是这样:
序列号是:  798Y-K0N,  关键特征码是:  70df46f671d4092f2175aeb1
序列号是:  Q8C4-1AN,  关键特征码是:  f4134cea72d4092f21752389
序列号是:  AK73-PET,  关键特征码是:  c8b046f275d4092f217552e4
  1. // test.cpp : Defines the entry point for the console application.
  2. //

  3. #include "stdafx.h"
  4. #include "stdio.h"
  5. #include "stdlib.h"
  6. #include "string.h"
  7. #include "windows.h"
  8. #include "omp.h"

  9. char sn[9];
  10. unsigned char  dev[]="/dev/hdb";
  11. char aTn0byx18s5hz4i[]="TN0BYX18S5HZ4IA67DGF3LPCJQRUK9MW2VE";
  12. DWORD dword_804E4E0[1024];
  13. char byte_804E4C0;
  14. unsigned char mbrinfo[512];

  15. #define TINY_BLOCK_COPY 64       // upper limit for movsd type copy
  16. #define IN_CACHE_COPY 64 * 1024  // upper limit for movq/movq copy w/SW prefetch
  17. #define UNCACHED_COPY 197 * 1024 // upper limit for movq/movntq w/SW prefetch
  18. //#define BLOCK_PREFETCH_COPY  infinity // no limit for movq/movntq w/block prefetch
  19. #define CACHEBLOCK 80h // number of 64-byte blocks (cache lines) for block prefetch

  20. unsigned char hdinfo[512];

  21. void * memcpy2(void *dest, const void *src, size_t n)
  22. {
  23.   __asm {

  24.    mov      ecx, [n]      ; number of bytes to copy
  25.    mov      edi, [dest]      ; destination
  26.    mov      esi, [src]      ; source
  27.    mov      ebx, ecx      ; keep a copy of count

  28.    cld
  29.    cmp      ecx, TINY_BLOCK_COPY
  30.    jb      $memcpy_ic_3   ; tiny? skip mmx copy

  31.    cmp      ecx, 32*1024      ; don't align between 32k-64k because
  32.    jbe      $memcpy_do_align   ;  it appears to be slower
  33.    cmp      ecx, 64*1024
  34.    jbe      $memcpy_align_done
  35. $memcpy_do_align:
  36.    mov      ecx, 8         ; a trick that's faster than rep movsb...
  37.    sub      ecx, edi      ; align destination to qword
  38.    and      ecx, 111b      ; get the low bits
  39.    sub      ebx, ecx      ; update copy count
  40.    neg      ecx            ; set up to jump into the array
  41.    add      ecx, offset $memcpy_align_done
  42.    jmp      ecx            ; jump to array of movsb's

  43. align 4
  44.    movsb
  45.    movsb
  46.    movsb
  47.    movsb
  48.    movsb
  49.    movsb
  50.    movsb
  51.    movsb

  52. $memcpy_align_done:         ; destination is dword aligned
  53.    mov      ecx, ebx      ; number of bytes left to copy
  54.    shr      ecx, 6         ; get 64-byte block count
  55.    jz      $memcpy_ic_2   ; finish the last few bytes

  56.    cmp      ecx, IN_CACHE_COPY/64   ; too big 4 cache? use uncached copy
  57.    jae      $memcpy_uc_test

  58. // This is small block copy that uses the MMX registers to copy 8 bytes
  59. // at a time.  It uses the "unrolled loop" optimization, and also uses
  60. // the software prefetch instruction to get the data into the cache.
  61. align 16
  62. $memcpy_ic_1:         ; 64-byte block copies, in-cache copy

  63.    prefetchnta [esi + (200*64/34+192)]      ; start reading ahead

  64.    movq   mm0, [esi+0]   ; read 64 bits
  65.    movq   mm1, [esi+8]
  66.    movq   [edi+0], mm0   ; write 64 bits
  67.    movq   [edi+8], mm1   ;    note:  the normal movq writes the
  68.    movq   mm2, [esi+16]   ;    data to cache; a cache line will be
  69.    movq   mm3, [esi+24]   ;    allocated as needed, to store the data
  70.    movq   [edi+16], mm2
  71.    movq   [edi+24], mm3
  72.    movq   mm0, [esi+32]
  73.    movq   mm1, [esi+40]
  74.    movq   [edi+32], mm0
  75.    movq   [edi+40], mm1
  76.    movq   mm2, [esi+48]
  77.    movq   mm3, [esi+56]
  78.    movq   [edi+48], mm2
  79.    movq   [edi+56], mm3

  80.    add      esi, 64         ; update source pointer
  81.    add      edi, 64         ; update destination pointer
  82.    dec      ecx            ; count down
  83.    jnz      $memcpy_ic_1   ; last 64-byte block?

  84. $memcpy_ic_2:
  85.    mov      ecx, ebx      ; has valid low 6 bits of the byte count
  86. $memcpy_ic_3:
  87.    shr      ecx, 2         ; dword count
  88.    and      ecx, 1111b      ; only look at the "remainder" bits
  89.    neg      ecx            ; set up to jump into the array
  90.    add      ecx, offset $memcpy_last_few
  91.    jmp      ecx            ; jump to array of movsd's

  92. $memcpy_uc_test:
  93.    cmp      ecx, UNCACHED_COPY/64   ; big enough? use block prefetch copy
  94.    jae      $memcpy_bp_1

  95. $memcpy_64_test:
  96.    or      ecx, ecx      ; tail end of block prefetch will jump here
  97.    jz      $memcpy_ic_2   ; no more 64-byte blocks left

  98. // For larger blocks, which will spill beyond the cache, it's faster to
  99. // use the Streaming Store instruction MOVNTQ.   This write instruction
  100. // bypasses the cache and writes straight to main memory.  This code also
  101. // uses the software prefetch instruction to pre-read the data.
  102. align 16
  103. $memcpy_uc_1:            ; 64-byte blocks, uncached copy

  104.    prefetchnta [esi + (200*64/34+192)]      ; start reading ahead

  105.    movq   mm0,[esi+0]      ; read 64 bits
  106.    add      edi,64         ; update destination pointer
  107.    movq   mm1,[esi+8]
  108.    add      esi,64         ; update source pointer
  109.    movq   mm2,[esi-48]
  110.    movntq   [edi-64], mm0   ; write 64 bits, bypassing the cache
  111.    movq   mm0,[esi-40]   ;    note: movntq also prevents the CPU
  112.    movntq   [edi-56], mm1   ;    from READING the destination address
  113.    movq   mm1,[esi-32]   ;    into the cache, only to be over-written
  114.    movntq   [edi-48], mm2   ;    so that also helps performance
  115.    movq   mm2,[esi-24]
  116.    movntq   [edi-40], mm0
  117.    movq   mm0,[esi-16]
  118.    movntq   [edi-32], mm1
  119.    movq   mm1,[esi-8]
  120.    movntq   [edi-24], mm2
  121.    movntq   [edi-16], mm0
  122.    dec      ecx
  123.    movntq   [edi-8], mm1
  124.    jnz      $memcpy_uc_1   ; last 64-byte block?

  125.    jmp      $memcpy_ic_2      ; almost done

  126. // For the largest size blocks, a special technique called Block Prefetch
  127. // can be used to accelerate the read operations.   Block Prefetch reads
  128. // one address per cache line, for a series of cache lines, in a short loop.
  129. // This is faster than using software prefetch, in this case.
  130. // The technique is great for getting maximum read bandwidth,
  131. // especially in DDR memory systems.
  132. $memcpy_bp_1:         ; large blocks, block prefetch copy

  133.    cmp      ecx, CACHEBLOCK         ; big enough to run another prefetch loop?
  134.    jl      $memcpy_64_test         ; no, back to regular uncached copy

  135.    mov      eax, CACHEBLOCK / 2      ; block prefetch loop, unrolled 2X
  136.    add      esi, CACHEBLOCK * 64   ; move to the top of the block
  137. align 16
  138. $memcpy_bp_2:
  139.    mov      edx, [esi-64]      ; grab one address per cache line
  140.    mov      edx, [esi-128]      ; grab one address per cache line
  141.    sub      esi, 128         ; go reverse order
  142.    dec      eax               ; count down the cache lines
  143.    jnz      $memcpy_bp_2      ; keep grabbing more lines into cache

  144.    mov      eax, CACHEBLOCK      ; now that it's in cache, do the copy
  145. align 16
  146. $memcpy_bp_3:
  147.    movq   mm0, [esi   ]      ; read 64 bits
  148.    movq   mm1, [esi+ 8]
  149.    movq   mm2, [esi+16]
  150.    movq   mm3, [esi+24]
  151.    movq   mm4, [esi+32]
  152.    movq   mm5, [esi+40]
  153.    movq   mm6, [esi+48]
  154.    movq   mm7, [esi+56]
  155.    add      esi, 64            ; update source pointer
  156.    movntq   [edi   ], mm0      ; write 64 bits, bypassing cache
  157.    movntq   [edi+ 8], mm1      ;    note: movntq also prevents the CPU
  158.    movntq   [edi+16], mm2      ;    from READING the destination address
  159.    movntq   [edi+24], mm3      ;    into the cache, only to be over-written,
  160.    movntq   [edi+32], mm4      ;    so that also helps performance
  161.    movntq   [edi+40], mm5
  162.    movntq   [edi+48], mm6
  163.    movntq   [edi+56], mm7
  164.    add      edi, 64            ; update dest pointer

  165.    dec      eax               ; count down

  166.    jnz      $memcpy_bp_3      ; keep copying
  167.    sub      ecx, CACHEBLOCK      ; update the 64-byte block count
  168.    jmp      $memcpy_bp_1      ; keep processing chunks

  169. // The smallest copy uses the X86 "movsd" instruction, in an optimized
  170. // form which is an "unrolled loop".   Then it handles the last few bytes.
  171. align 4
  172.    movsd
  173.    movsd         ; perform last 1-15 dword copies
  174.    movsd
  175.    movsd
  176.    movsd
  177.    movsd
  178.    movsd
  179.    movsd
  180.    movsd
  181.    movsd         ; perform last 1-7 dword copies
  182.    movsd
  183.    movsd
  184.    movsd
  185.    movsd
  186.    movsd
  187.    movsd

  188. $memcpy_last_few:      ; dword aligned from before movsd's
  189.    mov      ecx, ebx   ; has valid low 2 bits of the byte count
  190.    and      ecx, 11b   ; the last few cows must come home
  191.    jz      $memcpy_final   ; no more, let's leave
  192.    rep      movsb      ; the last 1, 2, or 3 bytes

  193. $memcpy_final:
  194.    emms            ; clean up the MMX state
  195.    sfence            ; flush the write buffer
  196.    mov      eax, [dest]   ; ret value = destination pointer

  197.     }
  198. }




  199. __declspec(naked)  void test(unsigned char * dev,unsigned char * mbrinfo,char * sn){

  200.         __asm
  201.         {        
  202.                 push        ebp
  203.                 mov                ebp, esp
  204.                 push        ebx
  205.                 push        eax
  206.                 //push        esi
  207.                 //push        edi
  208.                 mov        ebx, [ebp+16]
  209.                 mov        eax, [ebp+8]
  210.                 mov        edx, [ebp+12]
  211.                 mov        dword ptr [ebp-8], 0
  212.                 lea        ecx, [ebp-8]
  213.                 mov        byte ptr [ebx],        0
  214.                 call        sub_804B7CC        ; 取硬盘参数
  215.                 test        al, al
  216.                 jz        short loc_804C3E9
  217.                 push        9
  218.                 push        ebx                ; 计算出来的序列号
  219.                 xor        edx, edx
  220.                 push        edx                ; 需要穷举的信息
  221.                 mov        eax, [ebp-8]
  222.                 push        eax                ; 硬盘硬件信息
  223.                 push        offset aTn0byx18s5hz4i ; "TN0BYX18S5HZ4IA67DGF3LPCJQRUK9MW2VE"
  224.                 call        sub_8049FD8        ; 开始计算序列号
  225.                 add        esp, 14h

  226. loc_804C3E9:                                ; CODE XREF: sub_804C3AE+22.j
  227.                 //pop edi
  228.                 //pop esi
  229.                 mov        eax, [ebp-8]
  230.                 mov        ebx, [ebp-4]
  231.                 leave
  232.                 retn



  233. sub_804B7CC:

  234.                 push        ebp
  235.                 mov        ebp, esp
  236.                 push        edi
  237.                 push        esi
  238.                 push        ebx
  239.                 sub        esp, 274h

  240.                 mov        edi, edx
  241.                 mov        [ebp-280h], ecx
  242.                 lea        ebx, [ebp-20ch]
  243.                 push    512
  244.                 push        offset hdinfo               
  245.                 push        ebx                ; void *
  246.                 call        memcpy
  247.                 add        esp, 12


  248. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?

  249.                                 ; CODE XREF: sub_804B7CC+4F.j
  250.         
  251.                 lea        ebx, [edi+100h]
  252.                 lea        esi, [ebp-22ch]
  253.                 xor        ecx, ecx

  254. loc_804B849:                                ; CODE XREF: sub_804B7CC+9F.j
  255.                 mov        eax, ecx
  256.                 shr        eax, 1
  257.                 mov        dl, [ebx+eax]
  258.                 mov        al, dl
  259.                 shr        al, 4
  260.                 and        edx, 0Fh
  261.                 add        eax, 30h
  262.                 add        edx, 30h
  263.                 mov        [esi+ecx], al
  264.                 mov        [esi+ecx+1], dl
  265.                 add        ecx, 2
  266.                 cmp        ecx, 13h
  267.                 jbe        short loc_804B849
  268.                 lea        esi, [ebp-22ch]
  269.                 lea        ebx, [ebp-1f8h]
  270.                 mov        ecx, 13h

  271. loc_804B87E:                                ; CODE XREF: sub_804B7CC+BB.j
  272.                 mov        edx, ebx
  273.                 mov        al, [esi]
  274.                 inc        ebx
  275.                 inc        esi
  276.                 xor        [edx], al
  277.                 dec        ecx
  278.                 jns        short loc_804B87E
  279.                 mov        ax, word ptr [ebp-20ch+2]
  280.                 push        22h                ; size_t
  281.                 mov        word ptr [ebp-27ch],        ax
  282.                 lea        eax, [ebp-206h]
  283.                 push        eax                ; void *
  284.                 lea        edx, [ebp-27ch+2]
  285.                 push        edx                ; void *
  286.                 call        memcpy
  287.                 push        28h                ; size_t
  288.                 lea        eax, [ebp-1d6h]
  289.                 push        eax                ; void *
  290.                 lea        edx, [ebp-258h]
  291.                 push        edx                ; void *
  292.                 call        memcpy
  293.                 mov        al, [ebp-1adh]
  294.                 mov        [ebp-230h], al
  295.                 mov        al, [ebp-1aah]
  296.                 mov        [ebp-22fh], al
  297.                 mov        al, [ebp-1a6h]
  298.                 mov        [ebp-22eh], al
  299.                 add        esp, 18h
  300.                 mov        al, [ebp-1a4h]
  301.                 cmp        ds:byte_804E4C0, 0
  302.                 mov        [ebp-22dh], al
  303.                 lea        ebx, [ebp-27ch]
  304.                 jnz        short loc_804B935
  305.                 xor        ecx, ecx

  306. loc_804B905:                                ; CODE XREF: sub_804B7CC+160.j
  307.                 mov        eax, ecx
  308.                 mov        edx, 7

  309. loc_804B90C:                                ; CODE XREF: sub_804B7CC+150.j
  310.                 test        al, 1
  311.                 jz        short loc_804B919
  312.                 shr        eax, 1
  313.                 xor        eax, 0EDB88320h
  314.                 jmp        short loc_804B91B
  315. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?

  316. loc_804B919:                                ; CODE XREF: sub_804B7CC+142.j
  317.                 shr        eax, 1

  318. loc_804B91B:                                ; CODE XREF: sub_804B7CC+14B.j
  319.                 dec        edx
  320.                 jns        short loc_804B90C
  321.                 mov        ds:dword_804E4E0[ecx*4], eax
  322.                 inc        ecx
  323.                 cmp        ecx, 0FFh
  324.                 jbe        short loc_804B905
  325.                 mov        ds:byte_804E4C0, 1

  326. loc_804B935:                                ; CODE XREF: sub_804B7CC+135.j
  327.                 or        edx, 0FFFFFFFFh
  328.                 xor        ecx, ecx

  329. loc_804B93A:                                ; CODE XREF: sub_804B7CC+184.j
  330.                 mov        al, [ebx+ecx]
  331.                 xor        eax, edx
  332.                 movzx        eax, al
  333.                 shr        edx, 8
  334.                 inc        ecx
  335.                 xor        edx, ds:dword_804E4E0[eax*4]
  336.                 cmp        ecx, 50h
  337.                 jb        short loc_804B93A
  338.                 mov        eax, [ebp-280h]
  339.                 not        edx
  340.                 mov        [eax], edx
  341.                 mov        eax, 1

  342.                                 ; CODE XREF: sub_804B7CC+25.j
  343.                                         ; sub_804B7CC+63.j
  344.                 lea        esp, [ebp-0Ch]
  345.                 pop        ebx
  346.                 pop        esi
  347.                 pop        edi
  348.                 pop        ebp
  349.                 retn



  350. sub_8049FD8:

  351.                 push        ebp
  352.                 mov        ebp, esp
  353.                 push        edi
  354.                 push        esi
  355.                 xor        edi, edi
  356.                 cmp        [ebp+18h], 1
  357.                 push        ebx
  358.                 mov        esi, [ebp+16]
  359.                 mov        ebx, [ebp+12]
  360.                 jz        short loc_804A036

  361. loc_8049FEC:                                ; CODE XREF: sub_8049FD8+5C.j
  362.                 test        edi, edi
  363.                 jz        short loc_804A001
  364.                 test        edi, 3
  365.                 jnz        short loc_804A001
  366.                 mov        eax, [ebp+14h]
  367.                 mov        byte ptr [eax+edi], 2Dh
  368.                 jmp        short loc_804A02D
  369. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?

  370. loc_804A001:                                ; CODE XREF: sub_8049FD8+16.j
  371.                                         ; sub_8049FD8+1E.j
  372.                 push        0
  373.                 push        23h
  374.                 push        esi
  375.                 push        ebx
  376.                 call        sub_804D220
  377.                 mov        edx, [ebp+8]
  378.                 mov        al, [edx+eax]
  379.                 add        esp, 10h
  380.                 mov        edx, [ebp+14h]
  381.                 mov        [edx+edi], al
  382.                 push        0
  383.                 push        23h
  384.                 push        esi
  385.                 push        ebx
  386.                 call        sub_804D0D0
  387.                 mov        ebx, eax
  388.                 add        esp, 10h
  389.                 mov        esi, edx

  390. loc_804A02D:                                ; CODE XREF: sub_8049FD8+27.j
  391.                 mov        eax, [ebp+18h]
  392.                 inc        edi
  393.                 dec        eax
  394.                 cmp        edi, eax
  395.                 jb        short loc_8049FEC

  396. loc_804A036:                                ; CODE XREF: sub_8049FD8+12.j
  397.                 mov        eax, [ebp+14h]
  398.                 mov        edx, [ebp+18h]
  399.                 mov        byte ptr [eax+edx-1], 0
  400.                 lea        esp, [ebp-0Ch]
  401.                 pop        ebx
  402.                 pop        esi
  403.                 pop        edi
  404.                 pop        ebp
  405.                 retn



  406. sub_804D220:

  407.                 push        ebp
  408.                 mov        ebp, esp
  409.                 push        edi
  410.                 push        esi
  411.                 sub        esp, 30h
  412.                 mov        edx, [ebp+14h]
  413.                 mov        eax, [ebp+16]
  414.                 mov        edi, edx
  415.                 lea        ecx, [ebp-10h]
  416.                 mov        esi, eax
  417.                 mov        edx, [ebp+12]
  418.                 mov        eax, [ebp+8]
  419.                 test        edi, edi
  420.                 mov        dword ptr [ebp-20h], 0
  421.                 mov        dword ptr [ebp-1ch], 0
  422.                 mov        [ebp-14h], ecx
  423.                 mov        [ebp-24h], eax
  424.                 mov        [ebp-34h], edx
  425.                 jnz        short loc_804D2A0
  426.                 cmp        esi, edx
  427.                 jbe        loc_804D320
  428.                 div        esi

  429. loc_804D260:                                ; CODE XREF: sub_804D220+11E.j
  430.                 mov        ecx, [ebp-14h]
  431.                 test        ecx, ecx
  432.                 mov        [ebp-24h], edx
  433.                 jz        short loc_804D285
  434.                 mov        eax, [ebp-24h]
  435.                 mov        [ebp-20h], eax
  436.                 mov        dword ptr [ebp-1ch], 0

  437. loc_804D277:                                ; CODE XREF: sub_804D220+1D1.j
  438.                 mov        eax, [ebp-14h]
  439.                 mov        edx, [ebp-20h]
  440.                 mov        ecx, [ebp-1ch]
  441.                 mov        [eax], edx
  442.                 mov        [eax+4], ecx

  443. loc_804D285:                                ; CODE XREF: sub_804D220+48.j
  444.                                         ; sub_804D220+DA.j ...
  445.                 mov        eax, [ebp-10h]
  446.                 mov        edx, [ebp-0ch]
  447.                 add        esp, 30h
  448.                 pop        esi
  449.                 pop        edi
  450.                 pop        ebp
  451.                 retn
  452. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  453.                 align 10h

  454. loc_804D2A0:                                ; CODE XREF: sub_804D220+34.j
  455.                 cmp        edi, [ebp-34h]
  456.                 jbe        short loc_804D2D0
  457.                 mov        edx, [ebp+8]
  458.                 mov        ecx, [ebp-34h]
  459.                 mov        [ebp-20h], edx
  460.                 mov        [ebp-1ch], ecx
  461.                 mov        eax, [ebp-20h]
  462.                 mov        edx, [ebp-1ch]
  463.                 mov        [ebp-10h], eax
  464.                 mov        [ebp-0ch], edx
  465.                 add        esp, 30h
  466.                 pop        esi
  467.                 pop        edi
  468.                 pop        ebp
  469.                 retn
  470. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  471.                 align 10h

  472. loc_804D2D0:                                ; CODE XREF: sub_804D220+83.j
  473.                 bsr        eax, edi
  474.                 xor        eax, 1Fh
  475.                 mov        [ebp-2ch], eax
  476.                 jnz        short loc_804D350
  477.                 cmp        [ebp-34h], edi
  478.                 ja        short loc_804D2E5
  479.                 cmp        [ebp-24h], esi
  480.                 jb        short loc_804D2F5

  481. loc_804D2E5:                                ; CODE XREF: sub_804D220+BE.j
  482.                 mov        edx, [ebp-34h]
  483.                 mov        eax, [ebp-24h]
  484.                 sub        eax, esi
  485.                 sbb        edx, edi
  486.                 mov        [ebp-24h], eax
  487.                 mov        [ebp-34h], edx

  488. loc_804D2F5:                                ; CODE XREF: sub_804D220+C3.j
  489.                 mov        edx, [ebp-14h]
  490.                 test        edx, edx
  491.                 jz        short loc_804D285
  492.                 mov        eax, [ebp-24h]
  493.                 mov        edx, [ebp-34h]
  494.                 mov        [ebp-20h], eax
  495.                 mov        [ebp-1ch], edx
  496.                 mov        ecx, [ebp-14h]
  497.                 mov        eax, [ebp-20h]
  498.                 mov        edx, [ebp-1ch]
  499.                 mov        [ecx], eax
  500.                 mov        [ecx+4], edx
  501.                 jmp        loc_804D285
  502. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  503.                 align 10h

  504. loc_804D320:                                ; CODE XREF: sub_804D220+38.j
  505.                 test        esi, esi
  506.                 jnz        short loc_804D32F
  507.                 mov        eax, 1
  508.                 xor        edx, edx
  509.                 div        esi
  510.                 mov        esi, eax

  511. loc_804D32F:                                ; CODE XREF: sub_804D220+102.j
  512.                 mov        eax, [ebp-34h]
  513.                 mov        edx, edi
  514.                 div        esi
  515.                 mov        eax, [ebp-24h]
  516.                 mov        [ebp-34h], edx
  517.                 div        esi
  518.                 jmp        loc_804D260
  519. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  520.                 align 10h

  521. loc_804D350:                                ; CODE XREF: sub_804D220+B9.j
  522.                 mov        eax, 20h
  523.                 sub        eax, [ebp-2ch]
  524.                 mov        [ebp-28h], eax
  525.                 mov        edx, edi
  526.                 mov        cl, byte ptr [ebp-2ch]
  527.                 shl        edx, cl
  528.                 mov        eax, esi
  529.                 mov        cl, byte ptr [ebp-28h]
  530.                 shr        eax, cl
  531.                 mov        cl, byte ptr [ebp-2ch]
  532.                 shl        esi, cl
  533.                 mov        edi, edx
  534.                 mov        cl, byte ptr [ebp-28h]
  535.                 mov        edx, [ebp-34h]
  536.                 or        edi, eax
  537.                 shr        edx, cl
  538.                 mov        eax, [ebp-34h]
  539.                 mov        cl, byte ptr [ebp-2ch]
  540.                 shl        eax, cl
  541.                 mov        [ebp-34h], eax
  542.                 mov        cl, byte ptr [ebp-28h]
  543.                 mov        eax, [ebp-24h]
  544.                 shr        eax, cl
  545.                 or        eax, [ebp-34h]
  546.                 mov        [ebp-34h], eax
  547.                 mov        cl, byte ptr [ebp-2ch]
  548.                 div        edi
  549.                 mov        [ebp-34h], edx
  550.                 shl        [ebp-24h], cl
  551.                 mul        esi
  552.                 cmp        edx, [ebp-34h]
  553.                 mov        [ebp-38h], eax
  554.                 ja        short loc_804D3B2
  555.                 jnz        short loc_804D3BC
  556.                 mov        eax, [ebp-24h]
  557.                 cmp        [ebp-38h], eax
  558.                 jbe        short loc_804D3BC

  559. loc_804D3B2:                                ; CODE XREF: sub_804D220+186.j
  560.                 mov        ecx, [ebp-38h]
  561.                 sub        ecx, esi
  562.                 sbb        edx, edi
  563.                 mov        [ebp-38h], ecx

  564. loc_804D3BC:                                ; CODE XREF: sub_804D220+188.j
  565.                                         ; sub_804D220+190.j
  566.                 mov        eax, [ebp-14h]
  567.                 test        eax, eax
  568.                 jz        loc_804D285
  569.                 mov        ecx, [ebp-34h]
  570.                 mov        eax, [ebp-24h]
  571.                 sub        eax, [ebp-38h]
  572.                 sbb        ecx, edx
  573.                 mov        [ebp-34h], ecx
  574.                 mov        edx, ecx
  575.                 mov        cl, byte ptr [ebp-28h]
  576.                 shl        edx, cl
  577.                 mov        cl, byte ptr [ebp-2ch]
  578.                 mov        [ebp-24h], eax
  579.                 shr        eax, cl
  580.                 or        edx, eax
  581.                 mov        eax, [ebp-34h]
  582.                 shr        eax, cl
  583.                 mov        [ebp-20h], edx
  584.                 mov        [ebp-1ch], eax
  585.                 jmp        loc_804D277



  586. sub_804D0D0:

  587.                 push        ebp
  588.                 mov        ebp, esp
  589.                 push        edi
  590.                 push        esi
  591.                 sub        esp, 14h
  592.                 mov        edx, [ebp+14h]
  593.                 mov        esi, [ebp+8]
  594.                 mov        edi, [ebp+12]
  595.                 mov        eax, [ebp+16]
  596.                 test        edx, edx
  597.                 mov        [ebp-10h], esi
  598.                 mov        [ebp-1ch], eax
  599.                 mov        [ebp-0ch], edx
  600.                 mov        esi, edi
  601.                 jnz        short loc_804D110
  602.                 cmp        eax, edi
  603.                 jbe        short loc_804D170
  604.                 mov        edx, edi
  605.                 mov        eax, [ebp-10h]
  606.                 div        dword ptr [ebp-1ch]
  607.                 mov        edi, eax
  608.                 jmp        short loc_804D120
  609. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  610.                 align 10h

  611. loc_804D110:                                ; CODE XREF: sub_804D0D0+21.j
  612.                 cmp        [ebp-0ch], edi
  613.                 jbe        short loc_804D140
  614.                 xor        edi, edi
  615.                 mov        esi, esi
  616.                 lea        edi, [edi+0]

  617. loc_804D120:                                ; CODE XREF: sub_804D0D0+31.j
  618.                                         ; sub_804D0D0+88.j ...
  619.                 mov        dword ptr [ebp-14h], 0
  620.                 mov        edx, [ebp-14h]
  621.                 add        esp, 14h
  622.                 pop        esi
  623.                 mov        eax, edi
  624.                 pop        edi
  625.                 pop        ebp
  626.                 retn
  627. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  628.                 align 10h

  629. loc_804D140:                                ; CODE XREF: sub_804D0D0+43.j
  630.                 bsr        eax, [ebp-0ch]
  631.                 mov        edi, eax
  632.                 xor        edi, 1Fh
  633.                 jnz        short loc_804D1B0
  634.                 cmp        esi, [ebp-0ch]
  635.                 ja        short loc_804D15A
  636.                 mov        edx, [ebp-1ch]
  637.                 xor        edi, edi
  638.                 cmp        [ebp-10h], edx
  639.                 jb        short loc_804D120

  640. loc_804D15A:                                ; CODE XREF: sub_804D0D0+7E.j
  641.                 mov        edi, 1
  642.                 jmp        short loc_804D120
  643. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  644.                 jmp        short loc_804D170
  645. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  646.                 align 10h

  647. loc_804D170:                                ; CODE XREF: sub_804D0D0+25.j
  648.                                         ; sub_804D0D0+91.j
  649.                 mov        eax, [ebp-1ch]
  650.                 test        eax, eax
  651.                 jnz        short loc_804D185
  652.                 mov        eax, 1
  653.                 xor        ecx, ecx
  654.                 xor        edx, edx
  655.                 div        ecx
  656.                 mov        [ebp-1ch], eax

  657. loc_804D185:                                ; CODE XREF: sub_804D0D0+A5.j
  658.                 mov        eax, esi
  659.                 xor        edx, edx
  660.                 div        dword ptr [ebp-1ch]
  661.                 mov        [ebp-14h], eax
  662.                 mov        eax, [ebp-10h]
  663.                 div        dword ptr [ebp-1ch]
  664.                 mov        edx, [ebp-14h]
  665.                 add        esp, 14h
  666.                 mov        edi, eax
  667.                 pop        esi
  668.                 mov        eax, edi
  669.                 pop        edi
  670.                 pop        ebp
  671.                 retn
  672. ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
  673.                 align 10h

  674. loc_804D1B0:                                ; CODE XREF: sub_804D0D0+79.j
  675.                 mov        eax, 20h
  676.                 sub        eax, edi
  677.                 mov        [ebp-18h], eax
  678.                 mov        ecx, edi
  679.                 mov        edx, [ebp-0ch]
  680.                 shl        edx, cl
  681.                 mov        eax, [ebp-1ch]
  682.                 mov        cl, byte ptr [ebp-18h]
  683.                 shr        eax, cl
  684.                 or        edx, eax
  685.                 mov        ecx, edi
  686.                 shl        dword ptr [ebp-1ch], cl
  687.                 mov        [ebp-0ch], edx
  688.                 mov        cl, byte ptr [ebp-18h]
  689.                 mov        edx, esi
  690.                 shr        edx, cl
  691.                 mov        ecx, edi
  692.                 shl        esi, cl
  693.                 mov        eax, [ebp-10h]
  694.                 mov        cl, byte ptr [ebp-18h]
  695.                 shr        eax, cl
  696.                 or        esi, eax
  697.                 mov        ecx, edi
  698.                 mov        eax, esi
  699.                 div        dword ptr [ebp-0ch]
  700.                 mov        esi, edx
  701.                 mov        edi, eax
  702.                 shl        dword ptr [ebp-10h], cl
  703.                 mov        eax, [ebp-1ch]
  704.                 mul        edi
  705.                 cmp        edx, esi
  706.                 ja        short loc_804D20E
  707.                 jnz        loc_804D120
  708.                 cmp        eax, [ebp-10h]
  709.                 jbe        loc_804D120

  710. loc_804D20E:                                ; CODE XREF: sub_804D0D0+12D.j
  711.                 dec        edi
  712.                 jmp        loc_804D120

  713.         }
  714. }



  715. __declspec(naked)  int check(unsigned char * zz ){

  716.         __asm
  717.         {        
  718. push        ebp
  719. mov        ebp, esp
  720. push        ebx
  721. sub        esp, 10h
  722. mov        eax, [ebp+8]
  723. movzx        ebx, word ptr [eax+0Ah]
  724. push        eax
  725. call        sub_80482E8
  726. add        esp, 10h
  727. cmp        ebx, eax
  728. setz        al
  729. movzx        eax, al
  730. mov        ebx, [ebp-4]
  731. leave
  732. retn


  733. sub_80482E8:

  734. push        ebp
  735. mov        ebp, esp
  736. push        esi
  737. push        ebx
  738. xor        ecx, ecx
  739. mov        ebx, [ebp+8]
  740. xor        esi, esi
  741. xor        edx, edx

  742. loc_80482F6:
  743. mov        ax, [ebx+edx*2]
  744. test        ax, ax
  745. jz        short loc_8048304
  746. mov        esi, 1

  747. loc_8048304:
  748. movzx        eax, ax
  749. inc        edx
  750. add        ecx, eax
  751. cmp        edx, 4
  752. jbe        short loc_80482F6
  753. mov        eax, esi
  754. test        al, al
  755. jz        short loc_804831E
  756. not        ecx
  757. movzx        eax, cx

  758. loc_804831A:
  759. pop        ebx
  760. pop        esi
  761. leave
  762. retn

  763. loc_804831E:
  764. mov        eax, 0FFFFh
  765. jmp        short loc_804831A

  766.         }
  767. }



  768. int main(int argc, char* argv[])
  769. {
  770.         register int i,j,k,l,m,n,o,p,q,r,s,t,u,v,zz=0;
  771.         unsigned char *mf;
  772.         unsigned char z;
  773.         FILE *fp;


  774.         if (argc < 2){

  775.         printf ("输入参数: 原文件名 硬盘ID文件\n");
  776.         printf ("\n");
  777.         printf ("本工具的作用是做Mikrotik RouterOS 的序列号计算\n");
  778.         printf ("\n");
  779.         printf ("想得太美 编写于 2007.5.5 17:33\n");
  780.         return 1;}        


  781.         if (( fp = fopen(argv[1],"r")) == NULL)
  782.         {
  783.                 fprintf(stderr,"ID文件打开错误!");
  784.                 _exit (1);
  785.         }
  786.         
  787.         if (fread (hdinfo,1,512,fp) < 512)
  788.         {
  789.                 fprintf(stderr,"ID文件长度不正确!");
  790.                 _exit (1);
  791.         }
  792.         

  793.         mf=mbrinfo+0x100;

  794.         #pragma omp parallel for firstprivate(i,j,l,m,n,o,p,q,r,s,t,u,v,sn,mbrinfo)
  795. for (k=97;k<99;k++){
  796.                 mbrinfo[0x109]=k;
  797.                          for (l=53;l<99;l++){
  798.                                         mbrinfo[0x108]=l;
  799.                                                         for (m=20;m<99;m++){
  800.                                                                 mbrinfo[0x107]=m;
  801.                                                                         for (n=34;n<99;n++){
  802.                                                                                 mbrinfo[0x106]=n;
  803.                                                                                                 for (o=14;o<99;o++){
  804.                                                                                                                 mbrinfo[0x105]=o;
  805.                                                                                                                                 for (p=57;p<99;p++){
  806.                                                                                                                                         mbrinfo[0x104]=p;
  807.                                                                                                                                                 for (q=31;q<56;q++){
  808.                                                                                                                                                         mbrinfo[0x103]=q;
  809.                                                                                                                                                                 for (r=48;r<86;r++){
  810.                                                                                                                                                                 mbrinfo[0x102]=r;
  811.                                                                                                                                                                         for (s=63;s>0;s--){
  812.                                                                                                                                                                                         mbrinfo[0x101]=s;
  813.                                                                                                                                                                                                         for (t=1;t<99;t++){
  814.                                                                                                                                                                                                                         mbrinfo[0x100]=t;
  815.                                                                                                                                                                                                                                         test(dev,mbrinfo,sn);
  816.                                                                                                                                                                                                                                                 if  ( (strncmp(sn,"ILTS-NX0",4) == 0) || (strncmp(sn,"VY3P-XNN",8) == 8) || (strncmp(sn,"LF15-2JT",8) == 0) || (strncmp(sn,"8T9V-HKT",8) == 0)  || (strncmp(sn,"798Y-K0N",8) == 0) || (strncmp(sn,"Q8C4-1AN",8) == 0) || (strncmp(sn,"FAVD-NFT",8) == 0) || (strncmp(sn,"VNDH-NLN",8) == 0)\
  817.                                                                                                                                                                                                                                                         || (strncmp(sn,"AK73-PET",8) == 0)|| (strncmp(sn,"3N5N-F4N",8) == 0)|| (strncmp(sn,"PPT4-3EN",8) == 0)|| (strncmp(sn,"2EM4-MBT",8) == 0)|| (strncmp(sn,"UPBY-JIN",8) == 0)|| (strncmp(sn,"C1HM-PRT",8) == 0)|| (strncmp(sn,"M83D-ICN",8) == 0)|| (strncmp(sn,"NNFT-86N",8) == 0))
  818.                                                                                                                                                                                                                                                         {
  819.                                                                                                                                                                                                                                                                 for (i=0;i<256;i++)        {
  820.                                                                                                                                                                                                                                                                 mbrinfo[0x10a]=i;
  821.                                                                                                                                                                                                                                                                 for (j=0;j<256;j++)        {
  822.                                                                                                                                                                                                                                                                         mbrinfo[256+11]=j;                                                                                                                                                                                                                                                                        
  823.                                                                                                                                                                                                                                                                         if (check(mbrinfo+256)){                                                                                                                                                                                                                                                                                 
  824.                                                                                                                                                                                                                                                 printf("编号:%d,  序列号是:  %s,  关键特征码是:  ",zz++,sn);
  825.                                                                                                                                                                                                                                                 for (u=0x100;u<0x10c;u++)        printf("%02x",mbrinfo[u]);
  826.                                                                                                                                                                                                                                                 printf("\n");
  827.                                                                                                                                                                                                                                                 }}}}}}}}}}}}}}
  828.         return 0;
  829. }
复制代码




routeros
发表于 2019-4-21 07:28:53 | 显示全部楼层
岁月见证时间饶过了谁? 都是牛人
routeros
回复

使用道具 举报

发表于 2019-4-21 17:15:07 | 显示全部楼层
我就是想知道,你复制的内容,每行 带行号,最后一行是944,你用的什么软件?
肯定不是"windows自带 记事本"
routeros
回复

使用道具 举报

发表于 2019-4-22 17:54:15 | 显示全部楼层
汇编部分是用IDA的Hex-Rays Decompiler插件解码的。
routeros
回复

使用道具 举报

发表于 2019-4-24 09:30:08 | 显示全部楼层
老版本了 哈哈
routeros
回复

使用道具 举报

发表于 2019-4-29 18:15:40 | 显示全部楼层
吹嘘认领一下,当时市面流传的套件,其中一个导入key的,是我写的
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-3-29 23:28 , Processed in 0.118089 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表