Xposed 修改硬體函式 不適合新手閱讀 這是重寫版本 之前的寫的太垃圾了
世界美景發表於2017-11-03
具體我就不多說了 xpsoed相關 看老帖子 重寫版本注重程式碼
讀取器 獲取硬體相關資訊 方便檢測HOOK成功了嗎 我只獲取了少部分
--------------------------------------------------------------------------------------------------------------------------- private void init() { DisplayMetrics book=new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(book); try { Class localClass = Class.forName("android.os.SystemProperties"); Object localObject1 = localClass.newInstance(); Object localObject2 = localClass.getMethod("get", new Class[] { String.class, String.class }).invoke(localObject1, new Object[] { "gsm.version.baseband", "no message" }); setEditText(R.id.get,localObject2+""); } catch (Exception e) { e.printStackTrace(); } //獲取網路連線管理者 ConnectivityManager connectionManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); //獲取網路的狀態資訊,有下面三種方式 NetworkInfo networkInfo = connectionManager.getActiveNetworkInfo(); setEditText(R.id.lianwang,networkInfo.getType()+""); setEditText(R.id.lianwangname,networkInfo.getTypeName()); setEditText(R.id.imei, phone.getDeviceId()); setEditText(R.id.deviceversion,phone.getDeviceSoftwareVersion()); setEditText(R.id.imsi, phone.getSubscriberId()); setEditText(R.id.number, phone.getLine1Number()); setEditText(R.id.simserial, phone.getSimSerialNumber()); setEditText(R.id.simoperator,phone.getSimOperator()); setEditText(R.id.simoperatorname, phone.getSimOperatorName()); setEditText(R.id.simcountryiso, phone.getSimCountryIso()); setEditText(R.id.workType,phone.getNetworkType()+""); setEditText(R.id.netcountryiso,phone.getNetworkCountryIso()); setEditText(R.id.netoperator,phone.getNetworkOperator()); setEditText(R.id.netoperatorname,phone.getNetworkOperatorName()); setEditText(R.id.radiovis,android.os.Build.getRadioVersion()); setEditText(R.id.wifimac, wifi.getConnectionInfo().getMacAddress()); setEditText(R.id.getssid,wifi.getConnectionInfo().getSSID()); setEditText(R.id.getbssid,wifi.getConnectionInfo().getBSSID()); setEditText(R.id.ip,wifi.getConnectionInfo().getIpAddress()+""); setEditText(R.id.bluemac, BluetoothAdapter.getDefaultAdapter() .getAddress()); setEditText(R.id.bluname, BluetoothAdapter.getDefaultAdapter().getName() ); setEditText(R.id.cpu,Mnt.getCpuName()); setEditText(R.id.andrlid_id, Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)); setEditText(R.id.serial,android.os.Build.SERIAL); setEditText(R.id.brand,android.os.Build.BRAND); setEditText(R.id.tags, android.os.Build.TAGS); setEditText(R.id.device,android.os.Build.DEVICE); setEditText(R.id.fingerprint,android.os.Build.FINGERPRINT); setEditText(R.id.bootloader, Build.BOOTLOADER); setEditText(R.id.release, Build.VERSION.RELEASE); setEditText(R.id.sdk,Build.VERSION.SDK); // setEditText(R.id.sdk_INT,Build.VERSION.SDK_INT+""); setEditText(R.id.codename,Build.VERSION.CODENAME); setEditText(R.id.incremental,Build.VERSION.INCREMENTAL); setEditText(R.id.cpuabi, android.os.Build.CPU_ABI); setEditText(R.id.cpuabi2, android.os.Build.CPU_ABI2); setEditText(R.id.board, android.os.Build.BOARD); setEditText(R.id.model, android.os.Build.MODEL); setEditText(R.id.product, android.os.Build.PRODUCT); setEditText(R.id.type, android.os.Build.TYPE); setEditText(R.id.user, android.os.Build.USER); setEditText(R.id.disply, android.os.Build.DISPLAY); setEditText(R.id.hardware, android.os.Build.HARDWARE); setEditText(R.id.host, android.os.Build.HOST); setEditText(R.id.changshang, android.os.Build.MANUFACTURER); setEditText(R.id.phonetype,phone.getPhoneType()+""); setEditText(R.id.simstate,phone.getSimState()+""); setEditText(R.id.b_id,Build.ID); setEditText(R.id.gjtime,android.os.Build.TIME+""); setEditText(R.id.width,display.getWidth()+""); setEditText(R.id.height,display.getHeight()+""); setEditText(R.id.dpi,book.densityDpi+""); setEditText(R.id.density,book.density+""); setEditText(R.id.xdpi,book.xdpi+""); setEditText(R.id.ydpi,book.ydpi+""); setEditText(R.id.scaledDensity,book.scaledDensity+""); //setEditText(R.id.wl,getNetworkState(this)+""); // 方法2 DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width=dm.widthPixels; int height=dm.heightPixels; setEditText(R.id.xwidth,width+""); setEditText(R.id.xheight,height+""); } private void setEditText(int id, String s) { ((TextView) this.findViewById(id)).setText(s); } ----------------------------------------------------------------------------------------------------------------------------------- /** * 使用SharedPreferences 儲存輸入框輸入的資料 */ private void saveData() { try { SharedPreferences sh = this.getSharedPreferences("prefs", Context.MODE_WORLD_READABLE); SharedPreferences.Editor pre = sh.edit(); // Logger.d("儲存內容"); pre.putString("imei", this.getEditText(R.id.imei)); pre.putString("deviceversion",this.getEditText(R.id.deviceversion)); pre.putInt("phonetype", Integer.parseInt(this.getEditText(R.id.phonetype))); pre.putInt("simstate", Integer.parseInt(this.getEditText(R.id.simstate))); pre.putInt("width", Integer.parseInt(this.getEditText(R.id.width))); pre.putInt("height", Integer.parseInt(this.getEditText(R.id.height))); pre.putString("imsi", this.getEditText(R.id.imsi)); pre.putString("number", this.getEditText(R.id.number)); pre.putString("simserial", this.getEditText(R.id.simserial)); pre.putString("simoperator", this.getEditText(R.id.simoperator)); pre.putString("simoperatorname", this.getEditText(R.id.simoperatorname)); pre.putString("simcountryiso", this.getEditText(R.id.simcountryiso)); pre.putString("netcountryiso", this.getEditText(R.id.netcountryiso)); pre.putString("netoperator", this.getEditText(R.id.netoperator)); pre.putString("netoperatorname", this.getEditText(R.id.netoperatorname)); pre.putString("radiovis",this.getEditText(R.id.radiovis)); pre.putString("wifimac", this.getEditText(R.id.wifimac)); pre.putString("bluemac", this.getEditText(R.id.bluemac)); pre.putString("bluname",this.getEditText(R.id.bluname)); pre.putString("serial", this.getEditText(R.id.serial)); pre.putString("brand", this.getEditText(R.id.brand)); pre.putString("tags", this.getEditText(R.id.tags)); pre.putString("device", this.getEditText(R.id.device)); pre.putString("fingerprint", this.getEditText(R.id.fingerprint)); pre.putString("bootloader", this.getEditText(R.id.bootloader)); pre.putString("release", this.getEditText(R.id.release)); pre.putString("sdk", this.getEditText(R.id.sdk)); pre.putString("codename", this.getEditText(R.id.codename)); pre.putString("incremental", this.getEditText(R.id.incremental)); pre.putString("cpuabi", this.getEditText(R.id.cpuabi)); pre.putString("cpuabi2", this.getEditText(R.id.cpuabi2)); pre.putString("board", this.getEditText(R.id.board)); pre.putString("model", this.getEditText(R.id.model)); pre.putString("product", this.getEditText(R.id.product)); pre.putString("type", this.getEditText(R.id.type)); pre.putString("user", this.getEditText(R.id.user)); pre.putString("disply", this.getEditText(R.id.disply)); pre.putString("hardware", this.getEditText(R.id.hardware)); pre.putString("host", this.getEditText(R.id.host)); pre.putString("changshang", this.getEditText(R.id.changshang)); pre.putInt("time", Integer.parseInt(this.getEditText(R.id.gjtime))); pre.putString("androidid", this.getEditText(R.id.androidid)); pre.putInt("dpi", Integer.parseInt(this.getEditText(R.id.dpi))); pre.apply(); } catch (Throwable e) { // Logger.d("寫入內容失敗"); e.printStackTrace(); } } private void setEditText(int id, String s) { ((EditText) this.findViewById(id)).setText(s); } private String getEditText(int id) { return ((EditText) this.findViewById(id)).getText().toString(); } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ HOOK 介面 注意HOOK 很重要的一塊 HOOK什麼型別的值 透過SharedPreferences儲存的時候也要是相應 的型別 改的函式是Int 必須是Int 字串必須是字串 傳過來的 getString就得是字串 getint就得是Int 要不然就潰 這個下面程式碼少部分型別貌似不對 這個也是初期的老程式碼 哎懶得找了 大家對付看吧 主要是思路 public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { readData(lpparam); } private void readData(XC_LoadPackage.LoadPackageParam lpparam) throws IllegalAccessException { final XSharedPreferences pre = new XSharedPreferences(this.getClass() .getPackage().getName(), "prefs"); HookMethod(TelephonyManager.class, "getDeviceId",pre.getString("imei",null)); HookMethod(TelephonyManager.class, "getDeviceSoftwareVersion", pre.getString("deviceversion",null)); HookMethod(TelephonyManager.class,"getPhoneType",pre.getInt("phonetype",6)); HookMethod(TelephonyManager.class,"getSimState",pre.getInt("simstate",6)); HookMethod(Display.class,"getWidth",pre.getInt("width",6)); HookMethod(Display.class,"getHeight",pre.getInt("height",6)); // HookMethod(DisplayMetrics.class,"getDisplayMetrics",pre.getInt("dpi",6)); HookMethod(TelephonyManager.class,"getSubscriberId",pre.getString("imsi",null)); HookMethod(TelephonyManager.class, "getLine1Number",pre.getString("number",null)); HookMethod(TelephonyManager.class, "getSimSerialNumber",pre.getString("simserial",null)); HookMethod(TelephonyManager.class, "getSimOperator", pre.getString("simoperator",null)); HookMethod(TelephonyManager.class, "getSimOperatorName", pre.getString("simoperatorname",null)); HookMethod(TelephonyManager.class, "getSimCountryIso", pre.getString("simcountryiso",null)); HookMethod(TelephonyManager.class, "getNetworkCountryIso", pre.getString("netcountryiso",null)); HookMethod(TelephonyManager.class, "getNetworkOperator", pre.getString("netoperator",null)); HookMethod(TelephonyManager.class, "getNetworkOperatorName", pre.getString("netoperatorname",null)); HookMethod(android.os.Build.class, "getRadioVersion", pre.getString("radiovis",null)); HookMethod(WifiInfo.class, "getMacAddress",pre.getString("wifimac",null)); HookMethod(BluetoothAdapter.class, "getAddress", pre.getString("bluemac",null)); HookMethod(BluetoothAdapter.class,"getName",pre.getString("bluname",null)); XposedHelpers.findField(android.os.Build.class, "SERIAL").set(null, pre.getString("serial",null)); XposedHelpers.findField(android.os.Build.class, "BRAND").set(null, pre.getString("brand",null)); XposedHelpers.findField(android.os.Build.class, "TAGS").set(null, pre.getString("tags",null)); XposedHelpers.findField(android.os.Build.class, "DEVICE").set(null, pre.getString("device",null)); XposedHelpers.findField(android.os.Build.class, "FINGERPRINT").set(null, pre.getString("fingerprint",null)); XposedHelpers.findField(android.os.Build.class, "BOOTLOADER").set(null, pre.getString("bootloader",null)); XposedHelpers.findField(Build.VERSION.class, "RELEASE").set(null, pre.getString("release",null)); XposedHelpers.findField(Build.VERSION.class, "SDK").set(null, pre.getString("sdk",null)); XposedHelpers.findField(Build.VERSION.class, "CODENAME").set(null, pre.getString("codename",null)); XposedHelpers.findField(Build.VERSION.class, "INCREMENTAL").set(null, pre.getString("incremental",null)); XposedHelpers.findField(android.os.Build.class, "CPU_ABI").set(null, pre.getString("cpuabi",null)); XposedHelpers.findField(android.os.Build.class, "CPU_ABI2").set(null, pre.getString("cpuabi2",null)); XposedHelpers.findField(android.os.Build.class, "BOARD").set(null, pre.getString("board",null)); XposedHelpers.findField(android.os.Build.class, "MODEL").set(null, pre.getString("model",null)); XposedHelpers.findField(android.os.Build.class, "PRODUCT").set(null, pre.getString("product",null)); XposedHelpers.findField(android.os.Build.class, "TYPE").set(null, pre.getString("type",null)); XposedHelpers.findField(android.os.Build.class, "USER").set(null, pre.getString("user",null)); XposedHelpers.findField(android.os.Build.class, "DISPLAY").set(null, pre.getString("disply",null)); XposedHelpers.findField(android.os.Build.class, "HARDWARE").set(null, pre.getString("hardware",null)); XposedHelpers.findField(android.os.Build.class, "HOST").set(null, pre.getString("host",null)); XposedHelpers.findField(android.os.Build.class, "MANUFACTURER").set(null, pre.getString("changshang",null)); XposedHelpers.findField(android.os.Build.class,"TIME").set(null,pre.getInt("time",7)); } ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ GPU 相關HOOK 方法 這個網上目前沒有 只有我這一份程式碼 mySP.setSharedPref("GLRenderer", "Adreno (TM) 111"); // GPU mySP.setSharedPref("GLVendor", "UFU");// GPU廠商 try { XposedHelpers.findAndHookMethod("com.google.android.gles_jni.GLImpl", loadPkgParam.classLoader, "glGetString", Integer.TYPE, new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub //super.beforeHookedMethod(param); if (param.args[0] != null) { if (param.args[0].equals(Integer.valueOf(7936))) { param.setResult(SharedPref.getXValue("GLVendor")); } if (param.args[0].equals(Integer.valueOf(7937))) { param.setResult(SharedPref.getXValue("GLRenderer")); } } } }); } catch (Exception e) { XposedBridge.log("Fake GLVendor|GLRenderer ERROR: " + e.getMessage()); }*/ --------------------------------------------------------------------------------------------------------------------------------------------- 單獨列出來的都是 不太好HOOK 的 其實 這種寫法 不太適合新手閱讀 但沒辦法了 // 螢幕相關函式 解析度啊 xdpi ydpi 等等 try { XposedHelpers.findAndHookMethod("android.view.Display", loadPkgParam.classLoader, "getMetrics", DisplayMetrics.class, new XC_MethodHook(XCallback.PRIORITY_LOWEST) { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); final int dpi = tryParseInt(SharedPref.getXValue("DPI")); DisplayMetrics metrics = (DisplayMetrics) param.args[0]; metrics.densityDpi = dpi; } }); } catch (Exception e) { XposedBridge.log("Fake DPI ERROR: " + e.getMessage()); } try { XposedHelpers.findAndHookMethod("android.view.Display", loadPkgParam.classLoader, "getRealMetrics", DisplayMetrics.class, new XC_MethodHook(XCallback.PRIORITY_LOWEST) { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); final int dpi = tryParseInt(SharedPref.getXValue("DPI")); DisplayMetrics metrics = (DisplayMetrics) param.args[0]; metrics.densityDpi = dpi; } }); } catch (Exception e) { } try { XposedHelpers.findAndHookMethod("android.view.Display", loadPkgParam.classLoader, "getMetrics", DisplayMetrics.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); final float sdensity = tryParsefloat(SharedPref.getXValue("density")); DisplayMetrics metrics = (DisplayMetrics) param.args[0]; metrics.density = sdensity; } }); } catch (Exception e) { } try { XposedHelpers.findAndHookMethod("android.view.Display", loadPkgParam.classLoader, "getMetrics", DisplayMetrics.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); final float sxdpi = tryParsefloat(SharedPref.getXValue("xdpi")); DisplayMetrics metrics = (DisplayMetrics) param.args[0]; metrics.xdpi = sxdpi; } }); } catch (Exception e) { XposedBridge.log("Fake Real DPI ERROR: " + e.getMessage()); } try { XposedHelpers.findAndHookMethod("android.view.Display", loadPkgParam.classLoader, "getMetrics", DisplayMetrics.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); final float sydpi = tryParsefloat(SharedPref.getXValue("ydpi")); DisplayMetrics metrics = (DisplayMetrics) param.args[0]; metrics.ydpi = sydpi; } }); } catch (Exception e) { } try { XposedHelpers.findAndHookMethod("android.view.Display", loadPkgParam.classLoader, "getMetrics", DisplayMetrics.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); final float scdensity = tryParsefloat(SharedPref.getXValue("scaledDensity")); DisplayMetrics metrics = (DisplayMetrics) param.args[0]; metrics.scaledDensity = scdensity; } }); } catch (Exception e) { } private static int tryParseInt(String s) { try { return Integer.parseInt(s); } catch (NumberFormatException e) { return 320; } } private static float tryParsefloat(String s) { try { return Float.parseFloat(s); } catch (NumberFormatException e) { return (float) 480.0; } } -------------------------------------------------------------------------------------------------------------------------------------------- // get 引數HOOK 需要反射獲取下路徑 Class<?> classSysProp = Class .forName("android.os.SystemProperties"); XposedHelpers.findAndHookMethod(classSysProp, "get", String.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); String serialno = (String) param.args[0]; if (serialno.equals("gsm.version.baseband") || serialno.equals("no message") ) { param.setResult(SharedPref.getXValue("getBaseband")); } } }); XposedHelpers.findAndHookMethod(classSysProp, "get", String.class, String.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { // TODO Auto-generated method stub super.afterHookedMethod(param); String serialno = (String) param.args[0]; if (serialno.equals("gsm.version.baseband") || serialno.equals("no message") ) { param.setResult(SharedPref.getXValue("getBaseband")); } } });
---------------------------------------------------------------------------------------------------------------------
基本上比較難HOOK的函式 我都列出來了 不太適合新手觀看 寫的比較亂 好多種版本混合的程式碼
但核心HOOK 都是對的 除了傳值不太一樣
相關文章
- Xposed修改硬體資訊總結2017-11-03
- 函式的提升與重寫2024-05-31函式
- NSLog函式重寫2013-11-14函式
- 讀寫日誌函式2013-07-04函式
- java方法的神奇修改(重寫)2020-12-20Java
- 適合新手的流程圖軟體是什麼?原來精美的流程圖是這樣畫的2020-01-16流程圖
- 適合自媒體新手寫作的3大自媒體平臺,有手機就能做2022-03-23
- URL 重寫新手指南2016-08-29
- RFID讀寫器的組成,軟體與硬體部分2020-12-22
- Oracle job 中 interval 的寫法,實在是太操人了2014-06-19Oracle
- 寫的第一個函式是log - todo2015-05-22函式
- 寫了很久,這是一份最適合/貼切普通大眾/科班/非科班的『學習路線』2020-01-12
- 乾淨的程式碼: 編寫可讀的函式2022-02-04函式
- 讀寫INI檔案的四個函式 (轉)2007-12-15函式
- 自己寫的和收藏的一寫php函式2017-11-12PHP函式
- 如何讀懂並寫出裝逼的函式式程式碼2016-10-23函式
- 親身體驗6大自媒體平臺,這3個最適合新手,0基礎也能寫作變現2022-01-27
- 參考 logviewer 重寫了一個日誌讀寫包2019-08-08View
- 非推倒重來式的讀/寫伸縮擴充套件2011-06-07套件
- 修改java或css後不生效,還是顯示修改之前的樣式,問題已解決2021-01-04JavaCSS
- 不會用“函式選項模式”的朋友看過來,這麼寫很優雅2023-02-28函式模式
- 寫了一個數字轉成簡 / 繁體漢字的助手函式2017-06-28函式
- 用NumPy寫深度模型,用Julia可微分程式設計寫函式,這是WAIC開發者日2019-09-01模型程式設計函式AI
- 手寫JavaScript常用的函式2019-04-15JavaScript函式
- MyBatis 動態 SQL 最全教程,這樣寫 SQL 太優雅了!2024-04-26MyBatisSQL
- 難道是瘋了,要讀寫物件的私有屬性!2021-06-16物件
- C/C++—— C++中函式重寫和函式過載2016-04-04C++函式
- 寫了一個分段函式,引數是單個數字,執行函式 畫圖2018-12-28函式
- 對不起,我錯了,這程式碼不好寫2022-06-01
- 箭頭函式、簡寫函式、普通函式的區別2019-12-23函式
- 類成員函式的重寫,過載和隱藏的區別2014-03-30函式
- 程式設計女孩兒:誰說女生不適合寫程式碼!2014-01-07程式設計
- 大牛的程式碼是這樣寫的2019-05-11
- HDFS讀寫流程(重點)2020-07-08
- 最適合新手入門的SpringCloud教程 7—OpenFeign「F版本」2020-04-05SpringGCCloud
- C語言lseek()函式:移動檔案的讀寫位置2016-07-10C語言函式
- Linux網路程式設計--完整的讀寫函式(轉)2007-08-11Linux程式設計函式
- 程式設計師寫了一個新手都寫不出的低階bug,被罵慘了。2020-02-08程式設計師