본문 바로가기
Security/OverTheWire

Bandit Level 22 → Level 23

by curious week 2025. 12. 1.

문제

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.

## 문제 요구사항
. /etc/cron.d/ 에서 설정을 확인하고 어떤 명령이 실행되는지 확인

## 내가 사용한 명령어
ssh bandit22@bandit.labs.overthewire.org -p 2220
cd /etc/cron.d
ls -l
cat cronjob_bandit23
cat /usr/bin/cronjob_bandit23.sh
echo I am user bandit23 | md5sum | cut -d ' ' -f 1
cat /tmp/8ca319486bfbbc3663ea0fbe81326349

## 왜 이 명령어를 골랐는가
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
자신의 이름ㅇ르 password를 읽어서 /tmp/$mytarget에 저장하므로
echo I am user bandit23 | md5sum | cut -d ' ' -f 1 
→ 문자열 전체의 md5 해시값을 출력한다.