| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
Tags
- pentest
- androidhacking
- Linux
- Bandit
- bandit #밴딧 #웹해킹 #해킹 #화이트해커 #공부 #스터디 #IT #hacking #linux #openssl #nmap
- 리눅스
- androGoat
- time-based
- 밴딧
- 안드로이드 모의해킹
- 모의해킹
- sql injection
- error-based
- 쿠키변조
- msfconsole #heartbleed #247ctf #misc #webhacking
- 취약점 진단
Archives
- Today
- Total
d0r1
[picoctf] caas 본문

const express = require('express');
const app = express();
const { exec } = require('child_process');
app.use(express.static('public'));
app.get('/cowsay/:message', (req, res) => {
exec(`/usr/games/cowsay ${req.params.message}`, {timeout: 5000}, (error, stdout) => {
if (error) return res.status(500).end();
res.type('txt').send(stdout).end();
});
});
app.listen(3000, () => {
console.log('listening');
});

message 에 값을 넣어서 전송하면

귀여운 소가 메세지를 뱉어줌
express를 잘 몰라서 공부를 좀 하고 풀었음
| express의 exec child_process로 실행 한다고 보면 될 듯. 즉, exec(`/usr/games/cowsay ${req.params.message} /usr/games/coway/{under}를 수행,,? 한다고 볼 수 있음 (아마도, 현재 코드내에 위의 소 모양이 없으므로, message가 어떠한 프로그램의 파라미터로 대입되어, exec unknown {parm} 이렇게 들어갈 것으로 예상 됨) 여기서 :(콜론)이 어떤 역할을 하는지 궁금했는데 app.get('/cowsay/:message', (req, res) => { exec(`/usr/games/cowsay ${req.params.message}`, {timeout: 5000}, (error, stdout) => { : 하위에 입력된 message가 변수가 되고, ${}를 통해 해당 변수를 호출하는 개념 |
즉, 위를 기반으로하면, 해당 변수에 injection할 값을 대입하면, Command injection이 발생한다는 것을 파악
아무런 필터링이 진행되지 않기 때문에 ;(세미콜론)으로 terminating이 가능하다고 예측
message에 test; ls 를 수행

예상대로 ls가 수행됨을 확인할 수 있음
'이것저것' 카테고리의 다른 글
| php db connector output (0) | 2024.11.18 |
|---|---|
| mysql 3306 ufw allow -> http3306/tcp closed 해결법 (0) | 2024.11.18 |
| [picoCTF] more-SQLi (0) | 2024.09.05 |
| [picoCTF] SOAP (0) | 2024.09.05 |
| [root-me] HTTP-IP restriction bypass (0) | 2024.08.16 |