드림핵 dungeon-in-1983

Tamszero·2025년 5월 15일

이비전

목록 보기
12/12

main함수의 문제 진행 코드

 stream = fopen("/dev/urandom", "r");
  puts("Welcome to the Dungeon!");
  puts("You have only two buttons: A and B.");
  puts("Each monster requires certain series of key combinations to be defeated, so be careful!");
  for ( i = 0; i <= 9; ++i )
  {
    fread(&ptr, 8uLL, 1uLL, stream);
    printf("[STAGE %2d]: %s\n", i + 1, (const char *)v8 + 20 * i);
    sub_138D(ptr);
    printf("Cast your spell!: ");
    fgets(s, 200, stdin);
    if ( s[strlen(s) - 1] == 10 )
      s[strlen(s) - 1] = 0;
    if ( !(unsigned int)sub_1407(s, ptr) )
    {
      puts("You were defeated. Retreat!");
      exit(-1);
    }
    printf("%s defeated. STAGE %2d cleared!\n", (const char *)v8 + 20 * i, i + 1);
  }
  fclose(stream);
  printf("It's dangerous to go alone! Take the flag: ");
  lineptr = 0LL;
  ptr = 0LL;
  stream = fopen("./flag", "r");
  getline(&lineptr, &ptr, stream);
  printf("%s", lineptr);
  free(lineptr);
  fclose(stream);
  return 0LL;
}

문제에 접속해보면 welcome 던전~~
어쩌구 저쩌구가 나오고
스테이지 1~10까지의 문제를 풀어야 해결되는 게임인듯

먼저 랜덤으로 숫자를 생성해 드래곤의 능력치를 출력한다

"[INFO] HP: %5hu, STR: %5hhu, AGI: %5hhu, VIT: %5hhu, INT: %5hhu, END: %5hhu, DEX: %5hhu\n",

문제에서 익스플로잇 코드를 짜야하는 가장 중요한 서브함수 1407

_BOOL8 __fastcall sub_1407(__int64 a1, __int64 a2)
{
  int v2; // eax
  int v4; // [rsp+1Ch] [rbp-14h]
  int v5; // [rsp+20h] [rbp-10h]
  int i; // [rsp+24h] [rbp-Ch]
  __int64 v7; // [rsp+28h] [rbp-8h]

  v7 = 0LL;
  v4 = 0;
  v5 = 0;
  for ( i = 0; *(_BYTE *)(i + a1); ++i )
  {
    v2 = *(char *)(i + a1);
    if ( v2 == 65 )
    {
      v5 = 1;
      ++v7;
      if ( v4 )
      {
        puts("A button stucked! Retreat...");
        exit(-1);
      }
      v4 = 1;
    }
    else
    {
      if ( v2 != 66 )
      {
        puts("Invalid button!");
        exit(-1);
      }
      if ( !v5 )
      {
        puts("Lore says the spell should start with A...");
        exit(-1);
      }
      v7 *= 2LL;
      v4 = 0;
    }
  }
  return v7 == a2;

익스플로잇 코드는 아직 짜는중...어려워여

0개의 댓글