1๏ธโฃ FridaLab.apk WriteUp
๐FridaLab?
- https://rossmarks.uk/blog/fridalab/ ์์ ์ ๊ณต๋๋ Frida๋ฅผ ์ตํ๊ธฐ ์ํ Challenge APK
๐FridaLab APP
- FridaLab app์ Nox ํ๊ฒฝ์์ ์คํํด ๋ณด๋ฉด 8๊ฐ์ง์ ๋ฌธ์ ๊ฐ ๋์ค๋ ๊ฒ์ ์ ์ ์๋ค.
- 8๊ฐ์ง ๋ฌธ์ ์ ๋ํ์ฌ ์กฐ๊ฑด์ด ๋ง์กฑํ๋ฉด check๋ฅผ ๋๋ ์๋ ์์์ด Green์ผ๋ก ๋ฐ๋๋ค. (์กฐ๊ฑด์ด ๋ง์กฑํ์ง ๋ชปํ๋ ๊ฒฝ์ฐ๋ ๋นจ๊ฐ์!)
๐๋ฌธ์ ํ์ด (1๋ฒ)
- ๋ฌธ์ : Change class challenge_01’s variable ‘chall01’ to : 1
> ๋ฌธ์ ๋ Challenge_01 ํด๋์ค์ ๋ณ์์ธ chall01์ ๊ฐ์ 1๋ก ๋ฐ๊พธ๋ผ๋ ๊ฒ์ด๋ค.
> ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด Jadx๋ฅผ ํตํด์ FridaLab์ ๋ถ์ํด๋ณด์
โ > uk.rossmarks.fridalab ํจํค์ง์์ challenge_01 ํด๋์ค๋ฅผ ํ์ธํ ์ ์๋ค. โ > ์ด ํด๋์ค์ ๋ณ์์ธ ๊ฐ์ 1๋ก ๋ฐ๊ฟ์ฃผ๋ฉด ๋๋ค.
setImmediate(function(){ // ์ฐ๊ฒฐ๋์ด ์๋ ๋ถ๋ถ์ ๋ฐ๋ก ๋ค์์ ์คํ
Java.perform(function(){ // ์ค๋ ๋๊ฐ ์ฐ๊ฒฐ๋์ด ์์ผ๋ฉด ์๋์ ์ฝ๋๋ฅผ ์คํ
//#1
var test = Java.use("uk.rossmarks.fridalab.challenge_01");
test.chall01.value = 1;
console.log("[*] chall01 value is ", test.chall01.value);
})
})
> ์คํ ๊ฒฐ๊ณผ
ํ๋ฆฌ๋ค ์คํ ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ ์คํฌ๋ฆฝ์ค ์คํ : Frida -U -l fridalab.js uk.rossmakrs.fridalab
์คํ๊ฒฐ๊ณผ 1๋ฒ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
๐๋ฌธ์ ํ์ด (2๋ฒ)
- ๋ฌธ์ : Run chall02()
> ๋ฌธ์ ๋ฅผ ๋ณด๋ฉด chall02() ํจ์๋ฅผ ์คํ ํ๋ผ๋ ๊ฒ์ด๋ค.
> MainActivity๋ฅผ ํ์ธํด๋ณด๋ฉด, chall02 ํจ์๋ ์ ์๋์ด ์์ง๋ง ์ฌ์ฉ์ ํ์ง ์๋๋ค. ๋ฐ๋ผ์ MainActivity๋ฅผ ๋ถ๋ฌ์
chall02ํจ์๋ฅผ ์คํํด ์ฃผ๋ฉด ๋ ๊ฒ์ด๋ค.
//#2
//static method์ผ ๊ฒฝ์ฐ Java.use ์ฌ์ฉ
//instance method์ผ ๊ฒฝ์ฐ Java.choose๋ฅผ ์ฌ์ฉ
Java.choose("uk.rossmarks.fridalab.MainActivity",{
onMatch : function(test){
test.chall02();
},
onComplete : function(){
console.log("[*]#2 is clear");
}
})
> ์คํ ๊ฒฐ๊ณผ
ํ๋ฆฌ๋ค ์คํ ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ ์คํฌ๋ฆฝ์ค ์คํ : Frida -U -l fridalab.js uk.rossmakrs.fridalab
์คํ๊ฒฐ๊ณผ 2๋ฒ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
๐๋ฌธ์ ํ์ด (3๋ฒ)
- ๋ฌธ์ : Make chall03() return true
> ๋ฌธ์ ๋ฅผ ๋ณด๋ฉด chall03() ํจ์์์ True๋ฅผ ๋ฆฌํดํ๋๋ก ๋ง๋๋ ๊ฒ์ด๋ค.
//#3
var test = Java.use("uk.rossmarks.fridalab.MainActivity");
test.chall03.implementation = function(){
console.log("[*]#3 is clear");
return true;
}
> ์คํ ๊ฒฐ๊ณผ
ํ๋ฆฌ๋ค ์คํ ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ ์คํฌ๋ฆฝ์ค ์คํ : Frida -U -l fridalab.js uk.rossmakrs.fridalab
์คํ๊ฒฐ๊ณผ 3๋ฒ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
๐๋ฌธ์ ํ์ด (4๋ฒ)
- ๋ฌธ์ : Send “frida” to chall04()
> ๋ฌธ์ ๋ฅผ ๋ณด๋ฉด chall04() ์ธ์๊ฐ์ “frida"๋ผ๋ ๋ฌธ๊ตฌ๋ฅผ ๋ณด๋ด์ด ํจ์๋ฅผ ์คํ์ํค๋๋ก ํ๋ ๊ฒ์ด๋ค.
Java.choose("uk.rossmarks.fridalab.MainActivity",{
onMatch : function(test){
test.chall04("frida");
},
onComplete : function(){
console.log("[*]#4 is clear");
}
})
> ์คํ ๊ฒฐ๊ณผ
ํ๋ฆฌ๋ค ์คํ ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ ์คํฌ๋ฆฝ์ค ์คํ : Frida -U -l fridalab.js uk.rossmakrs.fridalab
์คํ๊ฒฐ๊ณผ 4๋ฒ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
๐๋ฌธ์ ํ์ด (5๋ฒ)
- ๋ฌธ์ : Always send “frida” to chall05()
> ๋ฌธ์ ๋ฅผ ๋ณด๋ฉด chall05() ์ธ์๊ฐ์ “frida"๋ผ๋ ๋ฌธ๊ตฌ๋ฅผ check๋ฅผ ๋๋ฅผ๋ ๋ง๋ค ๋ณด๋ด ํจ์๋ฅผ ์คํ์ํค๋๋ก ํ๋ ๊ฒ์ด๋ค.
//#5
var test = Java.use("uk.rossmarks.fridalab.MainActivity");
test.chall05.implementation = function(){
console.log("[*]#5 is clear");
this.chall05("frida");
}
> ์คํ ๊ฒฐ๊ณผ
ํ๋ฆฌ๋ค ์คํ ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ ์คํฌ๋ฆฝ์ค ์คํ : Frida -U -l fridalab.js uk.rossmakrs.fridalab
์คํ๊ฒฐ๊ณผ 5๋ฒ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
๐๋ฌธ์ ํ์ด (6๋ฒ)
- ๋ฌธ์ : Run chall06() after 10 seconds with correct value
> ๋ฌธ์ ๋ฅผ ๋ณด๋ฉด chall06() ํจ์๋ฅผ check๋ฒํผ์ ๋๋ฅธ๋ค 10์ด ๋ค์ ์คํ์ํค๋ ๊ฒ์ ์๋ฏธํ๋ ๊ฒ ๊ฐ๋ค
//challenge 06, setTimeout(fn, delay) ํ์
setTimeout(function(){
console.log("[*]Click to solve the problem");
setImmediate(function(){
Java.perform(function(){
var chall_06 = Java.use("uk.rossmarks.fridalab.challenge_06");
chall_06.addChall06.overload("int").implementation = function(arg){
Java.choose("uk.rossmarks.fridalab.MainActivity", {
onMatch : function(instance){
instance.chall06(chall_06.chall06.value);
},
onComplete : function(){
console.log("[*]Solved Challenge 06");
}
})
}
})
})
},10000);
> ์คํ ๊ฒฐ๊ณผ
ํ๋ฆฌ๋ค ์คํ ๋ช
๋ น์ด๋ฅผ ํตํ์ฌ ์คํฌ๋ฆฝ์ค ์คํ : Frida -U -l fridalab.js uk.rossmakrs.fridalab
์คํ๊ฒฐ๊ณผ 6๋ฒ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋ ๊ฒ์ ํ์ธ ํ ์ ์๋ค.
๐๋ฌธ์ ํ์ด (7๋ฒ)
- ๋ฌธ์ : Bruteforce check07pin() then confirm with chall07()
๐๋ฌธ์ ํ์ด (8๋ฒ)
- ๋ฌธ์ : Change ‘check’ button’s text value to ‘Confirm”
๐๋ฌธ์ ํ์ด ์ ๋ฆฌ
//fridaLab ์ ๋ฆฌ
setImmediate(function(){
Java.perform(function(){
//#1
var test = Java.use("uk.rossmarks.fridalab.challenge_01");
test.chall01.value = 1;
console.log("[*] chall01 value is ", test.chall01.value);
//#2
Java.choose("uk.rossmarks.fridalab.MainActivity",{
onMatch : function(test){
test.chall02();
},
onComplete : function(){
console.log("[*]#2 is clear");
}
})
//#3
var test = Java.use("uk.rossmarks.fridalab.MainActivity");
test.chall03.implementation = function(){
console.log("[*]#3 is clear");
return true;
}
//#4
Java.choose("uk.rossmarks.fridalab.MainActivity",{
onMatch : function(test){
test.chall04("frida");
},
onComplete : function(){
console.log("[*]#4 is clear");
}
})
//#5
var test = Java.use("uk.rossmarks.fridalab.MainActivity");
test.chall05.implementation = function(){
console.log("[*]#5 is clear");
this.chall05("frida");
}
//#7
var test = Java.use("uk.rossmarks.fridalab.challenge_07");
test.check07Pin.implementation = function(){
console.log("[*]#7 is clear");
return ture;
}
//#8
var test = Java.use("uk.rossmarks.fridalab.MainActivity");
test.chall08.implementation = function(){
console.log("[*]#8 is clear");
return true;
}
})
})
//challenge 06, setTimeout(fn, delay) ํ์
setTimeout(function(){
console.log("[*]Click to solve the problem");
setImmediate(function(){
Java.perform(function(){
var chall_06 = Java.use("uk.rossmarks.fridalab.challenge_06");
chall_06.addChall06.overload("int").implementation = function(arg){
Java.choose("uk.rossmarks.fridalab.MainActivity", {
onMatch : function(instance){
instance.chall06(chall_06.chall06.value);
},
onComplete : function(){
console.log("[*]Solved Challenge 06");
}
})
}
})
})
},10000);