Level Goal
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.
Commands you may need to solve this level
cron, crontab, crontab(5) (use “man 5 crontab” to access this)
전 레벨과 마찬가지로 /etc/cron.d
디렉토리에 있는 작업 스케줄러 설정 파일을 확인해야 한다.
cd /etc/cron.d/
cat ./cronjob_bandit23
cat /usr/bin/cronjob_bandit23.sh
/etc/cron.d/
디렉토리로 가서 다음 레벨과 관련이 있을 것 같은 cronjob_bandit23
파일 내용을 확인하여 마찬가지로 쉘 스크립트 코드를 확인해 본다. 아래는 그 코드이다.
#!/bin/bash
myname=$(whoami)
mytarget=$(echo I am user $myname | md5sum | cut -d ' ' -f 1)
echo "Copying passwordfile /etc/bandit_pass/$myname to /tmp/$mytarget"
cat /etc/bandit_pass/$myname > /tmp/$mytarget
$myname
변수에 현재 로그인한 계정이름이 들어가고 그 계정의 패스워드를 /tmp/$mytarget
이라는 파일에 저장하는 프로그램이다. 결국 이 $mytarget
이라는 변수에 들어가는 값만 알면 어떤 파일에 저장되는지 알 수 있다.
echo I am user bandit23 | md5sum | cut -d ' ' -f 1
cat /tmp/8ca319486bfbbc3663ea0fbe81326349
bandit23
계정의 패스워드를 알아야하므로, $mytarget
변수에 값을 저장하는 부분에서 $myname
을 bandit23
으로 변경하여 실행했다. 출력된 값을 이름으로 하는 파일의 내용을 출력하면 다음 레벨로 가는 패스워드를 얻을 수 있다.