๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
hacking/pwnable

[Dream hack] Welcome Hackers๐Ÿ‘จ‍๐Ÿ’ป

by ilp 2025. 3. 2.
๋ฐ˜์‘ํ˜•

๐Ÿ‘‰์ž ์‹œ ์•„๋ž˜์˜ ๋‘ ์ฝ”๋“œ๋ฅผ ์ฝ๊ณ , "Welcome Hackers :)"๊ฐ€ ์ถœ๋ ฅ๋˜๋Š” ์ž…๋ ฅ๊ฐ’์„ ์ฐพ์•„๋ณด์„ธ์š”.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int sz = 0x30; // sz์— 16์ง„์ˆ˜ 0x30์„ ํ• ๋‹นํ•œ๋‹ค. ์‹ญ์ง„์ˆ˜๋ก  48์ด๋‹ค.
  char *buf = (char *)malloc(sizeof(char) * sz);
  // sz ํฌ๊ธฐ์˜ ๋ฉ”๋ชจ๋ฆฌ๋ฅผ ๋™์ ํ• ๋‹น ํ•œ๋‹ค.

  puts("Hello World!"); // hello world ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. puts๋Š” ์ถœ๋ ฅํ•˜๊ณ  ์ž๋™ ์ค„๋ฐ”๊ฟˆ ํ•œ๋‹ค.
  printf("Education + Hack = ?\n");
  fgets(buf, sz, stdin); //๋ฌธ์ž์—ด์„ ์ฝ์–ด buf์— ์ €์žฅํ•œ๋‹ค. ์ตœ๋Œ€ sz-1 ๊ฐœ ๋ฌธ์ž๋ฅผ ์ฝ๋Š”๋‹ค.

  if (!strncmp(buf, "DreamHack", 9)) //buf์™€ dream... ๋ฌธ์ž์—ด์˜ ์ฒ˜์Œ 9์ž๋ฆฌ ๋น„๊ต
    printf("Welcome Hackers :)\n");
  else
    printf("No No :/\n");

  return 0;
}

#!/usr/bin/python3

quiz = [116, 66, 85, 81, 93, 120, 81, 83, 91]

for i in range(len(quiz)):
    quiz[i] ^= 0x30 # xor ์—ฐ์‚ฐ ์ˆ˜ํ–‰

quiz = ''.join([chr(_) for _ in quiz]) #์ˆซ์ž๋ฅผ ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•˜๊ณ  ์—ฐ๊ฒฐํ•ด์„œ ๋ฌธ์ž์—ด๋กœ ๋งŒ๋“ ๋‹ค.
answer = input() #๋ฌธ์ž์—ด ์ž…๋ ฅ ๋ฐ›์Œ

if answer == quiz:
    print("Welcome Hackers :)")
else:
    print("No No :/")

๋

๋ฐ˜์‘ํ˜•