2020 RACTF - C0llide?
2020. 6. 10. 03:09ㆍWeb
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
31
32
33
34
35
36
37
38
39
40
41
|
const bodyParser = require("body-parser")
const express = require("express")
const fs = require("fs")
const customhash = require("./customhash")
const app = express()
app.use(bodyParser.json())
const port = 3000
const flag = "flag"
const secret_key = "Y0ure_g01nG_t0_h4v3_t0_go_1nto_h4rdc0r3_h4ck1ng_m0d3"
app.get('/', (req, res) => {
console.log("[-] Source view")
res.type("text")
return fs.readFile("index.js", (err,data) => res.send(data.toString().replace(flag, "flag")))
})
app.post('/getflag', (req, res) => {
console.log("[-] Getflag post")
if (!req.body) {return res.send("400")}
let one = req.body.one
let two = req.body.two
console.log(req.body)
if (!one || !two) {
return res.send("400")
}
if ((one.length !== two.length) || (one === two)) {
return res.send("Strings are either too different or not different enough")
}
one = customhash.hash(secret_key + one)
two = customhash.hash(secret_key + two)
if (one == two) {
console.log("[*] Flag get!")
return res.send(flag)
} else {
return res.send(`${one} did not match ${two}!`)
}
})
app.listen(port, () => console.log(`Listening on port ${port}`))
|
cs |
위 문제는 js 조건문에 대해 파악하면 쉽게 풀 수 있었다.
20분동안 고민하다가 다음과 같은 페이로드를 짜 보았다.
1
2
3
4
|
{
"one" : [1,1,1],
"two" : [1,1,"1"]
}
|
cs |
!one || !two 에서 false
두 배열의 길이가 같으니 false || 데이터타입이 다르니 false
로 두번의 if를 넘긴 뒤
== ( =2개짜리 ) 비교문으로 one과 two를 검사하면 같게 나온다.
이것을 PostMan으로 요청 해 보니
다음과 같이 FLAG를 뽑아낼 수 있었다.
'Web' 카테고리의 다른 글
Path traversal tips (0) | 2020.10.29 |
---|---|
Dreamhack.io/ 해킹입문, xss (1) | 2020.08.05 |
LOS - iron golem (0) | 2020.05.14 |
HackCTF - Wise Saying (0) | 2020.05.10 |
LOS - xavis (0) | 2020.05.09 |