Lab: Blind OS command injection with output redirection

Lab: Blind OS command injection with output redirection

https://portswigger.net/web-security/os-command-injection/lab-blind-output-redirection

 

Lab: Blind OS command injection with output redirection | Web Security Academy

This lab contains a blind OS command injection vulnerability in the feedback function. The application executes a shell command containing the user-supplied ...

portswigger.net


리다이렉션을 이용한Blind OS Command Injection 취약점

 

  • 피드백 기능에 취약점 있음
  • 사용자가 제공한 세부정보가 포함된 쉘 명령 실행, 응답 반환 X
  • 출력 리다이렉션을 사용하여 명령의 출력을 캡쳐할 수 있음
  • 쓰기 가능한 폴더 위치 /var/www/images/
  • 삽입된 명령의 출력을 쓰기 가능 폴더의 파일로 리다이렉션 후 이미지 로드 URL을 사용하여 파일의 콘텐츠를 검색
  • whoami 명령을 실행하고 출력 확인

 

(1) 피드백 페이지로 이동합니다. 

 

(2) Submit feedback을 클릭하여 전송되는 패킷을 확인합니다. 

=> 전송 값 csrf, name, email, subject, message

 

(3) Blind Command Injection이 가능한지 확인합니다.

=> 전송 값 중 email에서 blind command injection이 가능함을 확인

 

(4) 이미지 요청을 확인합니다. 

=>  이미지 저장소의 일반적인 위치는 /var/www/images/

 

(5) 삽입된 명령의 출력을 쓰기 가능 폴더의 파일로 리다이렉션합니다. 

=> "명령어 > 저장위치" 형식

=> & whoami > /var/www/images/whoami.txt # => +%26+whoami+>+/var/www/images/whoami.txt+%23

=> &는 %26, #은 %23으로 변환 후 띄어쓰기는 +로 연결

 

(6) 파일이 생성되었는지 확인합니다. (결과 확인)

=> 이미지 요청값 중 하나를 Repeater로 보내고 filename을 이전에 만든 파일명으로 변경