๊ธ€ ์ž‘์„ฑ์ž: heogi

๋ฌธ์ œ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์œผ๋ฉด Summer_Fan.apk ํŒŒ์ผ์ด ์กด์žฌํ•œ๋‹ค.

 

ํ•ด๋‹น ์•ฑ์„ ์„ค์น˜ํ•˜๊ณ  ์‹คํ–‰ํ•ด๋ณด๋ฉด ์•„๋ž˜ ์ฒ˜๋Ÿผ ์„ ํ’๊ธฐ๋ฅผ ๋Œ๋ฆฌ๊ณ  ํ”Œ๋ž˜๊ทธ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ์•ฑ์ด ์‹คํ–‰๋œ๋‹ค.

adb install Summer_Fan.apk

 

 

GET FLAG! ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๊ฒŒ ๋˜๋ฉด ์•„๋ž˜ ํ™”๋ฉด์ฒ˜๋Ÿผ ๋‚˜์˜จ๋‹ค.

 

 

jadx๋ฅผ ํ†ตํ•ด apk ํŒŒ์ผ์˜ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด MainActivity์— ๋‹ค์–‘ํ•œ ํ•จ์ˆ˜๋“ค์ด ์กด์žฌํ•œ๋‹ค.

๊ทธ ์ค‘ Start ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์‹คํ–‰๋˜๋Š” startTimer(), Get Flag ๋ฒ„ํŠผ์„ ๋ˆ„๋ ค๋ฉด ์‹คํ–‰๋˜๋Š” checkTime(),

Flag๋ฅผ ์ƒ์„ฑํ•˜๋Š” generateFlag() ํ•จ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

private final void checkTime(Intent intent) {
    Toast.makeText(this, (((int) intent.getDoubleExtra(TimerService.TIME_EXTRA, 0.0d)) % 86400) / 3600 >= 31337 ? generateFlag() : "ํ”Œ๋ž˜๊ทธ๋ฅผ ์ฃผ๊ธฐ์—” ์•„์ง ๋„ˆ๋ฌด ๋”์šด๊ฑธ...", 0).show();
}

private final String generateFlag() {
    ArrayList arrayList = new ArrayList();
    int size = MainActivityKt.getFLAG().size();
    for (int i = 0; i < size; i++) {
        arrayList.add(Character.valueOf((char) ((MainActivityKt.getFLAG().get(i).intValue() ^ StringsKt.first(MainActivityKt.getKEY().get(i % MainActivityKt.getKEY().size()))) - gen(i))));
    }
    return CollectionsKt.joinToString$default(arrayList, "", null, null, 0, null, null, 62, null);
}

private final int gen(int i) {
    int size = MainActivityKt.getKEY().size();
    return (((int) Math.pow(i, 3.0d)) % 256) ^ StringsKt.first(MainActivityKt.getKEY().get(size - ((i % size) + 1)));
}

 

checkTime ํ•จ์ˆ˜๋‚ด์— ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋ฉด generateFlag ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•ด์ค€๋‹ค.

์ด์— Frida๋ฅผ ํ†ตํ•ด startTime ํ•จ์ˆ˜๋ฅผ ํ›„ํ‚นํ•˜์—ฌ generateFlag ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ Flag๋ฅผ ์ถœ๋ ฅํ–ˆ๋‹ค.

 

frida -D emulator-5554 -f com.example.summer --no-pause -l generateFlagHook.js
# generateFlagHook.js

function generateFlagHook(){
	Java.perform(function(){
		var RootingDecteor = Java.use("com.example.summer.MainActivity");
		RootingDecteor.startTimer.implementation = function(){
			Java.choose("com.example.summer.MainActivity",{
				"onMatch":function(generateFlag){
					console.log(generateFlag.generateFlag());
				},
				"onComplete":function() {}
			})
		};
	})
}

generateFlagHook()

 

'๐Ÿ›ก๏ธCTF > DreamHack' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

rev-basic-3  (0) 2023.09.19
[BOB CTF 8th] - FileStroage  (0) 2022.09.13
Apache htaccess  (0) 2022.07.28
read_flag  (0) 2022.01.23
crawling  (0) 2022.01.23