본문 바로가기

모바일

[android] frida hooking (프록시 탐지 우회)


1. proxy 탐지 구문
public static boolean ~~~Proxy(Context context) {
        int parseInt;
        if (VERSION.SDK_INT >= 14) {
            context = System.getProperty("http.proxyHost");
            String property = System.getProperty("http.proxyPort");
            if (property == null) {
                property = "-1";
            }
            parseInt = Integer.parseInt(property);
        } else {
            String host = Proxy.getHost(context);
            parseInt = Proxy.getPort(context);
            context = host;
        }
        return isNotEmpty(context) != null && parseInt > 0;
    }


2. python 코드
import sys
import frida

def on_message(message, data):
    print
    "[%s] -> %s" % (message, data)

PACKAGE_NAME = "com.package.name"

jscode = """
    Java.perform(function(){
        var System = Java.use("java.lang.System");  
        System.getProperty.overloads[0].implementation = function(prop){
            return 0;
        }
    });
"""

try:
    device = frida.get_usb_device(timeout=10)
    pid = device.spawn([PACKAGE_NAME])
    print("App is starting ... pid : {}".format(pid))
    process = device.attach(pid)
    device.resume(pid)
    script = process.create_script(jscode)
    script.on('message', on_message)
    print('[*] Running Frida')
    script.load()
    sys.stdin.read()
except Exception as e:
    print(e)