Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
titlemain
__int64 __fastcall main(__int64 a1, char **a2, char **a3)
{
  signed int state; // [rsp+4h] [rbp-Ch]

  state = 1;
  signal(14, handler);
  alarm(0x1Eu);
  title();
  setCandy();
  gOrderCnt = 0;
  gLoginFailCnt = 0;
  while ( !gLoginAccount )
  {
    if ( (unsigned int)login() )
    {
      gLoginFailCnt = 0;
LABEL_14:
      while ( state && gLoginAccount )
      {
        Menu();
        printf("Command : ");
        switch ( (unsigned int)retNumber(2LL) )
        {
          case 0u:
            state = 0;
            break;
          case 1u:
            printStock();
            break;
          case 2u:
            purchase();
            break;
          case 3u:
            charge();
            break;
          case 4u:
            if ( gLoginAccount->state == 1 )
              orderMenu();
            break;
          case 5u:
            if ( gLoginAccount->state == 1 )
              Account();
            break;
          case 9u:
            logout(2LL);
            break;
          default:
            goto LABEL_14;
        }
      }
    }
    else
    {
      if ( gLoginFailCnt == 2 )
        exit(1);
      ++gLoginFailCnt;
      puts("\nCreate an account?");
      puts("0) Yes\n1) No");
      if ( !(unsigned int)retNumber(2LL) )
        addAccount(3LL);
    }
  }
  return 0LL;
}

...

addAccount

  • 해당 함수는 다음과 같은 기능을 합니다.

    • 해당 함수는 전역 변수

      gStock를 이용해 사탕 정보를 출력합니다

      gAccount[].state 의 값이 '0' 인 경우 다음과 같이 동작합니다.

      • 해당 함수는 malloc()을 사용하여 128 byte의 heap 영역을 할당받습니다.

        • 해당 함수는 해당 영역의 주소를 gAccount[i].fd에 저장합니다.

        • 해당 함수는 해당 영역에 ID, Password,등의 정보를 저장합니다.
Code Block
languagecpp
titleprintStockaddAccount(unsigned int a1)
unsigned __int64 __fastcall printStockaddAccount(unsigned int a1)
{
  unsigned int i; // [rsp+4h10h] [rbp-Ch10h]
  unsignedsigned __int64int v2empty; // [rsp+8h14h] [rbp-8hCh]

  v2unsigned = __readfsqword(0x28u);
  if ( gStockCnt )
  {
  int64 v4; // [rsp+18h] [rbp-8h]

  v4 = __readfsqword(0x28u);
  empty = 1;
  for ( i = 0; i < gStockCnt= 2 && empty; ++i )
    {
     if printf("\n=*= Candy %d =*=\n", i); !gAccount[i].state )
    {
  printf("Name of candy  empty = 0;
    : %s\n", gStockgAccount[i]).state = a1;
      printf("Number of candy  gAccount[i].number = i + 1;
    : %d\n", gStockgAccount[i]->candyNumber);
      printf("Price of candy       : %d\n", gStock[i]->candyPrice).fd = (struct IDPW *)malloc(128uLL);
      gAccount[i].fd->state = 1LL;
      printfputs("Description\nEnter ofyour candy : %s\n", gStock[i]->candyDescriptionNew ID.");
    }
  }
  elseUserInput(gAccount[i].fd->id, 8LL);
  {
    puts("WeEnter haveyour notNew any candyPassword.");
  }
   return __readfsqword(0x28u) ^ v2;
}
  • 다음과 같은 구조체를 사용합니다.
Code Block
languagecpp
titlestruct STOCK
struct STOCK{
    char candyName[8]UserInput(gAccount[i].fd->pw, 8LL);
      puts("Enter your profile.");
      UserInput(gAccount[i].fd->description, 88LL);
    unsigned int  candyNumber  gAccount[i].bk = 10000LL;
    unsigned int  candyPrice}
  }
  if ( empty )
    puts("Could not add user.");
  return  char *candyDescription__readfsqword(0x28u) ^ v4;
};

purchase

  • 해당 함수는 다음과 같은 기능을 합니다구조체를 사용합니다.
    • 해당 함수는 전역 변수 gStockCnt의 값이 0일 경우 메시지 출력 해당 기능을 종료합니다.

    • 해당 함수는 전역 변수 gStockCnt의 값이 0이 아닐 경우 다음과 같은 기능을 합니다.

      • 해당 함수는 사용자로 부터 구매 할 캔디의 코드 번호(candyInfo[0]), 캔디의 수(candyInfo[1])를 입력받습니다.

        • 해당 함수는 구매 가능한 캔디 코드 번호, 캔디의 개수인지 확인합니다.

      • 해당 함수는 정상적인 구매가 진행 되며, 캔디의 재고가 없을 경우 아래 함수가 호출됩니다.

        • reSortStock()

        • setBoard()


Code Block
struct IDPW{
    long empty[2];
    char id[8];
    char pw[8];
    long state;
    char description[88];
};

struct ACCOUNT{
    long state;
    long number;
    struct IDPW *fd;
    long bk;
};


delAccount

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 전역 변수 gAccount[]를 이용해 삭제 가능한 계정들을 출력합니다.
    • 해당 함수는 사용자로 부터 삭제 할 계정의 번호를 입력 받습니다.
    • 해당 함수는 사용자가 선택한 계정의 state 정보가 '3' 일 경우 삭제를 진행합니다.

      • 해당 함수는 해당 계정(gAccount[num])의 정보를 초기화 합니다.

        • state = 0

        • fd→state = 0

        • memset(gAccount[num].fd, 0, 0x80uLL);

      • 해당 함수는 해당 계정(gAccount[num])의 fd 영역(heap)을 해제 합니다.

    •  해당 함수는 gAccount[num].fd 영역에 "gAccount[num].fd - 16" 연산 한 값을 저장합니다.

      • 저장되는 값은 Free chunk의 Head 주소입니다.
      • 이것으로 인해 The House of Lore 취약성이 발생하게 됩니다.
Code Block
languagecpp
titledelAccount()
unsigned __int64 delAccount()
{
  unsigned int i; // [rsp+8h] [rbp-18h]
  unsigned int num; // [rsp+Ch] [rbp-14h] MAPDST
  unsigned __int64 v4; // [rsp+18h] [rbp-8h]

  v4 = __readfsqword(0x28u);
  puts("\nAccount list");
  for ( i = 0; i <= 2; ++i )
  {
    if ( gAccount[i].state
Code Block
languagecpp
titlepurchase()
unsigned __int64 purchase()
{
  unsigned int v0; // ST00_4
  unsigned int candyInfo[2]; // [rsp+0h] [rbp-10h]
  unsigned __int64 v3; // [rsp+8h] [rbp-8h]

  v3 = __readfsqword(0x28u);
  if ( gStockCnt )
  {
    puts("Please enter the code number of the candy to be purchased.");
    candyInfo[0] = retNumber(3LL);
    if ( candyInfo[0] < gStockCnt )
    {
      puts("Please enter the number of the candy to purchase.");
      candyInfo[1] = retNumber(3LL);
      if ( gStock[candyInfo[0]]->candyNumber < candyInfo[1] )
      {
        if ( gStock[candyInfo[0]]->candyNumber < candyInfo[1] )
          puts("There is not enough stock.");
      }
      else if ( candyInfo[1] * gStock[candyInfo[0]]->candyPrice > gLoginAccount->bk )
      {
        printf(
          "You do not have enough money.(%ld)\n",
          candyInfo[1] * gStock[candyInfo[0]]->candyPrice,printf("%d) %s\n", gAccount[i].number, gAccount[i].fd->id);
  }
  puts("\nPlease enter the number of the account you want to delete");
  num = retNumber(2LL);
  if ( num && num <= 3 )
  {
    if ( gAccount[--num].state    *(_QWORD *)candyInfo);== 3 )
      }{
      else
      {gAccount[num].state = 0LL;
        gStock[candyInfo[0]]->candyNumber -= candyInfo[1]gAccount[num].fd->state = 0LL;
      printf("The account(%s) if ( !gStock[candyInfo[0]]->candyNumber )has been deleted.\n", gAccount[num].fd->id);
      memset(gAccount[num].fd, 0, {0x80uLL);
      free(gAccount[num].fd);
      gAccount[num].fd = printf(
struct IDPW *)((char *)gAccount[num].fd - 16);
    }
   "Thank else
 you for your purchase.(%ld)\n", {
      puts("You can not delete   candyInfo[1] * gStock[candyInfo[0]]->candyPrice,
            *(_QWORD *)candyInfothe account.");
    }
  }
  return  reSortStock(v0);
          setBoard();
        }
      }
    }
  }
  else
  {
    puts("We have not any candy.");
  }
  return __readfsqword(0x28u) ^ v3;
}

setBoard()

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 malloc() 함수를 이용해 1200 byte의 Heap 영역을 할당 받습니다.
    • 해당 함수는 해당 영역에 사용자로 부터 값을 입력 받아 저장합니다.
__readfsqword(0x28u) ^ v4;
}

printStock

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 전역 변수 gStock를 이용해 사탕 정보를 출력합니다.
Code Block
languagecpp
titleprintStock()
unsigned __int64 printStock()
{
  unsigned int i; // [rsp+4h] [rbp-Ch]
  unsigned __int64 v2; // [rsp+8h] [rbp-8h]

  v2 = __readfsqword(0x28u);
  if ( gStockCnt )
  {
    for ( i = 0; i < gStockCnt; ++i )
    {
      printf("\n=*= Candy %d =*=\n", i);
      printf("Name of candy        : %s\n", gStock[i]);
      printf("Number of candy      : %d\n", gStock[i]->candyNumber);
      printf("Price of candy       : %d\n", gStock[i]->candyPrice);
      printf("Description of candy : %s\n", gStock[i]->candyDescription);
    }
  }
  else
  {
    puts("We have not any candy.");
  }
  return _
Code Block
languagecpp
titlesetBoard()
unsigned __int64 setBoard()
{
  unsigned __int64 v0; // ST08_8

  v0 = __readfsqword(0x28u);
  puts("Please enter a comment for candy.");
  board = (__int64)malloc(1200uLL);
  UserInput(board, 1200LL);
  return __readfsqword(0x28u) ^ v0v2;
}

...

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 사용자로 부터 충전 할 금액의 번호는 입력 받습니다.
    • 해당 함수는 해당 금액을 "gLoginAccount→bk" 영역에 더합니다.
    구조체를 사용합니다.
Code Block
languagecpp
titlecharge()struct STOCK
struct STOCKunsigned __int64 charge()
{
  unsigned int chargeInfochar candyName[28]; // [rsp+0h] [rbp-10h]

    unsigned int __int64 v2; // [rsp+8h] [rbp-8h]
candyNumber;
  v2 = __readfsqword(0x28u);
  chargeInfo[0] = 0 unsigned int  candyPrice;
  puts("Please select the amount to charge.");
  puts("0) 1");
  puts("1) 10");
  puts("2) 100");
  puts("3) 1000");
  puts("4) 10000");
  puts("5) 100000");
  chargeInfo[1] = retNumber(2LL);
  switch ( chargeInfo[1] )
  {
    case 0u:
      chargeInfo[0] = 1;
      break;
    case 1u:
      chargeInfo[0] = 10;
      break;
    case 2u:
      chargeInfo[0] = 100;
   char *candyDescription;
};

purchase

  • 해당 함수는 다음과 같은 기능을 합니다.

    • 해당 함수는 전역 변수 gStockCnt의 값이 0일 경우 메시지 출력 해당 기능을 종료합니다.

    • 해당 함수는 전역 변수 gStockCnt의 값이 0이 아닐 경우 다음과 같은 기능을 합니다.

      • 해당 함수는 사용자로 부터 구매 할 캔디의 코드 번호(candyInfo[0]), 캔디의 수(candyInfo[1])를 입력받습니다.

        • 해당 함수는 구매 가능한 캔디 코드 번호, 캔디의 개수인지 확인합니다.

      • 해당 함수는 정상적인 구매가 진행 되며, 캔디의 재고가 없을 경우 아래 함수가 호출됩니다.

        • reSortStock()

        • setBoard()

Code Block
languagecpp
titlepurchase()
unsigned __int64 purchase()
{
  unsigned int v0; // ST00_4
  unsigned int candyInfo[2]; // [rsp+0h] [rbp-10h]
  unsigned __int64 v3; // [rsp+8h] [rbp-8h]

  v3 = __readfsqword(0x28u);
  if ( gStockCnt )
  {
    puts("Please enter the code number of the candy to be purchased.");
    candyInfo[0] = retNumber(3LL);
    if ( candyInfo[0] < gStockCnt )
    {
      puts("Please enter the number of the candy to purchase.");   break;
    case 3u:
      chargeInfocandyInfo[01] = 1000retNumber(3LL);
      if  break;( gStock[candyInfo[0]]->candyNumber < candyInfo[1] )
    case  4u:{
      chargeInfo  if ( gStock[candyInfo[0] = 10000;
      break]->candyNumber < candyInfo[1] )
          puts("There is not enough stock.");
    case  5u:}
      chargeInfoelse if ( candyInfo[1] * gStock[candyInfo[0]] = 100000;->candyPrice > gLoginAccount->bk )
      break;{
      default:  printf(
      break;
  }
  gLoginAccount->bk += chargeInfo[0];
  printf("%ld yen charged.\n", chargeInfo[0],"You do not have enough money.(%ld)\n",
          candyInfo[1] * gStock[candyInfo[0]]->candyPrice,
          *(_QWORD *)chargeInfocandyInfo);
      }
  return __readfsqword(0x28u) ^ v2;
}

.init_array

  • 다음과 같이 .init
Code Block
titlereadelf
lazenca0x0@ubuntu:~/Documents/CTF/SECCON2017$ gdb -q ./L*
Reading symbols from ./Lazenca.0x0...(no debugging symbols found)...done.
gdb-peda$ readelf 
.interp = 0x400238
.note.ABI-tag = 0x400254
.note.gnu.build-id = 0x400274
.gnu.hash = 0x400298
.dynsym = 0x4002b8
.dynstr = 0x4004c8
.gnu.version = 0x400580
.gnu.version_r = 0x4005b0
.rela.dyn = 0x4005e0
.rela.plt = 0x4005f8
.init = 0x4007d8
.plt = 0x400800
.plt.got = 0x400950
.text = 0x400960
.fini = 0x4029c4
.rodata = 0x4029d0
.eh_frame_hdr = 0x40376c
.eh_frame = 0x403888
.init_array = 0x603e08
.fini_array = 0x603e18
.jcr = 0x603e20
.dynamic = 0x603e28
.got = 0x603ff8
.got.plt = 0x604000
.data = 0x6040b8
.bss = 0x6040e0
gdb-peda$ x/2gx 0x603e08
0x603e08:	0x0000000000400a30	0x000000000040266b
gdb-peda$ x/5i 0x000000000040266b
   0x40266b:	push   rbp
   0x40266c:	mov    rbp,rsp
   0x40266f:	sub    rsp,0x10
   0x402673:	mov    rax,QWORD PTR fs:0x28
   0x40267c:	mov    QWORD PTR [rbp-0x8],rax
gdb-peda$ 

addAdmin

  • 해당 함수에서는 다음과 같은 Struct를 사용합니다.
Code Block
titleStruct IDPW, ACCOUNT
struct IDPW{
    long empty[2];
    char id[IDPWMAX];
    char pw[IDPWMAX];
    long state;
    char description[88];
};

struct ACCOUNT{
    long state;
    long number;
    struct IDPW *fd;
    long bk;
};
  • 해당 함수는 다음과 같은 기능을 합니다.

    • 전역 변수 gAccount[0]에 다음과 같은 값을 저장 합니다.

      • state = 1

      • number = 1

      • fd→id = "Admin"

      • fd→pw = "admin"

    • state 변수에 1을 저장하고 있으며, 해당 계정으로 "orderMenu", "Account" 기능을 이용 할 수 있습니다.

    else
      {
        gStock[candyInfo[0]]->candyNumber -= candyInfo[1];
        if ( !gStock[candyInfo[0]]->candyNumber )
        {
          printf(
            "Thank you for your purchase.(%ld)\n",
            candyInfo[1] * gStock[candyInfo[0]]->candyPrice,
            *(_QWORD *)candyInfo);
          reSortStock(v0);
          setBoard();
        }
      }
    }
  }
  else
  {
    puts("We have not any candy.");
  }
  return __readfsqword(0x28u) ^ v3;
}

setBoard()

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 malloc() 함수를 이용해 1200 byte의 Heap 영역을 할당 받습니다.
    • 해당 함수는 해당 영역에 사용자로 부터 값을 입력 받아 저장합니다.
Code Block
languagecpp
titlesetBoard()
unsigned __int64 setBoard
Code Block
languagecpp
titleaddAdmin()
unsigned __int64 addAdmin()
{
  unsigned __int64 v0; // ST08_8

  v0 = __readfsqword(0x28u);
   gAccount[0].state = 1LL;
  gAccount[0].number = 1LLputs("Please enter a comment for candy.");
  gAccount[0].fdboard = (struct IDPW *__int64)malloc(0x80uLL1200uLL);
  gAccount[0].bk = 880LLUserInput(board, 1200LL);
  return strncpy(gAccount[0].fd->id, "Admin", 8uLL);
  strncpy(gAccount[0].fd->pw, "admin", 8uLL);
  strncpy(gAccount[0].fd->description, "I'm Lazenca.0x0\nWebsite is \"https://www.lazenca.net/\"", 0x58uLL);
  return__readfsqword(0x28u) ^ v0;
}

charge

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 사용자로 부터 충전 할 금액의 번호는 입력 받습니다.
    • 해당 함수는 해당 금액을 "gLoginAccount→bk" 영역에 더합니다.
Code Block
languagecpp
titlecharge()
unsigned __int64 charge()
{
  unsigned int chargeInfo[2]; // [rsp+0h] [rbp-10h]
  unsigned __int64 v2; // [rsp+8h] [rbp-8h]

  v2 = __readfsqword(0x28u) ^ v0;
}

addAccount

  • 해당 함수는 다음과 같은 기능을 합니다.

    • 해당 함수는 전역 변수 gAccount[].state 의 값이 '0' 인 경우 다음과 같이 동작합니다.

      • 해당 함수는 malloc()을 사용하여 128 byte의 heap 영역을 할당받습니다.

        • 해당 함수는 해당 영역의 주소를 gAccount[i].fd에 저장합니다.

        • 해당 함수는 해당 영역에 ID, Password,등의 정보를 저장합니다.
Code Block
languagecpp
titleaddAccount(unsigned int a1)
unsigned __int64 __fastcall addAccount(unsigned int a1)
{
  unsigned int i; // [rsp+10h] [rbp-10h]
  signed int empty; // [rsp+14h] [rbp-Ch]
  unsigned __int64 v4; // [rsp+18h] [rbp-8h]

  v4 = __readfsqword(0x28u);
  empty;
  chargeInfo[0] = 0;
  puts("Please select the amount to charge.");
  puts("0) 1");
  puts("1) 10");
  puts("2) 100");
  puts("3) 1000");
  puts("4) 10000");
  puts("5) 100000");
  chargeInfo[1] = retNumber(2LL);
  switch ( chargeInfo[1] )
  {
    case 0u:
      chargeInfo[0] = 1;
  for ( i = 0break;
 i  <= 2 && empty; ++i )
  {
    if ( !gAccount[i].state )
    {
      empty = 0;case 1u:
      chargeInfo[0] = 10;
      break;
    case 2u:
      gAccountchargeInfo[i0].state = a1100;
       gAccount[i].number = i + 1;break;
    case 3u:
      gAccountchargeInfo[i0].fd = (struct IDPW *)malloc(128uLL)1000;
      gAccount[i].fd->state = 1LLbreak;
      puts("\nEnter your New ID.");case 4u:
      UserInput(gAccountchargeInfo[i].fd->id, 8LL)0] = 10000;
      break;
  puts("Enter your New Password.");case 5u:
      UserInput(gAccountchargeInfo[i].fd->pw, 8LL)0] = 100000;
       puts("Enter your profile.");break;
    default:
      UserInput(gAccount[i].fd->description, 88LL); break;
  }
  gLoginAccount->bk +=   gAccountchargeInfo[i].bk = 10000LL0];
  printf("%ld  }
  }
  if ( empty )
    puts("Could not add user."yen charged.\n", chargeInfo[0], *(_QWORD *)chargeInfo);
  return __readfsqword(0x28u) ^ v4v2;
}

delAccount

  • 해당 함수는 다음과 같은 기능을 합니다.
    • 해당 함수는 전역 변수 gAccount[]를 이용해 삭제 가능한 계정들을 출력합니다.
    • 해당 함수는 사용자로 부터 삭제 할 계정의 번호를 입력 받습니다.
    • 해당 함수는 사용자가 선택한 계정의 state 정보가 '3' 일 경우 삭제를 진행합니다.

      • 해당 함수는 해당 계정(gAccount[num])의 정보를 초기화 합니다.

        • state = 0

        • fd→state = 0

        • memset(gAccount[num].fd, 0, 0x80uLL);

      • 해당 함수는 해당 계정(gAccount[num])fd 영역(heap)을 해제 합니다.

    •  해당 함수는 gAccount[num].fd 영역에 "gAccount[num].fd - 16" 연산 한 값을 저장합니다.

      • 저장되는 값은 Free chunk의 Head 주소입니다.
      • 이것으로 인해 The House of Lore 취약성이 발생하게 됩니다.

.init_array

  • 다음과 같이 .init
Code Block
titlereadelf
lazenca0x0@ubuntu:~/Documents/CTF/SECCON2017$ gdb -q ./L*
Reading symbols from ./Lazenca.0x0...(no debugging symbols found)...done.
gdb-peda$ readelf 
.interp = 0x400238
.note.ABI-tag = 0x400254
.note.gnu.build-id = 0x400274
.gnu.hash = 0x400298
.dynsym = 0x4002b8
.dynstr = 0x4004c8
.gnu.version = 0x400580
.gnu.version_r = 0x4005b0
.rela.dyn = 0x4005e0
.rela.plt = 0x4005f8
.init = 0x4007d8
.plt = 0x400800
.plt.got = 0x400950
.text = 0x400960
.fini = 0x4029c4
.rodata = 0x4029d0
.eh_frame_hdr = 0x40376c
.eh_frame = 0x403888
.init_array = 0x603e08
.fini_array = 0x603e18
.jcr = 0x603e20
.dynamic = 0x603e28
.got = 0x603ff8
.got.plt = 0x604000
.data = 0x6040b8
.bss = 0x6040e0
gdb-peda$ x/2gx 0x603e08
0x603e08:	0x0000000000400a30	0x000000000040266b
gdb-peda$ x/5i 0x000000000040266b
   0x40266b:	push   rbp
   0x40266c:	mov    rbp,rsp
   0x40266f:	sub    rsp,0x10
   0x402673:	mov    rax,QWORD PTR fs:0x28
   0x40267c:	mov    QWORD PTR [rbp-0x8],rax
gdb-peda$ 

addAdmin

  • 해당 함수에서는 다음과 같은 Struct를 사용합니다.
Code Block
titleStruct IDPW, ACCOUNT
  • 해당 함수는 다음과 같은 기능을 합니다.

    • 전역 변수 gAccount[0]에 다음과 같은 값을 저장 합니다.

      • state = 1

      • number = 1

      • fd→id = "Admin"

      • fd→pw = "admin"

    • state 변수에 1을 저장하고 있으며, 해당 계정으로 "orderMenu", "Account" 기능을 이용 할 수 있습니다.

Code Block
languagecpp
titleaddAdmin()
unsigned __int64 addAdmin()
{
  unsigned __int64 v0; // ST08_8

  v0 = __readfsqword(0x28u);
  gAccount[0].state = 1LL;
  gAccount[0].number = 1LL;
  gAccount[0].fd = (struct IDPW *)malloc(0x80uLL);
  gAccount[0].bk = 880LL;
  strncpy(gAccount[0].fd->id, "Admin", 8uLL);
  strncpy(gAccount[0].fd->pw, "admin", 8uLL);
  strncpy(gAccount[0].fd->description, "I'm Lazenca.0x0\nWebsite is \"https://www.lazenca.net/\"", 0x58uLL);
  
Code Block
languagecpp
titledelAccount()
unsigned __int64 delAccount()
{
  unsigned int i; // [rsp+8h] [rbp-18h]
  unsigned int num; // [rsp+Ch] [rbp-14h] MAPDST
  unsigned __int64 v4; // [rsp+18h] [rbp-8h]

  v4 = __readfsqword(0x28u);
  puts("\nAccount list");
  for ( i = 0; i <= 2; ++i )
  {
    if ( gAccount[i].state )
      printf("%d) %s\n", gAccount[i].number, gAccount[i].fd->id);
  }
  puts("\nPlease enter the number of the account you want to delete");
  num = retNumber(2LL);
  if ( num && num <= 3 )
  {
    if ( gAccount[--num].state == 3 )
    {
      gAccount[num].state = 0LL;
      gAccount[num].fd->state = 0LL;
      printf("The account(%s) has been deleted.\n", gAccount[num].fd->id);
      memset(gAccount[num].fd, 0, 0x80uLL);
      free(gAccount[num].fd);
      gAccount[num].fd = (struct IDPW *)((char *)gAccount[num].fd - 16);
    }
    else
    {
      puts("You can not delete the account.");
    }
  }
  return __readfsqword(0x28u) ^ v4v0;
}

changePW

  • 해당 함수는 다음과 같은 기능을 합니다.

    • 해당 함수는 전역 변수 "gAccount[i].state"를 이용해 비밀번호 변경이 가능한 계정을 출력합니다.

    • 해당 함수는 사용자로 부터 비밀번호를 변경할 계정의 번호를 입력 받습니다.

    • 해당 함수는 해당 계정의 '.fd.state' 영역에 저장된 값이 '0'이 아닐 경우 비밀번호를 변경할 수 있습니다.

...