Xposed系列 - 微信自動登入

微信是我們日常最經常使用的APP,今天我們就使用Xposed來實現自動登入,在實現程式碼之前我們要先分析微信這個app。

1、查詢微信登入視窗

1。1 我們先在雷電模擬器開啟微信,進入登入介面。

Xposed系列 - 微信自動登入

1。2 再開啟佈局最佳化利器之 Hierarchy Viewer,透過這個利器我們可以看到微信的登入介面對應的類是:com。tencent。mm。plugin。account。ui。LoginUI。

Xposed系列 - 微信自動登入

2、

透過jadx-gui反編譯微信Apk,查詢相應的程式碼,並查詢賬號、密碼、登入按鈕對應的欄位。

Xposed系列 - 微信自動登入

透過程式碼分析,我們可以定位到:gZC為賬號輸入框,gZD為密碼輸入框,gZG為登入按鈕。

Xposed系列 - 微信自動登入

3、監聽登入介面,並設定賬號與密碼,並自動登入。

if(packageName。equals(“com。tencent。mm”)){ findAndHookMethod(“com。tencent。mm。plugin。account。ui。LoginUI”, loadPackageParam。classLoader, “onCreate”, Bundle。class, new XC_MethodHook() { @Override protected void afterHookedMethod(XC_MethodHook。MethodHookParam param) throws Throwable { Class c = loadPackageParam。classLoader。loadClass(“com。tencent。mm。plugin。account。ui。LoginUI”); //設定賬號 Field uaserName = c。getDeclaredField(“gZC”); uaserName。setAccessible(true); EditText uaserNameEditText = (EditText) uaserName。get(param。thisObject); uaserNameEditText。setText(“weixin”); //設定密碼 Field password = c。getDeclaredField(“gZD”); password。setAccessible(true); EditText passwordEditText = (EditText) password。get(param。thisObject); passwordEditText。setText(“123456”); //登入 Field login = c。getDeclaredField(“gZG”); login。setAccessible(true); Button loginButton = (Button) login。get(param。thisObject); loginButton。callOnClick(); } });}

Xposed系列 - 微信自動登入

這樣就可以實現微信自動登入功能,有2個地方要注意的:

1、Hierarchy Viewer在真機上,只有root才能連線。

2、我們透過Hierarchy Viewer看到的登入介面對應的類是:com。tencent。mm。plugin。account。ui。LoginUI,但反編譯出來的對應是:com。tencent。p194mm。plugin。account。p316ui。LoginUI,這個要注意下。