Skip to content

Commit

Permalink
首次提交
Browse files Browse the repository at this point in the history
首次提交
  • Loading branch information
su committed Feb 28, 2018
1 parent 4f97e34 commit 6e5201c
Show file tree
Hide file tree
Showing 24 changed files with 1,198 additions and 0 deletions.
29 changes: 29 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
maven {
url 'https://raw.githubusercontent.com/wuxiaosu/MvnRepository/master'
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
31 changes: 31 additions & 0 deletions fakebalance/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26

defaultConfig {
applicationId "com.wuxiaosu.fakebalance"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"

}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
provided 'de.robv.android.xposed:api:82'
implementation 'com.github.wuxiaosu:SettingLabelView:1.0@aar'
}
21 changes: 21 additions & 0 deletions fakebalance/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
49 changes: 49 additions & 0 deletions fakebalance/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wuxiaosu.fakebalance">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter>
</activity>

<activity-alias
android:name=".MainActivity_Alias"
android:enabled="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:targetActivity=".MainActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity-alias>

<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposeddescription"
android:value="@string/app_description" />
<meta-data
android:name="xposedminversion"
android:value="30" />

</application>

</manifest>
1 change: 1 addition & 0 deletions fakebalance/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.wuxiaosu.fakebalance.Main
116 changes: 116 additions & 0 deletions fakebalance/src/main/java/com/wuxiaosu/fakebalance/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package com.wuxiaosu.fakebalance;

import android.app.Application;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;

import com.wuxiaosu.fakebalance.hook.AliPayHook;
import com.wuxiaosu.fakebalance.hook.TimHook;
import com.wuxiaosu.fakebalance.hook.WeChatHook;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import dalvik.system.BaseDexClassLoader;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

/**
* Created by su on 2017/12/29.
*/

public class Main implements IXposedHookLoadPackage {

private static final String ALIPAY_PKG_NAME = "com.eg.android.AlipayGphone";
private static final String TIM_PKG_NAME = "com.tencent.tim";
private static final String WECHAT_PKG_NAME = "com.tencent.mm";

private String alipayVersionName;
private String timVersionName;
private String wechatVersionName;

private static List<String> pkgList = new ArrayList<>();

static {
pkgList.add(ALIPAY_PKG_NAME);
pkgList.add(TIM_PKG_NAME);
pkgList.add(WECHAT_PKG_NAME);
}

@Override
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

if (lpparam.appInfo == null || (lpparam.appInfo.flags & (ApplicationInfo.FLAG_SYSTEM |
ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0) {
return;
}
final String packageName = lpparam.packageName;

if (packageName.equals(BuildConfig.APPLICATION_ID)) {
XposedHelpers.findAndHookMethod(BuildConfig.APPLICATION_ID + ".MainActivity", lpparam.classLoader,
"isModuleActive", XC_MethodReplacement.returnConstant(true));
return;
}

if (pkgList.contains(packageName)) {
XposedHelpers.findAndHookMethod(Application.class,
"attach",
Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
Context context = (Context) param.args[0];
ClassLoader appClassLoader = context.getClassLoader();

initVersionName(context);

if (packageName.endsWith(ALIPAY_PKG_NAME)) {
new AliPayHook(alipayVersionName).hook(appClassLoader);
} else if (packageName.endsWith(WECHAT_PKG_NAME)) {
new WeChatHook(wechatVersionName).hook(appClassLoader);
}
}
});

if (packageName.equals(TIM_PKG_NAME)) {
XposedHelpers.findAndHookConstructor("dalvik.system.BaseDexClassLoader",
lpparam.classLoader, String.class, File.class, String.class, ClassLoader.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) throws Throwable {

if (param.args[0].toString().contains("qwallet_plugin.apk")) {
ClassLoader classLoader = (BaseDexClassLoader) param.thisObject;
new TimHook(timVersionName).hook(classLoader);
}
}
});
}
}
}

private void initVersionName(Context context) {
alipayVersionName = getVersionName(context, ALIPAY_PKG_NAME);
timVersionName = getVersionName(context, TIM_PKG_NAME);
wechatVersionName = getVersionName(context, WECHAT_PKG_NAME);
}

private String getVersionName(Context context, String pkgName) {
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packInfo = packageManager.getPackageInfo(pkgName, 0);
return packInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return "";
}
}
Loading

0 comments on commit 6e5201c

Please sign in to comment.