Narnia 설정
1단계
Narnia(http://overthewire.org/wargames/narnia/)는 SSH로 해당 서버에 연결하도록 구성되어 있고, 모든 문제는 /narnia/ 아래에 있다. 처음 세 문제를 풀어 보자. 칼리의 터미널이나 윈도 사용자라면 Putty(http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)에서 다음 명령을 실행한다.
# ssh narnia0@narnia.labs.overthewire.org
narnia0@narnia.labs.overthewire.org's password: narnia0
$ cd /narnia/
각 과제는 C 코드와 바이너리 실행 파일을 모두 보여 주는 방식으로 배치했다. 예를 들어, 0번 과제에는 narnia0과 narnia0.c 파일이 해당된다. C 코드를 살펴보자.
$ cat narnia0.c
narnia0@melinda:/narnia$ cat narnia0.c /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include <stdio.h> #include <stdlib.h> int main(){ long val = 0x41414141; char buf[20]; printf("Correct val's value from 0x41414141 -> 0xdeadbeef!\n"); printf("Here is your chance: "); scanf("%24s", &buf); printf("buf: %s\n", buf); printf("val: 0x%08x\n", val); if(val == 0xdeadbeef) system("/bin/sh"); else{ printf("WAY OFF!!!!\n"); exit(1); } return 0; }
▲ 그림 1-5 Narnia 0 - 코드