MS16-077の解析

まずws2_32

 L719E9B5B:
          cmp    dword ptr [ebp+0Ch],00000017h
          jnz    L719E9C11
          lea    edx,[ebp-00000850h]
          mov    [ebp-00000868h],eax
;***********
          jmp    L719E60BC

 L719E9C1B:
          push    [ebp+24h]
          push    edi
          push    [ebp+1Ch]
          push    [ebp+18h]
          push    00000017h
;
          push    [ebp-04h]
          call    SUB_L719E5FC0
          mov    esi,eax
          cmp    esi,ebx
          jz     L719E5F79
          jmp    L719E5FA6
       
 SUB_L719E5F41:
          mov    edi,edi
          push    ebp
          mov    ebp,esp
          push    ecx
          push    ecx
          mov    eax,[ebp+08h]
          mov    [ebp-04h],eax
          mov    eax,[ebp+10h]
          push    ebx
          xor    ebx,ebx

          mov    [eax],ebx
          mov    eax,[ebp+14h]
          mov    [eax],ebx
          mov    eax,[ebp+18h]
          mov    [eax],ebx
          mov    eax,[ebp+1Ch]
          push    esi
          push    edi
          mov    edi,[ebp+20h]
          mov    [eax],ebx
;       
          mov    [ebp-08h],ebx
        mov    [edi],ebx
       
 L719E5F6F:
          test    byte ptr [ebp+0Ch],02h
          jnz    L719E9C1B
 L719E5F79:
          test    byte ptr [ebp+0Ch],01h
          jz     L719E5F99
          push    [ebp+24h]
          push    edi
          push    [ebp+14h]
          push    [ebp+10h]
          push    00000002h

          push    [ebp-04h]
          call    SUB_L719E5FC0
          mov    esi,eax
          cmp    esi,ebx
          jnz    L719E5FA6
 L719E5F99:
          mov    eax,[ebp+14h]
          cmp    [eax],ebx
          jz     L719E9869
 L719E5FA4:
          xor    esi,esi
 L719E5FA6:
          mov    eax,[ebp-04h]
          cmp    eax,[ebp+08h]
          jnz    L719E9C99
 L719E5FB2:
          pop    edi
          mov    eax,esi
          pop    esi
          pop    ebx
          leave
          retn    0020h

旧コード

 L719E9B5A:
          cmp    dword ptr [ebp+10h],00000017h
          jnz    L719E9C55
          lea    edx,[ebp-00000850h]
          mov    [ebp-00000874h],eax
 L719E9B70:
          xor    eax,eax
          test    byte ptr [ebp+0Ch],80h
          push    0000000Fh
          pop    ecx
          lea    edi,[ebp-00000840h]
          rep stosd
          mov    eax,[ebp+08h]
          mov    [ebp-0000083Ch],eax
          mov    dword ptr [ebp-00000840h],0000003Ch
          mov    dword ptr [ebp-0000082Ch],0000000Ch
          mov    [ebp-00000838h],edx
          mov    eax,00020000h
          jnz    L719E60E5
          mov    eax,[ebp-00000868h]
          jmp    L719E60E5

 L719E9C6F:
          push    [ebp+24h]
          push    esi
          push    [ebp+1Ch]
          push    [ebp+18h]
          push    00000017h
          push    [ebp-08h]

          push    [ebp-04h]
          call    SUB_L719E5FD6
          mov    edi,eax
          cmp    edi,ebx
          jz     L719E5F8C
          jmp    L719E5FBC

 L719E98A8:
          test    byte ptr [ebp+1Ch],10h
          jz    L719E5E3F
          or    esi,00000010h
          jmp    L719E5E3F
               
 SUB_L719E5F46:
          mov    edi,edi
          push    ebp
          mov    ebp,esp

          sub    esp,0000000Ch
          mov    eax,[ebp+08h]
          mov    [ebp-04h],eax
          mov    eax,[ebp+10h]
          push    ebx
          xor    ebx,ebx
          test    byte ptr [ebp+0Ch],10h
          mov    [eax],ebx
          mov    eax,[ebp+14h]
          mov    [eax],ebx
          mov    eax,[ebp+18h]
          mov    [eax],ebx
          mov    eax,[ebp+1Ch]
          push    esi

          mov    esi,[ebp+20h]
          mov    [eax],ebx
          push    edi
          mov    [ebp-0Ch],ebx
          mov    [ebp-08h],ebx
          mov    [esi],ebx
        jz  L719E5F82
          and    dword ptr [ebp+0Ch],FFFFFFEFh
          mov    dword ptr [ebp-08h],00000080h
 L719E5F82:
          test    byte ptr [ebp+0Ch],02h
          jnz    L719E9C6F
 L719E5F8C:
          test    byte ptr [ebp+0Ch],01h
          jz     L719E5FAF
          push    [ebp+24h]
          push    esi
          push    [ebp+14h]
          push    [ebp+10h]
          push    00000002h
          push    [ebp-08h]
          push    [ebp-04h]
          call    SUB_L719E5FD6
          mov    edi,eax
          cmp    edi,ebx
          jnz    L719E5FBC
 L719E5FAF:
          mov    eax,[ebp+14h]
          cmp    [eax],ebx
          jz     L719E9859
 L719E5FBA:
          xor    edi,edi
 L719E5FBC:
          mov    eax,[ebp-04h]
          cmp    eax,[ebp+08h]
          jnz    L719E9CF0
 L719E5FC8:
          mov    eax,edi
          pop    edi
          pop    esi
          pop    ebx
          leave
          retn    0020h

新コード

どうやら、 GetAddrInfo の内部処理なんだけど、ws2_32.dllについては、Windows 2000は独自実装なので影響ないようだ・ω・


次、netbt.sys

 SUB_L00025897:
          mov    edi,edi
          push    ebp
          mov    ebp,esp
          sub    esp,00000018h
          mov    eax,[ebp+14h]
          push    esi
          mov    esi,[ebp+0Ch]
          add    eax,00000011h
          cmp    esi,eax
          jbe    L000258B7
          mov    eax,C000021Bh
          jmp    L00025B54
 L000258B7:
          push    ebx
          push    edi
          mov    ecx,L0002BA8C
          call    [HAL.dll!KfAcquireSpinLock]
          cmp    byte ptr [L0002BB52],00h
          mov    [ebp+0Fh],al
          jnz    L000258EB
          push    [ebp+18h]
          call    SUB_L0002546D
          test    al,al
          jnz    L000258EB
          push    [ebp+1Ch]
          push    [ebp+18h]
          call    SUB_L0001604C
          test    al,al
          jz     L0002595E

 L000258EB:
          movzx    ecx,[L0002BA50]

          mov    eax,[ebp+08h]
          lea    edx,[esi-31h]
          add    eax,0000002Dh
          cmp    edx,ecx
          jnz    L0002595E
          xor    edx,edx
          test    ecx,ecx
          jbe    L0002591A
          mov    edi,[L0002BA54]
          sub    edi,eax
 L0002590D:
          mov    bl,[eax]
          cmp    bl,[edi+eax]
          jnz    L0002595E
          inc    edx
          inc    eax
          cmp    edx,ecx
          jc     L0002590D
 L0002591A:
          push    L0002B940
          call    SUB_L000240E0
          mov    ecx,000000FFh
          cmp    eax,ecx
          mov    [ebp-08h],eax
          jbe    L00025935
          mov    [ebp-08h],ecx
          mov    eax,ecx
 L00025935:
          lea    eax,[eax+eax*8-09h]
          lea    edi,[esi+eax*2+47h]
          movzx    eax,di
          push    4174624Eh
          push    eax
          push    00000000h
          mov    [ebp-10h],edi
          call    [ntoskrnl.exe!ExAllocatePoolWithTag]
          mov    ebx,eax
          test    ebx,ebx
          jnz    L00025976
          mov    esi,C000009Ah
          jmp    L00025963
        
 L000263EC:
          mov    eax,[esi+70h]
          mov    [ebp+0Ch],eax
 L000263F2:
          cmp    byte ptr [L0002BB52],00h
          jnz    L0002641E
          push    [ebp+0Ch]
          call    SUB_L0002546D
          test    al,al
          jnz    L0002641E
          mov    eax,[esi+14h]
          movzx    eax,[eax+000001FAh]
          push    eax
          push    [ebp+0Ch]
          call    SUB_L0001604C
          test    al,al
          jz     L000263AC
 L0002641E:
          xor    eax,eax
          mov    ax,[L0002BA4C]
          push    00000001h
          push    eax
          lea    eax,[ebp-0Ch]
          push    eax
          push    [esi+14h]
          push    [esi+58h]
          push    [esi+5Ch]
          push    00000000h
          push    esi
   &n
bsp;      push    [L0002BA30]
          push    L000261A3
          call    SUB_L00012B9D
          test    eax,eax
          jl     L000263AC
          test    ebx,ebx
          jz     L00026467
          xor    ecx,ecx
          lea    eax,[ebx+0Ch]
          inc    ecx
          lock
          xadd    [eax],ecx
          mov    eax,[ebp+0Ch]
          mov    [esi+70h],eax
          jmp    L0002646E
 L00026467:
          // mov    eax,[esi+70h]
          mov    ebx,[esi+34h]
          and    dword ptr [esi+34h],00000000h
         //   mov    [ebp+0Ch],eax       
 L0002646E:
          mov    eax,[ebp-0Ch]
          push    L0002BA90
          mov    edx,esi
          mov    ecx,L0002B960
          mov    [esi+1Ch],ebx
          mov    [esi+50h],eax
          call    [ntoskrnl.exe!ExfInterlockedInsertTailList]
          mov    dl,[ebp-01h]
          mov    ebx,[HAL.dll!KfReleaseSpinLock]
          mov    ecx,edi
          call    ebx
          mov    eax,[esi+14h]
          movzx    eax,[eax+000001FAh]
          push    00000010h
          push    eax
          push    esi
          push    L0002875C
          push    [ebp+0Ch]
          push    esi
          call    SUB_L000120A6
          test    eax,eax
          jge    L000263E5
          mov    ecx,edi
          call    [HAL.dll!KfAcquireSpinLock]
          push    00000000h
          push    [esi+24h]
          mov    [ebp-01h],al
          call    [ntoskrnl.exe!ExFreePoolWithTag]
          and    dword ptr [esi+24h],00000000h
          push    00000001h
          push    esi
          call    SUB_L000161B1
          mov    dl,[ebp-01h]
          mov    ecx,edi
          call    ebx
          jmp    L000263E5
;——————————————————————————
          jz     L00031442
          mov    word ptr [esi+000000E0h],000Ah
          mov    word ptr [esi+000000E2h],000Ah
          mov    word ptr [esi+000000E6h],0010h
          mov    word ptr [esi+000000E4h],0010h
          mov    word ptr [esi+7Ah],0014h
 L0002EB32:
          or    word ptr [esi+7Eh],FFFFh
 L0002EB37:
          push    edi
          push    esi
          call    SUB_L0002F3A2
          push    ebx
          push    ebx
          push    SWC000314CC_AllowNBToInternet
          push    edi
          call    SUB_L0002E090
          pop    edi
          mov    [esi+00000212h],al

          pop    esi
          pop    ebx
          pop    ebp
          retn    0008h
 SWC000314CC_AllowNBToInternet:
          unicode    ‘AllowNBToInternet’,0000h      
 
;——————————————————————————
 L0002BB52:
         db    00h;
 SUB_L000164D6:
          mov    edi,edi
          push    ebp
          mov    ebp,esp
          sub    esp,00000068h
          mov    eax,[L0002B5D0]
          mov    [ebp-04h],eax
          mov    eax,[ebp+08h]
          and    dword ptr [ebp-28h],00000000h
          mov    [ebp-2Ch],eax
          mov    eax,[ebp+0Ch]
          push    ebx          mov    ebx,[eax+0Ah]
          mov    [ebp-64h],eax
          add    eax,00000008h
          mov    [ebp-30h],eax
          mov    ax,[eax]
          mov    ch,al
          push    esi
          mov    esi,[ebp+10h]
          push    edi
          mov    edi,[ebp+14h]
          bswap    ebx
          mov    [ebp-48h],esi
          mov    cl,ah
          movzx    eax,[L0002BA50]
          add    eax,00000031h
          cmp    edi,eax
          mov    [ebp-3Ch],ebx
          mov    [ebp-38h],ecx
          jl     L000164BD
          lea    eax,[ebp-20h]
          push    eax
          lea    eax,[ebp-4Ch]
          push    eax
          lea    eax,[ebp-14h]
          push    eax
          lea    eax,[edi-0Dh]
          push    eax
          lea    eax,[esi+0Ch]
          push    eax
          call    SUB_L000106C1
          test    eax,eax
          jl     L000164BD
          test    byte ptr [ebp+18h],80h

          jz     L000210D1
          test    byte ptr [ebp+18h],04h
          jz     L000164BD
          mov    eax,[ebp-20h]
          lea    edi,[esi+eax+0Dh]
          cmp    byte ptr [edi+01h],21h
          jz     L00020C71
          mov    ecx,L0002BA8C
          call    [HAL.dll!KfAcquireSpinLock]
          push    ebx
          mov    [ebp-1Ch],al
          call    SUB_L000155ED
          test    al,al
          jz     L00020D01
          cmp    dword ptr [L0002B6F8],00000000h
          jz     L00020F24
 L00020D01:
          cmp    byte ptr [L0002BB52],00h
          jnz    L00020D25
          push    ebx
          call    SUB_L0002546D
          test    al,al
          jnz    L00020D25
          push    [ebp-38h]
          push    ebx
          call    SUB_L0001604C
          test    al,al
          jz     L00020F24
 L00020D25:
          mov    dl,[ebp-1Ch]
          mov    ecx,L0002BA8C
          call    [HAL.dll!KfReleaseSpinLock]
          mov    eax,[ebp+18h]
          mov    ecx,[ebp-20h]
          and    eax,00000F00h
          mov    [ebp-58h],eax
          jnz    L000183AC
 L00016295:
          add    ecx,0000001Dh
 L00016298:
          mov    eax,[ebp+14h]
          cmp    eax,ecx
          jl     L000164BD
          lea    ecx,[edi+0Ah]
          mov    [ebp-44h],ecx
          mov    cx,[edi+08h]
          mov    dh,cl
          sub    esi,edi
          lea    eax,[esi+eax-0Ah]
          mov    [ebp-24h],eax
          mov    dl,ch
          mov    ecx,edx
          movzx    ecx,cx
          cmp    ecx,eax
          jc     L00020D4C
 L000162C7:
          push    00000006h
          xor    edx,edx
          pop    ecx
          div    ecx
          mov    ebx,eax
          test    ebx,ebx
          jnz    L00020D56
 L000162D8:
          mov    edi,[HAL.dll!KfAcquireSpinLock]
          mov    esi,L0002BA8C
          mov    ecx,esi
          call    edi
          mov    [eb
p-1Ch],al
          lea    eax,[ebp-18h]
          push    eax
          push    00000010h
          push    00000000h
          push    [ebp-48h]
          lea    eax,[ebp-14h]
          push    eax
          call    SUB_L000160BF
          test    eax,eax
          jl     L00020FFE
          mov    eax,[ebp-20h]
          mov    ecx,[ebp-48h]
          lea    eax,[ecx+eax+0Dh]
          mov    [ebp-68h],eax
          mov    eax,[ebp-18h]
          mov    eax,[eax+60h]
          test    eax,eax
          mov    [ebp-30h],eax
          jz     L000210B1
          mov    edi,[eax+1Ch]
          push    [ebp-38h]
          mov    eax,[edi+00000088h]
          push    [ebp-3Ch]
          mov    [ebp-5Ch],edi
          mov    [ebp-40h],eax
          call    SUB_L0001604C
          test    al,al
          jz     L0001634C
          test    byte ptr [ebp-40h],08h
          jnz    L00020DF4
 L0001634C:
          mov    ecx,[ebp-18h]
          cmp    byte ptr [ecx+6Ch],00h
          jnz    L00016360
          cmp    word ptr [ebp-58h],0000h
          jnz    L000183B4
 L00016360:
          mov    eax,[ecx+34h]
          test    eax,eax
          jz     L00020F2E
          mov    edx,[ebp-28h]
          test    edx,edx
          jnz    L00020E07
 L00016376:
          mov    eax,[ecx+34h]
          mov    eax,[eax+64h]
          test    eax,eax
          jnz    L00020E87
 L00016384:
          lea    esi,[ebx+ebx*2]
          shl    esi,1
          jz     L00020EF5
          mov    eax,[ebp-18h]
          mov    eax,[eax+34h]
          mov    ecx,[edi+00000088h]
          mov    [eax+60h],ecx
          mov    eax,[ebp-18h]
          mov    eax,[eax+34h]
          mov    cx,[edi+6Ch]
          mov    [eax+6Ch],cx
          mov    eax,[ebp-18h]
          mov    eax,[eax+34h]
          mov    cx,[edi+6Eh]
          mov    [eax+6Eh],cx
 L000163BA:
          mov    eax,[ebp-18h]
          mov    edi,[edi+14h]
          and    dword ptr [eax+60h],00000000h
          mov    eax,[ebp-18h]
          xor    ebx,ebx
          inc    ebx
          add    eax,0000000Ch
          mov    ecx,ebx
          lock
          xadd    [eax],ecx
          lea    eax,[ebp-60h]
          push    eax
          lea    eax,[ebp-54h]
          push    eax
          push    [ebp-30h]
          call    SUB_L00012C7F
          cmp    dword ptr [ebp-54h],00000000h
          jz     L00020FEA
          cmp    word ptr [ebp-58h],0000h
          mov    ecx,[ebp-18h]
          mov    eax,[ecx]
          mov    ecx,[ecx+04h]
          mov    [ecx],eax
          mov    [eax+04h],ecx
          mov    eax,[ebp-18h]
          mov    [eax+04h],eax
          mov    [eax],eax
          jnz    L00020F75
          push    [ebp-38h]
          push    [ebp-3Ch]
          call    SUB_L0001604C
          test    al,al
          mov    [ebp-50h],al
          jz     L00020F4B
 L00016423:
          push    [ebp-50h]
   &
nbsp;      push    00000000h
          call    SUB_L0001609B
          test    byte ptr [L0002B894],10h
          jnz    L00020F59
 L0001643A:
          mov    eax,[ebp-18h]
          mov    ecx,[edi+00000158h]
          add    eax,00000040h
          or    [eax],ecx
          mov    ecx,[edi+0000015Ch]
          or    [eax+04h],ecx
          push    [ebp-1Ch]
          push    [ebp-60h]
          push    [ebp-38h]
          push    [ebp-3Ch]
          call    SUB_L0001604C
          push    eax
          push    edi
          lea    eax,[ebp-64h]
          push    eax
          mov    eax,[ebp-68h]
          push    esi
          push    [ebp-18h]
          add    eax,0000000Ah
          push    eax
          call    SUB_L000166B9
          and    dword ptr [ebp-18h],00000000h
          mov    edi,eax
 L0001647E:
          test    byte ptr [ebp-3Fh],02h
          jnz    L0001649B
          mov    eax,[ebp-2Ch]
          mov    ecx,[eax+00000124h]
          mov    edx,[ebp-64h]
          bswap    ecx
          cmp    [edx+0Ah],ecx
          jz     L00020FDF
 L0001649B:
          mov    dl,[ebp-1Ch]
          mov    ecx,L0002BA8C
          call    [HAL.dll!KfReleaseSpinLock]
          cmp    edi,00000103h
          jz     L000164BD
          push    edi
          push    [ebp-60h]
          push    [ebp-54h]
          call    SUB_L00016147
 L000164BD:
          mov    ecx,[ebp-04h]
          pop    edi
          pop    esi
          mov    eax,C000021Bh
          pop    ebx
          call    SUB_L00010615
          leave
          retn    0018h

 L00020C71:
          mov    edi,L0002BA8C
          mov    ecx,edi
          call    [HAL.dll!KfAcquireSpinLock]
          cmp    byte ptr [L0002BB52],00h
          mov    [ebp-1Ch],al
          jnz    L00020CA5
          push    ebx
          call    SUB_L0002546D
          test    al,al
          jnz    L00020CA5
          push    [ebp-38h]
          push    ebx
          call    SUB_L0001604C
          test    al,al
          jz     L00021240
 L00020CA5:
          mov    dl,[ebp-1Ch]
          mov    ecx,edi
          call    [HAL.dll!KfReleaseSpinLock]
          mov    edx,[ebp-20h]
          lea    ecx,[edx+18h]
          cmp    [ebp+14h],ecx
          jl     L000164BD
          movzx    eax,[esi+edx+17h]
          lea    eax,[eax+eax*8]
          lea    eax,[ecx+eax*2]
          cmp    [ebp+14h],eax
          jl     L000164BD
          push    ebx
          push    edx
          lea    eax,[ebp-14h]
          push    eax
          push    [ebp+14h]
          push    esi
          call    SUB_L00024E81
          jmp    L000164BD
 L00020D4C:
          mov    eax,ecx
          mov    [ebp-24h],eax
          jmp    L000162C7

 SUB_L0002546D:
          mov    edi,edi
          push    ebp
          mov    ebp,esp
          mov    eax,[L0002B940]
       &
nbsp;  push    esi
          mov    edx,L0002B940
          jmp    L00025490
 L0002547F:
          mov    ecx,[eax+54h]
          mov    esi,[eax+50h]
          and    esi,ecx
          and    ecx,[ebp+08h]
          cmp    esi,ecx
          jz     L0002549B
          mov    eax,[eax]
 L00025490:
          cmp    eax,edx
          jnz    L0002547F
          xor    al,al
 L00025496:
          pop    esi
          pop    ebp
          retn    0004h
;——————————————————————————
 L0002549B:
          mov    al,01h
          jmp    L00025496

書き換え範囲多いので旧コード省略

XP版はそのまま動作させることができない

おすすめ

2件のフィードバック

  1. ななし より:

    これは既に拡張カーネルに組み込まれているのでしょうか?

  2. 黒翼猫 より:

    1/3 程組み込まれています。
    全部組み込むとクラッシュするため調査中です

黒翼猫 へ返信する コメントをキャンセル

メールアドレスが公開されることはありません。 が付いている欄は必須項目です