[Frida] 루팅탐지 우회기법 및 실습

유서정·2024년 3월 26일
post-thumbnail

루팅탐지 우회기법

실습

# 1. 루팅 탐지 로직 우회

루트 탐지 로직 자체를 우회해서
Root detected!! 창이 뜨지 않도록 함

root_detect_v1.js

Java.perform(function() {
	var root_hypass = Java.use("sg.vantagepoint.a.c")	//패키지의 c 클래스

	root_hypass.a.implementation = function() {		//a메서드에 대해 무조건 false 반환
		return false;
	}

	root_hypass.b.implementation = function() {		//b메서드에 대해 무조건 false 반환
		return false;
	}

	root_hypass.c.implementation = function() {		//c메서드에 대해 무조건 false 반환
		return false;
	}
})

//b, c만 수정했을땐 루팅이 우회되지 않음
//== 실질적으로 루팅을 탐지하는 것은 c클래스의 a메소드

a,b,c 메서드에 대해서 무조건 false 반환하도록 수정

실행화면

# 2. 시스템 함수 우회

프로그램 종료 시키는 시스템 함수(exit) 우회하여
OK 버튼을 눌러도 프로그램이 종료되지 않도록 함

root_detect_v2.js

Java.perform(function() {
	var System_ = Java.use("java.lang.System")
	console.log("[-] Rooting Bypass ...")

	//root 탐지 우회, System.exit() 시스템 함수 후킹
	System_.exit.implementation = function() {
		console.log("[+] System exit")
	}
})

//Root Detected는 뜨지만 ok를 눌러도 프로그램이 종료되지 않음
//패키지명 : owasp.mstg.uncrackable1 (Manifest.xml 파일에서 찾으면 됨)

실행화면

# 3. 루팅 탐지 로직 우회 + 문자열 입력 검증 우회

루팅 탐지 로직 우회
+
문자열 입력 검증 우회로 verify 버튼을 눌렀을때 무조건 성공이 뜨도록 함

root_detect_v3.js

Java.perform(function(){
	var root_ = Java.use("sg.vantagepoint.a.c")
	var secret_logic = Java.use("sg.vantagepoint.uncrackable1.a")
	console.log("[-] Verify Logic Bypass ...")

	//c 클래스, 루팅 탐지 로직 우회
	root_.a.overload().implementation = function() {
		return false();
	}

	//Secret key 인증 로직 우회
	secret_logic.a.implementation = function() {
		console.log("[+] Verify Logic Bypass Success")
		return true;
	}
})

실행화면

# 4. 루팅 탐지 로직 우회 + 인증 문자열 추출

root_detect_v4.js

Java.perform(function(){
	var root_ = Java.use("sg.vantagepoint.a.c")
	var secret_hook = Java.use("sg.vantagepoint.a.a")
	console.log("[-] Verify Logic Bypass ...")

	//c 클래스, 루팅 탐지 로직 우회
	root_.a.overload().implementation = function() {
		return false();
	}

	//Secret key 문자열 추출 및 인증
	secret_hook.a.implementation = function(arg1, arg2) {
		console.log("[*] AES String Extract...")
		//bArr[], bArr2[] 값을 10진수로 줄력
		var retval = this.a(arg1, arg2);
		console.log("[-] String Value Demical :"+retval)
		console.log("[-] String Length :"+retval.length)
		var string_array = "";

		for(var i=0;i<retval.length;i++)
			string_array+=String.fromCharCode(retval[i])

		console.log("[+] Find Secret String : "+string_array)
		return retval
	}
})

실행화면

# 5. 루팅 탐지 로직 우회 + 인증 문자열 추출

root_detect_v5.js

Java.perform(function(){
	var root_ = Java.use("sg.vantagepoint.a.c")
	console.log("[-] Verify Logic Bypass ...")

	//c 클래스, 루팅 탐지 로직 우회
	root_.a.overload().implementation = function() {
		return false();
	}

	console.log("[-] 3초 후, 문자열 출력 코드 실행")
	//String 출력, 출력 결과 내에 정답 문자열 확인
	setTimeout(function() {
		console.log("[+] 문자열 출력")
		var str_1 = Java.use("java.lang.String")
		str_1.equals.implementation = function(arg1) {
			console.log(this+':::'+arg1)
			return false
		}
	}, 3000)	//3초

})
profile
information security

0개의 댓글