Skip to content

Commit ec1ad60

Browse files
committed
Add Xposed debug framework
Xposed 你調試那麽困難你家裏人知道嗎!!!
1 parent 611ab6e commit ec1ad60

File tree

4 files changed

+342
-173
lines changed

4 files changed

+342
-173
lines changed

app/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
apply plugin: 'com.android.application'
22

3+
def ADB_PATH = "${android.getSdkDirectory()}/platform-tools/adb"
4+
35
android {
46
compileSdkVersion 26
57
buildToolsVersion "26.0.1"
@@ -25,6 +27,38 @@ android {
2527
}
2628
}
2729

30+
31+
android.applicationVariants.all { variant ->
32+
variant.getCompileConfiguration().resolutionStrategy {
33+
if (variant.install != null) {
34+
variant.install.doLast {
35+
println "Running app..."
36+
exec {
37+
executable = ADB_PATH
38+
args = ['shell', "am start -n ${variant.applicationId}/.SettingsActivity"]
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
task debugWechat(dependsOn: "installDebug") {
46+
doLast {
47+
println "Stop WeChat..."
48+
exec {
49+
executable = ADB_PATH
50+
args = ['shell', "am force-stop com.tencent.mm"]
51+
}
52+
println "Start WeChat..."
53+
exec {
54+
executable = ADB_PATH
55+
args = ['shell', "am start -n com.tencent.mm/com.tencent.mm.ui.LauncherUI"]
56+
}
57+
58+
}
59+
}
60+
61+
2862
dependencies {
2963
implementation 'com.android.support:support-v4:26.0.2'
3064
implementation 'com.wei.android.lib:fingerprintidentify:1.2.1'
Lines changed: 10 additions & 173 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,8 @@
11
package com.yyxx.wechatfp;
22

33
import android.annotation.TargetApi;
4-
import android.app.Activity;
4+
import android.app.Application;
55
import android.content.Context;
6-
import android.content.SharedPreferences;
7-
import android.content.pm.PackageInfo;
8-
import android.os.Bundle;
9-
import android.provider.Settings;
10-
import android.view.View;
11-
import android.widget.EditText;
12-
import android.widget.ImageView;
13-
import android.widget.RelativeLayout;
14-
import android.widget.TextView;
15-
import android.widget.Toast;
16-
17-
import com.wei.android.lib.fingerprintidentify.FingerprintIdentify;
18-
import com.wei.android.lib.fingerprintidentify.base.BaseFingerprint;
19-
import com.yyxx.wechatfp.ObfuscationHelper.MM_Classes;
20-
import com.yyxx.wechatfp.ObfuscationHelper.MM_Fields;
21-
import com.yyxx.wechatfp.ObfuscationHelper.MM_Res;
22-
import com.yyxx.wechatfp.Utils.AESHelper;
236

247
import de.robv.android.xposed.IXposedHookLoadPackage;
258
import de.robv.android.xposed.IXposedHookZygoteInit;
@@ -30,170 +13,24 @@
3013

3114

3215
public class WalletBaseUI implements IXposedHookZygoteInit, IXposedHookLoadPackage {
33-
private static Activity mWalletPayUIActivity;
34-
private static EditText mInputEditText;
35-
private RelativeLayout mPasswordLayout;
36-
private ImageView mFingerprintImageView;
37-
private RelativeLayout mFingerPrintLayout;
38-
private TextView mPayTitleTextView, mPasswordTextView;
39-
private static FingerprintIdentify mFingerprintIdentify;
40-
private static boolean mNeedFingerprint;
16+
4117
public static final String WECHAT_PACKAGENAME = "com.tencent.mm";
4218

4319
public void initZygote(StartupParam startupParam) throws Throwable {
4420
}
4521

4622
@Override
47-
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
48-
XposedBridge.log("loaded: [" + lpparam.packageName + "]");
23+
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
4924
if (lpparam.packageName.equals(WECHAT_PACKAGENAME)) {
50-
try {
51-
final Context context = (Context) XposedHelpers.callMethod(XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ActivityThread", null), "currentActivityThread", new Object[0]), "getSystemContext", new Object[0]);
52-
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(WECHAT_PACKAGENAME, 0);
53-
int versionCode = packageInfo.versionCode;
54-
String versionName = packageInfo.versionName;
55-
boolean isVersionSupported = ObfuscationHelper.init(versionCode, versionName, lpparam);
56-
if (!isVersionSupported) {
57-
Toast.makeText(context, "当前版本:" + versionName + "." + versionCode + "不支持", Toast.LENGTH_LONG).show();
58-
XposedBridge.log("当前版本:" + versionName + "." + versionCode + "不支持");
59-
return;
60-
}
61-
62-
63-
XposedHelpers.findAndHookMethod(MM_Classes.PayUI, "onCreate", Bundle.class, new XC_MethodHook() {
64-
@TargetApi(21)
65-
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
66-
mWalletPayUIActivity = (Activity) param.thisObject;
67-
mNeedFingerprint = true;
68-
}
69-
});
70-
XposedHelpers.findAndHookMethod(MM_Classes.FetchUI, "onCreate", Bundle.class, new XC_MethodHook() {
71-
@TargetApi(21)
72-
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
73-
mWalletPayUIActivity = (Activity) param.thisObject;
74-
mNeedFingerprint = true;
75-
}
76-
});
77-
XposedHelpers.findAndHookConstructor(MM_Classes.Payview, Context.class, new XC_MethodHook() {
78-
@TargetApi(21)
79-
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
80-
SharedPreferences xmodPrefs = XPreferenceProvider.getRemoteSharedPreference(context);
81-
XposedBridge.log("设置数量" + String.valueOf(xmodPrefs.getAll().size()));
82-
boolean fingerPrintEnabled = xmodPrefs.getBoolean("enable_fp", false);
83-
XposedBridge.log("fingerPrintEnabled:" + fingerPrintEnabled);
84-
85-
if (fingerPrintEnabled && mNeedFingerprint && mWalletPayUIActivity != null) {
86-
initFingerPrintLock();
87-
mPasswordLayout = (RelativeLayout) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PaypwdView);
88-
mInputEditText = (EditText) XposedHelpers.getObjectField(mPasswordLayout, MM_Fields.PaypwdEditText);
89-
XposedBridge.log("密码输入框:" + mInputEditText.getClass().getName());
90-
mInputEditText.setVisibility(View.GONE);
91-
mPayTitleTextView = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayTitle);
92-
mPayTitleTextView.setText(MM_Res.Finger_title);
93-
final View mKeyboard = (View) XposedHelpers.getObjectField(param.thisObject, MM_Fields.PayInputView);
94-
XposedBridge.log("密码键盘:" + mKeyboard.getClass().getName());
95-
mKeyboard.setVisibility(View.GONE);
96-
mFingerPrintLayout = new RelativeLayout(mWalletPayUIActivity);
97-
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
98-
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
99-
mFingerPrintLayout.setLayoutParams(layoutParams);
100-
mFingerprintImageView = new ImageView(mWalletPayUIActivity);
101-
mFingerprintImageView.setImageResource(MM_Res.Finger_icon);
102-
mFingerPrintLayout.addView(mFingerprintImageView);
103-
mPasswordLayout.addView(mFingerPrintLayout);
104-
mFingerprintImageView.setOnClickListener(new View.OnClickListener() {
105-
@Override
106-
public void onClick(View view) {
107-
mPasswordLayout.removeView(mFingerPrintLayout);
108-
mInputEditText.setVisibility(View.VISIBLE);
109-
mKeyboard.setVisibility(View.VISIBLE);
110-
mFingerprintIdentify.cancelIdentify();
111-
mPayTitleTextView.setText(MM_Res.passwd_title);
112-
}
113-
});
114-
mPasswordTextView = (TextView) XposedHelpers.getObjectField(param.thisObject, MM_Fields.Passwd_Text);
115-
mPasswordTextView.setVisibility(View.VISIBLE);
116-
mPasswordTextView.setOnClickListener(new View.OnClickListener() {
117-
@Override
118-
public void onClick(View view) {
119-
mPasswordLayout.removeView(mFingerPrintLayout);
120-
mInputEditText.setVisibility(View.VISIBLE);
121-
mKeyboard.setVisibility(View.VISIBLE);
122-
mFingerprintIdentify.cancelIdentify();
123-
mPayTitleTextView.setText(MM_Res.passwd_title);
124-
}
125-
});
126-
} else {
127-
128-
}
129-
}
130-
});
131-
XposedHelpers.findAndHookMethod(MM_Classes.Payview, "dismiss", new XC_MethodHook() {
132-
@TargetApi(21)
133-
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
134-
XposedBridge.log(new Exception());
135-
if (mWalletPayUIActivity != null) {
136-
mFingerprintIdentify.cancelIdentify();
137-
mWalletPayUIActivity = null;
138-
mNeedFingerprint = false;
139-
}
140-
}
141-
});
142-
} catch (Throwable l) {
143-
XposedBridge.log(l);
144-
}
145-
}
146-
}
147-
148-
public static void initFingerPrintLock() {
149-
mFingerprintIdentify = new FingerprintIdentify(mWalletPayUIActivity);
150-
if (mFingerprintIdentify.isFingerprintEnable()) {
151-
mFingerprintIdentify.startIdentify(3, new BaseFingerprint.FingerprintIdentifyListener() {
152-
@Override
153-
public void onSucceed() {
154-
// 验证成功,自动结束指纹识别
155-
Toast.makeText(mWalletPayUIActivity, "指纹识别成功", Toast.LENGTH_SHORT).show();
156-
onSuccessUnlock(mWalletPayUIActivity);
157-
}
158-
159-
@Override
160-
public void onNotMatch(int availableTimes) {
161-
// 指纹不匹配,并返回可用剩余次数并自动继续验证
162-
Toast.makeText(mWalletPayUIActivity, "指纹识别失败,还可尝试" + String.valueOf(availableTimes) + "次", Toast.LENGTH_SHORT).show();
163-
}
164-
165-
@Override
166-
public void onFailed(boolean isDeviceLocked) {
167-
// 错误次数达到上限或者API报错停止了验证,自动结束指纹识别
168-
// isDeviceLocked 表示指纹硬件是否被暂时锁定
169-
Toast.makeText(mWalletPayUIActivity, "多次尝试错误,请确认指纹", Toast.LENGTH_SHORT).show();
170-
}
171-
172-
@Override
173-
public void onStartFailedByDeviceLocked() {
174-
// 第一次调用startIdentify失败,因为设备被暂时锁定
175-
Toast.makeText(mWalletPayUIActivity, "系统限制,重启后必须验证密码后才能使用指纹验证", Toast.LENGTH_SHORT).show();
25+
XposedBridge.log("loaded: [" + lpparam.packageName + "]" + " version:" + BuildConfig.VERSION_NAME);
26+
XposedHelpers.findAndHookMethod(Application.class, "onCreate", new XC_MethodHook() {
27+
@TargetApi(21)
28+
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
29+
XposedBridge.log("Application onCreate");
30+
Context context = (Context) param.thisObject;
31+
XposedPluginLoader.load(XposedPlugin.class, context, lpparam);
17632
}
17733
});
17834
}
17935
}
180-
181-
private static void onSuccessUnlock(Context context) {
182-
String pwd;
183-
String ANDROID_ID = Settings.System.getString(mWalletPayUIActivity.getContentResolver(), Settings.System.ANDROID_ID);
184-
185-
SharedPreferences xmodPrefs = XPreferenceProvider.getRemoteSharedPreference(context);
186-
XposedBridge.log("设置数量" + String.valueOf(xmodPrefs.getAll().size()));
187-
if (xmodPrefs.getAll().size() > 0) {
188-
pwd = xmodPrefs.getString("paypwd", "");
189-
} else {
190-
pwd = "";
191-
}
192-
if (pwd.length() > 0) {
193-
mInputEditText.setText(AESHelper.decrypt(pwd, ANDROID_ID));
194-
} else {
195-
Toast.makeText(mWalletPayUIActivity, "未设定支付密码,请在WechatFp中设定微信的支付密码", Toast.LENGTH_SHORT).show();
196-
}
197-
198-
}
19936
}

0 commit comments

Comments
 (0)