首页
社区
课程
招聘
[原创]KCTF 2019 Q1 第6题----Repwn
2019-3-24 10:39 2939

[原创]KCTF 2019 Q1 第6题----Repwn

2019-3-24 10:39
2939

Repwn


1、根据字符串“Please Input Your Key_ Now!“找到输入key的代码在0x0x4015A2,在4015AA处调用了sub_4012F0用于比较key的第8-19位和20位
.text:00401588                 mov     [esp+68h+Str], offset Str ; "Please Input Your Key_ Now!"
.text:0040158F                 lea     ebx, [ebp+var_28]
.text:00401592                 call    puts
.text:00401597                 mov     [esp+68h+var_64], ebx
.text:0040159B                 mov     [esp+68h+Str], offset aS ; "%s"
.text:004015A2                 call    scanf
.text:004015A7                 mov     [esp+68h+Str], ebx
.text:004015AA                 call    sub_4012F0      ; 比较key的第8-19位是不是==X1Y0uN3tG00d,第20位是不是==H(0x48)
.text:004015AF                 test    eax, eax
.text:004015B1                 jnz     short loc_4015C7
.text:004015B3                 lea     eax, [ebp+var_58]
.text:004015B6                 mov     [esp+68h+Str], eax ; Str
.text:004015B9                 call    puts
.text:004015BE                 lea     esp, [ebp-8]
.text:004015C1                 xor     eax, eax
.text:004015C3                 pop     ebx
.text:004015C4                 pop     esi
.text:004015C5                 pop     ebp
.text:004015C6                 retn

2、第一步比较通过之后会跳到0x4015C7,调用了sub_401460这个函数。
    1)、这个函数在401472处比较key的长度是不是等于0x18如果不等则错误
    2)、在0x401493调用了函数sub_4013B0,用于校验0-7位是否符合条件
   3)、在0x4014B6利用strcpy的栈溢出漏洞跳转到第二个key的输入和校验处,溢出地址可以由字符串"pause"找到;有两处引用了这个字符串,其中由0x401BC7处引用了这个字符串。再往前回溯找到0x401CE1调用了这个函数,可以得出溢出地址是0x401BF0。
1460 sub_401460      proc near               ; CODE XREF: sub_4014C0+10Ap
.text:00401460
.text:00401460 Str             = dword ptr -18h
.text:00401460 Source          = dword ptr -14h
.text:00401460 Dest            = byte ptr -10h
.text:00401460 arg_0           = dword ptr  8
.text:00401460
.text:00401460                 push    ebp
.text:00401461                 mov     ebp, esp
.text:00401463                 push    ebx
.text:00401464                 sub     esp, 14h
.text:00401467                 mov     ebx, [ebp+arg_0]
.text:0040146A                 mov     [esp+18h+Str], ebx ; Str
.text:0040146D                 call    strlen
.text:00401472                 cmp     eax, 18h
.text:00401475                 jz      short loc_401490
.text:00401477                 mov     [esp+18h+Str], offset aStringLengthIs ; "String Length is Wrong"
.text:0040147E                 call    printf
.text:00401483
.text:00401483 loc_401483:                             ; CODE XREF: sub_401460+3Aj
.text:00401483                                         ; sub_401460+5Bj
.text:00401483                 add     esp, 14h
.text:00401486                 xor     eax, eax
.text:00401488                 pop     ebx
.text:00401489                 pop     ebp
.text:0040148A                 retn
.text:0040148A ; ---------------------------------------------------------------------------
.text:0040148B                 align 10h
.text:00401490
.text:00401490 loc_401490:                             ; CODE XREF: sub_401460+15j
.text:00401490                 mov     [esp+18h+Str], ebx
.text:00401493                 call    sub_4013B0      ; 校验第0-7位是否符合条件
.text:00401498                 test    eax, eax
.text:0040149A                 jz      short loc_401483
.text:0040149C                 sub     byte ptr [ebx+14h], 58h
.text:004014A0                 lea     eax, [ebp+Dest]
.text:004014A3                 sub     byte ptr [ebx+15h], 46h
.text:004014A7                 sub     byte ptr [ebx+16h], 3
.text:004014AB                 sub     byte ptr [ebx+17h], 6Bh
.text:004014AF                 mov     [esp+18h+Source], ebx ; Source
.text:004014B3                 mov     [esp+18h+Str], eax ; Dest
.text:004014B6                 call    strcpy
.text:004014BB                 jmp     short loc_401483
.text:004014BB sub_401460      endp


3、校验算法
// 校验第0-7位是否符合条件
signed int __cdecl sub_4013B0(int a1)
{
  int v1; // ebx@1
  int v2; // ecx@1
  int v3; // esi@1
  signed int result; // eax@2

  sub_401380(a1);
  v1 = dword_40802C + 1000 * dword_408020 + 100 * dword_408024 + 10 * dword_408028;
  v2 = dword_408034 + 10 * dword_408030;
  v3 = dword_40803C + 10 * dword_408038;
  if ( 2 * (v1 + v2) != 4040 || 3 * v2 / 2 + 100 * v3 != 115 )
    goto LABEL_2;
  result = 1;
  if ( v1 - 110 * v3 != 1900 )
  {
    printf("Key_Is_Wrong,Please_Input_Again!");
LABEL_2:
    result = 0;
  }
  return result;
}

由上面3步可以得出第一层的key是:20101001X1Y0uN3tG00dHaCk


第二个key目前还没有看出是什么算法

[培训]二进制漏洞攻防(第3期);满10人开班;模糊测试与工具使用二次开发;网络协议漏洞挖掘;Linux内核漏洞挖掘与利用;AOSP漏洞挖掘与利用;代码审计。

收藏
点赞3
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回