修改IMEI:
HookIMEI(TelephonyManager.class, "getDeviceId", data);
public static void HookIMEI(final Class> cls, final String method, final String result) {
log(TAG+"->HookIMEI:"+result);
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void
afterHookedMethod(MethodHookParam param)throws Throwable {
param.setResult(result);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookIMEI:"+ e.getMessage());
}
}
修改IMSI:
HookIMSI(TelephonyManager.class, "getSubscriberId", data);
public static void HookIMSI(final Class> cls, final String method, final String result) {
log(TAG+"->HookIMSI:"+result);
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
param.setResult(result);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookIMSI:"+ e.getMessage());
}
}
修改Android_id:
HookAndroidID(Secure.class, "getString", Secure.ANDROID_ID, data);
HookAndroidID(System.class, "getString", Secure.ANDROID_ID, data);
public static void HookAndroidID(final Class> cls, final String method, final String type, final String result) {
try {
log(TAG+"->HookAndroidID:"+result);
Object[] obj = new Object[3];
obj[0] = ContentResolver.class;
obj[1] = String.class;
obj[2] = new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
if (param.args[1].equals(type)) {
param.setResult(result);
}
}
};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookAndroidID:"+ e.getMessage());
}
}
修改Build相关参数:
HookBuildID(Build.class, "ID", data);
public static void HookBuildID(final Class> cls, String fieldName, final String result) {
log(TAG+"->HookBuildID:"+result);
try {
XposedHelpers.setStaticObjectField(cls, fieldName, result);
} catch (Throwable e) {
log("ERROR:HookBuildID:"+ e.getMessage());
}
}
HookVersionSDKInt(Build.VERSION.class, "SDK_INT", sdkInt);
public static void HookVersionSDKInt(final Class> cls, String fieldName, final int result) {
log(TAG+"->HookVersionSDKInt:"+result);
try {
XposedHelpers.setStaticObjectField(cls, fieldName, result);
} catch (Throwable e) {
log("ERROR:HookVersionSDKInt:"+ e.getMessage());
}
}
修改WifiInfo相关参数:
HookWifiBSSID(WifiInfo.class, "getBSSID", bssid);
public static void HookWifiBSSID(final Class> cls, final String method, final String result) {
log(TAG+"->HookWifiBSSID:"+result);
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
param.setResult(result);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookWifiBSSID:"+ e.getMessage());
}
}
修改DisplayMetrics相关参数:
HookDisplayMetrics(Display.class, "getMetrics", width, height, desity, desityDpi, xDpi, yDpi);
public static void HookDisplayMetrics(final Class> cls, final String method,
final int widthPixels, final int heightPixels,
final Float desity, final int desityDpi, final Float xDpi,
final Float yDpi) {
try {
Object[] obj = new Object[2];
obj[0] = DisplayMetrics.class;
obj[1] = new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
DisplayMetrics dm = (DisplayMetrics)param.args[0];
if(heightPixels > 0)dm.heightPixels = heightPixels;
if(widthPixels > 0)dm.widthPixels = widthPixels;
if(desityDpi > 0)dm.densityDpi = desityDpi;
if(yDpi > 0.0f)dm.ydpi = yDpi;
if(xDpi > 0.0f)dm.xdpi = xDpi;
if(desity > 0.0f)dm.density = desity;
if(widthPixels > 0 ){
Field widField = DisplayMetrics.class.getDeclaredField("noncompatWidthPixels");
widField.setAccessible(true);
widField.set(dm, widthPixels);
}
if(heightPixels > 0 ){
Field heightField = DisplayMetrics.class.getDeclaredField("noncompatHeightPixels");
heightField.setAccessible(true);
heightField.set(dm, heightPixels);
}
if(desityDpi > 0){
Field ddpiCompatField = DisplayMetrics.class.getDeclaredField("noncompatDensityDpi");
ddpiCompatField.setAccessible(true);
ddpiCompatField.set(dm, desityDpi);
}
if(xDpi > 0.0f){
Field xdpiCompatField = DisplayMetrics.class.getDeclaredField("noncompatXdpi");
xdpiCompatField.setAccessible(true);
xdpiCompatField.set(dm, xDpi);
}
if(yDpi > 0.0f){
Field ydpiCompatField = DisplayMetrics.class.getDeclaredField("noncompatYdpi");
ydpiCompatField.setAccessible(true);
ydpiCompatField.set(dm, yDpi);
}
}
};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookDisplayMetrics:"+ e.getMessage());
}
}
修改Display相关参数:
HookDisplayWidth(Display.class, "getWidth", disWidth);
HookDisplayHeight(Display.class, "getHeight", disHeight);
public static void HookDisplayHeight(final Class> cls, final String method, final int result) {
log(TAG+"->HookDisplayHeight:"+result);
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
param.setResult(result);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookDisplayHeight:"+ e.getMessage());
}
}
public static void HookDisplayWidth(final Class> cls, final String method, final int result) {
log(TAG+"->HookDisplayWidth:"+result);
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
param.setResult(result);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookDisplayWidth:"+ e.getMessage());
}
}
修改SystemHttpAgent相关参数:
HookSystemHttpAgent(System.class, "getProperty", data));
public static void HookSystemHttpAgent(final Class> cls, final String method, final String result) {
log(TAG+"->HookSystemHttpAgent: "+result);
try {
Object[] obj = new Object[2];
obj[0] = String.class;
obj[1] = new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
if(param.args[0].equals("http.agent")){
param.setResult(result);
}
}
};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookSystemHttpAgent:"+ e.getMessage());
}
}
修改手机安装包信息:
HookInstalledPackages("android.app.ApplicationPackageManager", lpparam, "getInstalledPackages")
public static void HookInstalledPackages(String className, LoadPackageParam lpparam, String method) {
log(TAG+"->HookInstalledPackages.");
try {
ClassLoader loader = lpparam.classLoader;
Object[] obj = new Object[2];
obj[0] = Integer.TYPE.getName();
obj[1]= new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
List packs = (List) param.getResult();
List res = new ArrayList();
for(PackageInfo pi:packs){
if(pi.applicationInfo.packageName.contains("com.microvirt")
|| pi.applicationInfo.packageName.contains("com.thirdparty.superuser")
|| pi.applicationInfo.packageName.contains("de.robv.android.xposed.installer"))
{
continue;
}
res.add(pi);
}
param.setResult(res);
}
};
XposedHelpers.findAndHookMethod(className, loader, method, obj);
} catch (Throwable e) {
log("ERROR:HookInstalledPackages:"+ e.getMessage());
}
}
WIFI链接信息:
HookWifiGetConnectionInfo(WifiManager.class, "getConnectionInfo", bssid, wifiMac, ssid);
public static void HookWifiGetConnectionInfo(final Class> cls, final String method,
final String mBSSID, final String mMacAddress, final String mSSID) {
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
log(TAG+"->HookWifiGetConnectionInfo:afterHookedMethod");
WifiInfo result = (WifiInfo)param.getResult();
WifiInfo wInfo = WifiInfo.class.getConstructor(WifiInfo.class).newInstance(result);
Field fieldBssid = WifiInfo.class.getDeclaredField("mBSSID");
fieldBssid.setAccessible(true);
fieldBssid.set(wInfo, mBSSID);
Field fieldMac = WifiInfo.class.getDeclaredField("mMacAddress");
fieldMac.setAccessible(true);
fieldMac.set(wInfo, mMacAddress);
try {
Field fieldSSID = WifiInfo.class.getDeclaredField("mSSID");
fieldSSID.setAccessible(true);
fieldSSID.set(wInfo, mSSID);
} catch (Throwable ex) {
try {
Field fieldWifiSsid = WifiInfo.class.getDeclaredField("mWifiSsid");
fieldWifiSsid.setAccessible(true);
Object mWifiSsid = fieldWifiSsid.get(wInfo);
if (mWifiSsid != null) {
Method methodCreateFromAsciiEncoded = mWifiSsid.getClass().getDeclaredMethod(
"createFromAsciiEncoded", String.class);
fieldWifiSsid.set(wInfo, methodCreateFromAsciiEncoded.invoke(null, mSSID));
}
} catch (Throwable exex) {
Log.d("", exex.toString());
}
}
param.setResult(wInfo);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
} catch (Throwable e) {
log("ERROR:HookWifiGetConnectionInfo:"+ e.getMessage());
}
}
WIFI扫描信息:
HookWifiGetScanResult(WifiManager.class, "getScanResults", json));
public static void HookWifiGetScanResult(final Class> cls, final String method, final String paramString) {
try {
Object[] obj = new Object[]{new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param)throws Throwable {
List rtn =(List) param.getResult();
List scanResults = new ArrayList() ;
if(rtn.size()>0){
JSONArray array = new JSONArray(json);
for(int i=0; i<array.length(); i++){
JSONObject js = array.getJSONObject(i);
String wifiname = js.getString("wifiname");
String wifimac = js.getString("wifimac");
ScanResult scan = ScanResult.class.getConstructor(ScanResult.class).newInstance(rtn.get(0));
Field fieldssid = ScanResult.class.getDeclaredField("SSID");
fieldssid.setAccessible(true);
fieldssid.set(scan, wifiname);
Field fieldBssid = ScanResult.class.getDeclaredField("BSSID");
fieldBssid.setAccessible(true);
fieldBssid.set(scan, wifimac);
scanResults.add(scan);
}
}
param.setResult(scanResults);
}
}};
XposedHelpers.findAndHookMethod(cls, method, obj);
}catch (Throwable e) {
log("ERROR:HookWifiGetConnectionInfo:"+ e.getMessage());
}
}
File信息:
// Hook WifiManager getScanResults
public static class CHashMap{
public String key = ""
public String value = ""
public static CHashMap getNewHashMap(String key, String value){
CHashMap map = new CHashMap()
map.key = key
map.value = value
return map
}
}
// 需要修改的文件列表
List hookFileList = new ArrayList()
hookFileList.add(CHashMap.getNewHashMap("/system/app/Superuser", "/sb/noZuoNoDie_su"))
hookFileList.add(CHashMap.getNewHashMap("/system/app/Suser", "/sb/noZuoNoDie_su"))
hookFileList.add(CHashMap.getNewHashMap("/system/bin/su", "/sb/noZuoNoDie_su"))
hookFileList.add(CHashMap.getNewHashMap("/system/xbin/su", "/sb/noZuoNoDie_su"))
hookFileList.add(CHashMap.getNewHashMap("/system/sbin/su", "/sb/noZuoNoDie_su"))
hookFileList.add(CHashMap.getNewHashMap("/sbin/su", "/sb/noZuoNoDie_su"))
hookFileList.add(CHashMap.getNewHashMap("/vendor/bin/su", "/sb/noZuoNoDie_su"))
// 其它指定目录
String fileRoot = "/sdcard/hardwareInfo/"
hookFileList.add(CHashMap.getNewHashMap("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", fileRoot + "cpuinfo_max_freq"))
hookFileList.add(CHashMap.getNewHashMap("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq", fileRoot + "cpuinfo_min_freq"))
hookFileList.add(CHashMap.getNewHashMap("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq", fileRoot + "cpuinfo_cur_freq"))
hookFileList.add(CHashMap.getNewHashMap("/proc/cpuinfo", fileRoot + "cpuinfo"))
hookFileList.add(CHashMap.getNewHashMap("/proc/meminfo", fileRoot + "meminfo"))
// Hook
HookFile_path(lpparam, hookFileList)