[pwnable.xyz] executioner trick(?)
Wargame/pwnable.xyz

[pwnable.xyz] executioner trick(?)

๐Ÿงก executioner ๋ฌธ์ œ ์†Œ๊ฐœ

int __cdecl main(int argc, const char **argv, const char **envp)
{
  _QWORD *v4; // rax
  int i; // [rsp+0h] [rbp-20h]
  int fd; // [rsp+4h] [rbp-1Ch]

  setup();
  solve_pow();
  puts("Shellcode executioner");
  fd = open("/dev/urandom", 0);
  if ( fd != -1 )
  {
    read(fd, key, 0x7FuLL);
    close(fd);
    printf("Input: ", key);
    read(0, inpt, 0x7FuLL);
    for ( i = 0; i < strlen(inpt); ++i )
      inpt[i] ^= key[i];
    v4 = mmap(0LL, 0x1000uLL, 7, 34, 0, 0LL);
    *v4 = *(_QWORD *)inpt;
    v4[1] = qword_202288;
    v4[2] = qword_202290;
    v4[3] = qword_202298;
    v4[4] = qword_2022A0;
    v4[5] = qword_2022A8;
    v4[6] = qword_2022B0;
    v4[7] = qword_2022B8;
    v4[8] = qword_2022C0;
    v4[9] = qword_2022C8;
    v4[10] = qword_2022D0;
    v4[11] = qword_2022D8;
    v4[12] = qword_2022E0;
    v4[13] = qword_2022E8;
    v4[14] = qword_2022F0;
    v4[15] = qword_2022F8;
    JUMPOUT(__CS__, v4);
  }
  puts("error");
  return 1;
}

๋‚ด๊ฐ€ ์ž…๋ ฅํ•œ ์‰˜์ฝ”๋“œ์˜ ๊ธธ์ด๋งŒํผ XOR ์—ฐ์‚ฐ์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ๋ฉ”๋ชจ๋ฆฌ๋ฅผ mapping ํ•˜์—ฌ ๊ทธ ์žฅ์†Œ๋กœ jump ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

 

๐Ÿงก executioner trick

์‚ฌ์‹ค ํŠธ๋ฆญ์ด๋ผ๊ณ  ํ•  ๊ฒƒ๋„ ์—†์ด strlen์€ '\x00' byte๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ํŒ๋‹จํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์•ž์— ๋„๋ฐ”์ดํŠธ ๋ช‡ ๊ฐœ๋ฅผ ๋„ฃ์–ด์ฃผ๊ณ  ์‰˜์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ๋‚ด๊ฐ€ ์ ์œผ๋ ค๋˜ ๊ฒƒ์€ ์ด๊ฒŒ ์•„๋‹ˆ๋ผ ๋‚ด๊ฐ€ ์ด ๋ฌธ์ œ๋ฅผ ํ’€๊ณ  ๋‹ค๋ฅธ ๋ถ„๋“ค์˜ ํ’€์ด๋ฅผ ๊ตฌ๊ฒฝํ•ด๋ดค๋Š”๋ฐ ๋‚ด๊ฐ€ ๋น„๊ต์ ? ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•œ ๊ฒƒ ๊ฐ™์•„์„œ ์ ์–ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. ๋ฌผ๋ก  64bit /bin/sh code๋ฅผ ์‚ฌ์šฉํ•˜์‹  ๋ถ„๋„ ๊ณ„์…จ๋‹ค.

๋‚˜๋Š” main์—์„œ mapping๋œ memory๋กœ jump ํ• ๋•Œ r12๊ฐ€ _start๋ฅผ ๊ฐ€๋ฆฌํ‚ค๊ณ  ์žˆ๋‹ค๋Š” ์ ์„ ์ด์šฉํ•ด add instruction์„ ์ด์šฉํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์˜€๋‹ค.

'Wargame > pwnable.xyz' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[pwnable.xyz] fishing - thread  (0) 2021.07.12
[pwnable.xyz] Heap - House of Force ๋ณต์Šต (note v3)  (2) 2021.07.09
[pwnable.xyz] executioner v2 ์‚ฝ์งˆ  (2) 2021.07.03
[pwnable.xyz] Free spirit trick ์†Œ๊ฐœ  (2) 2021.06.26
[pwnable.xyz] ๋ชฉํ‘œ  (0) 2021.06.25