Beebox[OS Command Injection - Blind]
목차
❓ Command Injection : OS명령어를 입력하여 내부정보 유출 및 악의적인 행위를 수행(매우심각❗)
❓ Blind : 눈 감고 공격..(장님공격)한다는 말 (True, False만 가지고 공격하는거였는데..)
1. LOW
(1) 입력
![Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (1) 입력 Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (1) 입력](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
해당 입력창에 IP을 입력하면
ping을 실행해주네요
![Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (1) 입력 Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (1) 입력](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
OS Command Injection과 동일하게 실행시켜보겠습니다.
nc -l -p 12345
▶ 내 PC에서 위와 같이 입력해주세요
▶ 넷캣의 -l은 리스닝모드이고, -p 다음에는 오픈할 포트를 적어주세요
![Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (1) 입력 Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (1) 입력](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
보통 칼리를 많이 쓰지만 저는 우분투를 사용했어요
서버에서는 내 PC의 IP를 입력해서 접속하려고 합니다.
(2) 공격
![Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (2) 공격 Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (2) 공격](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
-e /bin/bash 옵션은 shell을 이용해서 상호작용할 수 있도록 하기위해서지요
-e는 exec의 약자로 뒤에 넣은 것을 실행합니다!!
![Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (2) 공격 Beebox[OS Command Injection - Blind] - 1. LOW - undefined - (2) 공격](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
서버에서 내 PC로 연결을 한 후 내 PC에서 명령어를 실행한 결과에요
명령어가 정상적으로 실행되고 결과도 얻을 수 있네요!!
2. Medium & High
(1) 소스코드 확인
Low와 동일하게 입력해보았지만 실행이 되지 않네요
![Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인 Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
Medium은 commandi_check_1을 호출하고
High는 commandi_check_2를 호출하네요
![Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인 Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
Medium은 &와 ;사용을 막고있네요
&와 ; 대신 |를 사용합니다!!
위와 같이 사용하면 똑같이 연결이 되네요
💡 명령어 관련 상식 알아두기!!
❓ 명령어는 정상적으로 실행됐을 때 0을 반환하고, 실패 시 0이 아닌 정수를 반환해요!
🎯 ; = 앞 명령어 실패와 상관 없이 다음 명령어가 실행돼요!
🎯 || = 앞 명령어가 실패했을 때 다음 명령어가 실행돼요!(실패 예시: 없는 디렉터리로 이동한다던지 등)
🎯 | = 앞 명령어의 결과를 뒤 명령어에게 넘겨주어요!! (보통 more, awk, grep 등과 같이 사용)
🎯 && = 앞 명령어가 성공했을 때 다음 명령어가 실행돼요!
🎯 & = 앞 명령어를 백그라운드로 실행하고 다음 명령어를 실행!
예시) 이 부분은 이해안갈수도 있을 것 같아서.. ㅎ
![Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인 Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
![Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인 Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - (1) 소스코드 확인](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
sleep 5가 실행되는 동안 PID확인!!
(2) 공격
![Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined -](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
|를 사용하니 정상적으로 nc가 실행돼요!
앞 명령어의 결과를 받은 것과 상관없이 뒤 명령어는 실행되니까요?
하하
![Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined - Beebox[OS Command Injection - Blind] - 2. Medium & High - undefined -](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
(2) 대응방안
시스템명령어를 외부에서 사용못하도록 하는 것이 가장 좋지만
부득이하게 사용해야한다면
High에 나온 것과 같이
escapeshellcmd함수를 사용하세요!
& ; | 특수문자를 사용할 수 없도록 합니다!
'Wargame > BeeBox' 카테고리의 다른 글
Beebox[Server-Side Includes (SSI) Injection] (0) | 2021.03.30 |
---|---|
Beebox[PHP Code Injection] (0) | 2021.03.30 |
Beebox[OS Command Injection] (0) | 2021.03.29 |
Beebox[iFrame Injection] (0) | 2021.03.29 |
Beebox[HTML Injection - Stored (Blog)] (0) | 2021.03.29 |
댓글