티스토리 뷰

728x90
반응형


Hackthebox 에서 포렌식 챌린지 중 Illumination 문제 풀이 입니다.

git 사용해본 사람이라면 한번쯤은 주의해서 사용해야하는 점을 인지시켜주는 문제였던 것 같습니다. 난이도는 매우 쉬운 편에 속하는 것 같습니다.

 

 

 

압축을 풀면 위와 같이 파일들이 존재합니다.

bot.js 파일 내용은 아래와 같습니다.

 

//Discord.JS
const Discord = require("discord.js");
const client = new Discord.Client();
const fs = require("fs");
var config = JSON.parse(fs.readFileSync("./config.json"));

(중략)

client.login(Buffer.from(config.token, 'base64').toString('ascii')) //Login with secret token

 

config.json 파일 내용은 아래와 같습니다.

 

{

	"token": "Replace me with token when in use! Security Risk!",
	"prefix": "~",
	"lightNum": "1337",
	"username": "UmVkIEhlcnJpbmcsIHJlYWQgdGhlIEpTIGNhcmVmdWxseQ==",
	"host": "127.0.0.1"

}

 

username을 base64 디코딩을 해보았지만 별 소득은 없었습니다.

Red Herring, read the JS carefully

 

bot.js 에서도 언급했던 것처럼 login 에 쓰이는 값은 config.token 인 걸 알 수 있습니다. 하지만 token 값이 비어 있기에 찾던 중 .git 폴더가 있다는 것을 알게 되었고, 개발자가 최근에 commit 내용을 업데이트해서 token 값을 제거한 것을 알 수 있었습니다.

 

// 명령어 : git log -p -2
commit 47241a47f62ada864ec74bd6dedc4d33f4374699
Author: SherlockSec <dan@lights.htb>
Date:   Fri May 31 12:00:54 2019 +0100

    Thanks to contributors, I removed the unique token as it was a security risk. Thanks for reporting responsibly!

diff --git a/config.json b/config.json
index 316dc21..6735aa6 100644
--- a/config.json
+++ b/config.json
@@ -1,6 +1,6 @@
 {

-       "token": "SFRCe3YzcnNpMG5fYzBudHIwbF9hbV9JX3JpZ2h0P30=",
+       "token": "Replace me with token when in use! Security Risk!",
        "prefix": "~",
        "lightNum": "1337",
        "username": "UmVkIEhlcnJpbmcsIHJlYWQgdGhlIEpTIGNhcmVmdWxseQ==",
 }

 

위 토큰 값을 다시 base64 디코딩했을 때 플래그 값을 획득할 수 있었습니다.

 

atob("SFRCe3YzcnNpMG5fYzBudHIwbF9hbV9JX3JpZ2h0P30=")
"HTB{플래그값가리개}"
728x90
반응형
댓글