
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.
프로그램은 시간 기반 작업 스케줄러인 cron으로 실행되어 자동으로 일정한 간격에 동작한다. /etc/cron.d/에서 어떤 명령이 실행되고 있는지 설정을 확인해라.
노트: 다른 사람이 작성한 쉘 스크립트를 볼 수 있는 능력은 아주 유용하다. 이 레벨의 스크립트는 읽기 쉽게 작성되었다. 내용을 이해하는 것이 어렵다면 이 스크립트를 실행해 출력되는 디버그 정보를 확인해라.
cron, crontab, crontab(5)(use “man 5 crontab” to access this)
bandit22@bandit:~$ cat /etc/cron.d/cronjob_bandit23
@reboot bandit23 /usr/bin/cronjob_bandit23.sh &> /dev/null
* * * * * bandit23 /usr/bin/cronjob_bandit23.sh &> /dev/null
bandit22@bandit:~$ cat /usr/bin/cronjob_bandit23.sh
#!/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
cronjob_bandit23.sh 파일을 1분 마다 실행한다. 쉘 스크립트의 내용을 확인해보면 bash로 실행되고, whoami 명령의 결과를 myname 변수에 할당한다.
그리고 "i am user $(whoami)"의 md5 해시값을 공백 기준으로 잘라 mytarget 변수에 할당한다.
결과적으로 이 스크립트는 /etc/bandit_pass/$myname의 내용을 /tmp/$mytarget에 저장하는 동작을 명시하고 있다.
그러면 bandit23 계정으로 접속했을 때 해당 크론잡이 동작했을 때 bandit23의 패스워드가 있는 임시 파일 이름을 알 수 있다.
bandit22@bandit:~$ cat /tmp/$(echo I am user bandit23 | md5sum | cut -d ' ' -f 1)