일반적인 ios 후킹 코드
console.log("[*] Started: Hooking");
if (ObjC.available) {
try {
var className = "Class 명";
var funcName = "메소드 명";
var hook = eval('ObjC.classes.' + className + '["' + funcName + '"]');
var newretval = ptr('0x0');
Interceptor.attach(hook.implementation,{
onLeave : function(retval) {console.log("[*] Class Name : " + className);
console.log("[*] Function Name : " + funcName);
console.log("[+] type of return value : " + typeof retval);
console.log("[-] return value : " + retval);
retval.replace(newretval);
console.log("[-] new return value : " + retval);
}});}
catch(err) { console.log("[!] Exception2: " + err.message); } }
else { console.log("not aVailable!")}
Ida를 이용한 메모리 주소를 추가하여 해당 반환값을 변조하는 코드
var targetMobile = 'DVIA-v2';
var addr = ptr(0x1949A8);
var moduleBase = Module.getBaseAddress(targetMobile);
var targetAddress = moduleBase.add(addr);
Interceptor.attach(targetAddress, {
onEnter: function(args) {
console.log('Address Entered: ' +addr + 'args: '+ args[2]);
},
onLeave: function(retval){
console.log('retval: '+retval);
retval.replace(0x0);
console.log('modify: '+ retval);
}
});
UI dump 출처 : https://hackcatml.tistory.com/57
frida -U DVIA-v2 -l UI_dump.js
var window = ObjC.classes.UIWindow.keyWindow();
var rootControl = window.rootViewController();
var ui = window.recursiveDescription().toString();
var ui_autolayout = window['- _autolayoutTrace']().toString();
var control = rootControl['- _printHierarchy']().toString();
// 전체 UI 계층 출력하고 싶은 경우
// console.log("\n\x1b[31m" + ui + "\x1b[0m");
// Simplified recursiveDescription
// console.log("\n\x1b[34m" + ui_autolayout + "\x1b[0m");
// 현재 화면에 보여지는 UIController를 알고 싶은 경우
console.log("\n\x1b[32m" + control + "\x1b[0m");
'APP 모의해킹 > iOS' 카테고리의 다른 글
palera1n ios 15~16 탈옥방법 with 맥북 (0) | 2023.06.18 |
---|---|
Tweak setting (0) | 2023.04.23 |
iOS Setting (0) | 2023.04.03 |
iOS 정적 분석 (0) | 2023.03.30 |
iOS 진단 코드 (0) | 2023.03.21 |