攻防世界 Reversing-x64Elf-100

XP大水哥發表於2020-12-21

Reversing-x64Elf-100

__int64 __fastcall main(int a1, char **a2, char **a3)
{
  __int64 result; // rax
  char s[264]; // [rsp+0h] [rbp-110h] BYREF
  unsigned __int64 v5; // [rsp+108h] [rbp-8h]

  v5 = __readfsqword(0x28u);
  printf("Enter the password: ");
  if ( !fgets(s, 255, stdin) )
    return 0LL;
  if ( (unsigned int)sub_4006FD((__int64)s) )
  {
    puts("Incorrect password!");
    result = 1LL;
  }
  else
  {
    puts("Nice!");
    result = 0LL;
  }
  return result;
}

找到主要函式sub_4006FD

__int64 __fastcall sub_4006FD(__int64 a1)
{
  int i; // [rsp+14h] [rbp-24h]
  __int64 v3[4]; // [rsp+18h] [rbp-20h]

  v3[0] = (__int64)"Dufhbmf";
  v3[1] = (__int64)"pG`imos";
  v3[2] = (__int64)"ewUglpt";
  for ( i = 0; i <= 11; ++i )
  {
    if ( *(char *)(v3[i % 3] + 2 * (i / 3)) - *(char *)(i + a1) != 1 )
      return 1LL;
  }
  return 0LL;
}

寫個Python指令碼
a1為所求的flag

str=["Dufhbmf","pG`imos","ewUglpt"]
flag=''
for i in range(12):
    flag+=chr(ord(str[i % 3][2 * int(i / 3)])-1)
print(flag)

Code_Talkers

遇到過的問題

TypeError: string indices must be integers

這個錯誤意思是字串的下標一定要是整數