????????? Android App ???????????????????????????????? dex??????????Ч????????????????????·??У??????????????? smali ??????????????????????鷳???????????????????????????????????????????????????????????????Щ APP ????????????????????
????Xposed ?? Android ????????????? hook ??????? Xposed???????????? Java ??????з?????hook ????÷??????????????滻??????????????????????????????????????? Xposed ?????????????????Щ??á?
??????? hook
????Xposed ?滻?? app_process (Zygote) ???? Java ??????? Native ???????????????????? Java ??????????????????????????Xposed ??? hook Java ????????????????????? Xposed ???? module ??????? API ??????????????ο? Xposed repo ??? ??? ???????? API ??? ????????????磺
/* Hook org.apache.http ???е? HttpPost ???? */
XposedHelpers.findAndHookMethod("org.apache.http.impl.client.AbstractHttpClient"?? loadPackageParam.classLoader?? "execute"?? HttpUriRequest.class?? new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (!param.args[0].getClass().getCanonicalName().contains("HttpPost")) {
return;
}
HttpPost request = (HttpPost) param.args[0];
String url = request.getURI().toString();
}
}
????Xposed ??? Java ?????????? API???????????????????? ???????? hook ??????????? ???????????????????????????????????б???д????б???????????????????????????д??????????????? hook ?????? Dalvik ?? invoke-virtual ??????????????ж????????????????????????????????????????????????????????????????????? super() ??????
?????????????е??????????????? hook java.net.HttpURLConnection ?? getInputStream() ???????????Щ????????????????????????????????????д???
/* ??????? */
XposedHelpers.findAndHookMethod("java.net.HttpURLConnection"?? loadPackageParam.classLoader?? "getInputStream"?? new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
/* Do something */
}
}
???????????????Xposed ??????????????÷????????????????? getInputStream() ????????????????? java.net.URLConnection ????????? java.net.HttpURLConnection ?в??????д????????????????????? java.net.URLConnection ????? hook ????????????? java.net.URLConnection ?? getInputStream() ????????
/**
* Returns an {@code InputStream} for reading data from the resource pointed by
* this {@code URLConnection}. It throws an UnknownServiceException by
* default. This method must be overridden by its subclasses.
*
* @return the InputStream to read data from.
* @throws IOException
*             if no InputStream could be created.
*/
public InputStream getInputStream() throws IOException {
throw new UnknownServiceException("Does not support writing to the input stream");
}
??????????????? java.net.URLConnection ???????????????????????У?HTTP ?????????????? framework ?????Щ??????????????????????
??????????? hook ??????е???????????????
final int apiLevel = Build.VERSION.SDK_INT;
/* ?? Android 4.4 ????? okhttp ?????? 6.0 ??????и?? */
if (apiLevel >= 23) {
XposedHelpers.findAndHookMethod("com.android.okhttp.internal.huc.HttpURLConnectionImpl"?? loadPackageParam.classLoader?? "getInputStream"?? URLGetInputStreamHook);
} else if (apiLevel >= 19) {
XposedHelpers.findAndHookMethod("com.android.okhttp.internal.http.HttpURLConnectionImpl"?? loadPackageParam.classLoader?? "getInputStream"?? URLGetInputStreamHook);
} else {
XposedHelpers.findAndHookMethod("libcore.net.http.HttpURLConnectionImpl"?? loadPackageParam.classLoader?? "getInputStream"?? URLGetInputStreamHook);
}