Thursday, June 9, 2016

[Technical Guide] Hide tethering on H830

I am not going to provide a pre-built apk.

If you want to hide tethering, you have to learn and know the basics of xposed and compiling an apk.
I would prefer that no one provides a pre-built APK either, but I obviously can't demand/enforce this

Requirements: H830 T-mobile LG G5, root, xposed
May or may not work with other LG G5 variants

Technical details:
  1. Tethering app verifies permission with T-mobile before starting
    When you enable tethering, there is a popup saying something like "Please wait, verifing...".
    The "whichurl" backdoor bypasses this check/popup.
  2. Tethered data gets diverted into separate tethering APN
    T-mobile monitors this separate APN. The initZygote stuff attempts to stop this from happening. I have not tested this throughly, but it seems to work
  3. Rest of the hooks, probably not important

Code
Code:

package com.xposed.lgg5.tethering;

import android.content.Context;
import android.content.res.XResources;
import android.util.Log;
import android.widget.Toast;
import de.robv.android.xposed.*;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import static de.robv.android.xposed.XposedHelpers.setIntField;

public class XposedTetheringH830 implements IXposedHookLoadPackage, IXposedHookZygoteInit{


    public void initZygote(IXposedHookZygoteInit.StartupParam var1) throws Throwable {
        Log.i("XposedTetheringH830", "Updating systemwide arrays to stop tethering data being diverted into tethering APNs");
        XResources.setSystemWideReplacement("android", "array", "config_mobile_hotspot_provision_app", new String[0]);

        // If we override the three items below, tethering is completely disabled on device
        /*XResources.setSystemWideReplacement("android", "array", "config_tether_usb_regexs", new String[0]);
        XResources.setSystemWideReplacement("android", "array", "config_tether_wifi_regexs", new String[0]);
        XResources.setSystemWideReplacement("android", "array", "config_tether_bluetooth_regexs", new String[0]);*/

        // don't know if this is necessary
        XResources.setSystemWideReplacement("android", "array", "config_tether_upstream_types", new int[0]);

        // necessary, otherwise phone diverts tethered data into separate APNs
        XResources.setSystemWideReplacement("android", "array", "config_tether_apndata", new String[0]);
    }

    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if(lpparam.packageName == null || lpparam.appInfo == null || lpparam.appInfo.packageName == null) {
            return;
        }
        if(lpparam.packageName.equals("com.lge.upsell")) {
            // stops tethering APK from checking with Tmobile on tethering permissions on your account
            findAndHookMethod("com.lge.upsell.UpsellUtil", lpparam.classLoader, "getSettingInt", Context.class, String.class, int.class,
                    new XC_MethodHook() {
                        @Override
                        protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

                            Context context = (Context) param.args[0];
                            if (param.args[1].equals("whichurl")) {
                                Toast.makeText(context, "Upsell whichurl override = 4", Toast.LENGTH_SHORT).show();
                                Log.i("XposedTetheringH830", "Nice LG backdoor, Upsell whichurl override = 4");
                                param.setResult(4);
                            }
                        }
                    }
            );
        }

        // rest of these hooks probably not needed... the whichurl backdoor above is most important
        if(lpparam.packageName.equals("com.lge.wifihotspotwidget")) {
            findAndHookMethod("com.lge.wifihotspotwidget.MDMWifiSettingsAdapter", lpparam.classLoader, "checkDisallowHotspot", new XC_MethodReplacement() {
                @Override
                protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                    Log.i("XposedTetheringH830", "checkDisallowHotspot = false");
                    return false;
                }
            });

            findAndHookMethod("com.lge.wifihotspotwidget.WidgetPopup", lpparam.classLoader, "isTmusSimCard", new XC_MethodReplacement() {
                @Override
                protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                    Log.i("XposedTetheringH830", "widgetPopup isTmusSimCard = false");
                    return false;
                }
            });

            findAndHookMethod("com.lge.wifihotspotwidget.HotspotWidgetProvider", lpparam.classLoader, "isTmusSimCard", new XC_MethodReplacement() {
                @Override
                protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
                    Log.i("XposedTetheringH830", "HotspotWidgetProvider isTmusSimCard = false");
                    return false;
                }
            });

            findAndHookMethod("android.os.UserManager", lpparam.classLoader, "hasUserRestriction", String.class, new XC_MethodHook() {
                @Override
                protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

                    if(param.args[0].equals("no_config_tethering")){
                        Log.i("XposedTetheringH830", "no_config_tethering = false");
                        param.setResult(false);
                    }

                }
            });
        }

    }
}



from xda-developers http://ift.tt/24CCV4X
via IFTTT

No comments:

Post a Comment