OvertheWire:bandit:Level23

CTF수상까지...!!·2023년 11월 3일
0

OvertheWire:문제풀이

목록 보기
24/26

level22->level23

Level23


A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in /etc/cron.d/ for the configuration and see what command is being executed.

NOTE: Looking at shell scripts written by other people is a very useful skill. The script for this level is intentionally made easy to read. If you are having problems understanding what it does, try executing it to see the debug information it prints.

문제를 보면, 우선 이전 문제와 똑같다.

여기까지도 똑같다.

그런데, 여기서 bash 스크립트가 나타난다.

이 스크립트를 해석해보면,

  • whoami 명령을 사용하여 현재 사용자의 이름(bandit22)을 myname에 저장한다.
  • echo 명령을 사용하여 I am user $myname 문자열을 하고, 생성한 문자열을 MD5 해시값으로 변환하고, 그 해시값을 mytarget에 저장.
  • "Copying passwordfile /etc/bandit_pass/mynameto/tmp/myname to /tmp/mytarget" 메시지를 출력. 즉, mytarget에 저장한 해시값을 출력.
  • /etc/bandit_pass/myname경로에있는비밀번호파일의내용을읽어와서,그내용을/tmp/myname 경로에 있는 비밀번호 파일의 내용을 읽어와서, 그 내용을 /tmp/mytarget 파일에 복사.

그러나 우리는 bandit23의 비밀번호를 알아야 하므로,

echo I am bandit23 | md5sum | cut -d ‘ ‘ -f 1

명령을 실행하면 다음과 같이 해당 문자열에 대한 해시값이 출력된다.
업로드중..

위와 같이 해당 해시값이 /tmp/ 에 저장되므로 해당 파일을 읽으면 bandit23의 비밀번호를 알 수 있다.

비밀번호 : QYw0Y2aiA672PsMmh9puTQuhoz8SyR2G

profile
보안 공부...내 공부...

0개의 댓글

Powered by GraphCDN, the GraphQL CDN