티스토리 뷰

반응형

iOS앱에서 frida를 이용해 접근하는 파일이벤트를 추적할 수 있는 스크립트이다.

// 'open' 함수 후킹
Interceptor.attach(Module.findExportByName(null, 'open'), {
    onEnter: function(args) {
        var path = Memory.readUtf8String(args[0]);  // 첫 번째 인자는 파일 경로
        console.log('File opened: ' + path);
    },
    onLeave: function(retval) {
        // 파일 디스크립터 반환
    }
});

// 'fopen' 함수 후킹
Interceptor.attach(Module.findExportByName(null, 'fopen'), {
    onEnter: function(args) {
        var path = Memory.readUtf8String(args[0]);  // 첫 번째 인자는 파일 경로
        console.log('File fopen: ' + path);
    },
    onLeave: function(retval) {
        // 파일 포인터 반환
    }
});

// 'read' 함수 후킹
Interceptor.attach(Module.findExportByName(null, 'read'), {
    onEnter: function(args) {
        var fd = args[0].toInt32();  // 파일 디스크립터
        console.log('File read: FD=' + fd);
    },
    onLeave: function(retval) {
        // 리턴 값은 읽은 바이트 수
    }
});

// 'write' 함수 후킹
Interceptor.attach(Module.findExportByName(null, 'write'), {
    onEnter: function(args) {
        var fd = args[0].toInt32();  // 파일 디스크립터
        var size = args[2].toInt32();  // 쓰여진 바이트 크기
        console.log('File write: FD=' + fd + ' Bytes=' + size);
    },
    onLeave: function(retval) {
        // 리턴 값은 실제로 쓰여진 바이트 수
    }
});

// 'close' 함수 후킹
Interceptor.attach(Module.findExportByName(null, 'close'), {
    onEnter: function(args) {
        var fd = args[0].toInt32();  // 파일 디스크립터
        console.log('File closed: FD=' + fd);
    }
});
반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함