Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Chion82 committed Feb 17, 2016
0 parents commit 0e0914e
Show file tree
Hide file tree
Showing 43 changed files with 1,348 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
26 changes: 26 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "moe.chionlab.wechatmomentstat"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
Binary file added app/libs/XposedBridgeApi.jar
Binary file not shown.
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/chiontang/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package moe.chionlab.wechatmomentstat;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
33 changes: 33 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="moe.chionlab.wechatmomentstat">

<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="xposedmodule"
android:value="true" />
<meta-data
android:name="xposedminversion"
android:value="30" />
<meta-data
android:name="xposeddescription"
android:value="Export WeChat moments and get statistics." />

<activity android:name=".gui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>
1 change: 1 addition & 0 deletions app/src/main/assets/xposed_init
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
moe.chionlab.wechatmomentstat.Main
85 changes: 85 additions & 0 deletions app/src/main/java/moe/chionlab/wechatmomentstat/Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package moe.chionlab.wechatmomentstat;

import android.os.Environment;

/**
* Created by chiontang on 2/4/16.
*/
public class Config {

static boolean ready = false;

final static public String EXT_DIR = Environment.getExternalStorageDirectory() + "/WeChatMomentStat";
final static public String DATA_DIR = Environment.getDataDirectory() + "/data/moe.chionlab.wechatmomentstat";

final static public String WECHAT_PACKAGE = "com.tencent.mm";

final static String[] VERSIONS = {"6.3.13.49_r4080b63", "6.3.13.64_r4488992"};
final static String[] PROTOCAL_SNS_DETAIL_CLASSES = {"com.tencent.mm.protocal.b.atp", "com.tencent.mm.protocal.b.atp"};
final static String[] PROTOCAL_SNS_DETAIL_METHODS = {"a", "a"};
final static String[] SNS_XML_GENERATOR_CLASSES = {"com.tencent.mm.plugin.sns.f.i", "com.tencent.mm.plugin.sns.f.i"};
final static String[] SNS_XML_GENERATOR_METHODS = {"a", "a"};
final static String[] PROTOCAL_SNS_OBJECT_CLASSES = {"com.tencent.mm.protocal.b.aqi", "com.tencent.mm.protocal.b.aqi"};
final static String[] PROTOCAL_SNS_OBJECT_METHODS = {"a", "a"};
final static String[] PROTOCAL_SNS_OBJECT_USERID_FIELDS = {"iYA", "iYA"};
final static String[] PROTOCAL_SNS_OBJECT_NICKNAME_FIELDS = {"jyd", "jyd"};
final static String[] PROTOCAL_SNS_OBJECT_TIMESTAMP_FIELDS = {"fpL", "fpL"};
final static String[] PROTOCAL_SNS_OBJECT_COMMENTS_FIELDS = {"jJX", "jJX"};
final static String[] PROTOCAL_SNS_OBJECT_LIKES_FIELDS = {"jJU", "jJU"};
final static String[] SNS_OBJECT_EXT_AUTHOR_NAME_FIELDS = {"jyd", "jyd"};
final static String[] SNS_OBJECT_EXT_REPLY_TO_FIELDS = {"jJM", "jJM"};
final static String[] SNS_OBJECT_EXT_COMMENT_FIELDS = {"fsI", "fsI"};
final static String[] SNS_OBJECT_EXT_AUTHOR_ID_FIELDS = {"iYA", "iYA"};
final static String[] SNS_DETAIL_FROM_BIN_METHODS = {"am", "am"};
final static String[] SNS_OBJECT_FROM_BIN_METHODS = {"am", "am"};

static String PROTOCAL_SNS_DETAIL_CLASS;
static String PROTOCAL_SNS_DETAIL_METHOD;
static String SNS_XML_GENERATOR_CLASS;
static String SNS_XML_GENERATOR_METHOD;
static String PROTOCAL_SNS_OBJECT_CLASS;
static String PROTOCAL_SNS_OBJECT_METHOD;
static String PROTOCAL_SNS_OBJECT_USERID_FIELD;
static String PROTOCAL_SNS_OBJECT_NICKNAME_FIELD;
static String PROTOCAL_SNS_OBJECT_TIMESTAMP_FIELD;
static String PROTOCAL_SNS_OBJECT_COMMENTS_FIELD;
static String PROTOCAL_SNS_OBJECT_LIKES_FIELD;
static String SNS_OBJECT_EXT_AUTHOR_NAME_FIELD;
static String SNS_OBJECT_EXT_REPLY_TO_FIELD;
static String SNS_OBJECT_EXT_COMMENT_FIELD;
static String SNS_OBJECT_EXT_AUTHOR_ID_FIELD;
static String SNS_DETAIL_FROM_BIN_METHOD;
static String SNS_OBJECT_FROM_BIN_METHOD;

static public void initWeChatVersion(String version) {
for (int i=0;i<VERSIONS.length;i++) {
if (VERSIONS[i].equals(version)) {
Config.setConstants(i);
Config.ready = true;
return;
}
}
Config.ready = false;
}

static private void setConstants(int index) {
PROTOCAL_SNS_DETAIL_CLASS = PROTOCAL_SNS_DETAIL_CLASSES[index];
PROTOCAL_SNS_DETAIL_METHOD = PROTOCAL_SNS_DETAIL_METHODS[index];
SNS_XML_GENERATOR_CLASS = SNS_XML_GENERATOR_CLASSES[index];
SNS_XML_GENERATOR_METHOD = SNS_XML_GENERATOR_METHODS[index];
PROTOCAL_SNS_OBJECT_CLASS = PROTOCAL_SNS_OBJECT_CLASSES[index];
PROTOCAL_SNS_OBJECT_METHOD = PROTOCAL_SNS_OBJECT_METHODS[index];
PROTOCAL_SNS_OBJECT_USERID_FIELD = PROTOCAL_SNS_OBJECT_USERID_FIELDS[index];
PROTOCAL_SNS_OBJECT_NICKNAME_FIELD = PROTOCAL_SNS_OBJECT_NICKNAME_FIELDS[index];
PROTOCAL_SNS_OBJECT_TIMESTAMP_FIELD = PROTOCAL_SNS_OBJECT_TIMESTAMP_FIELDS[index];
PROTOCAL_SNS_OBJECT_COMMENTS_FIELD = PROTOCAL_SNS_OBJECT_COMMENTS_FIELDS[index];
PROTOCAL_SNS_OBJECT_LIKES_FIELD = PROTOCAL_SNS_OBJECT_LIKES_FIELDS[index];
SNS_OBJECT_EXT_AUTHOR_NAME_FIELD = SNS_OBJECT_EXT_AUTHOR_NAME_FIELDS[index];
SNS_OBJECT_EXT_REPLY_TO_FIELD = SNS_OBJECT_EXT_REPLY_TO_FIELDS[index];
SNS_OBJECT_EXT_COMMENT_FIELD = SNS_OBJECT_EXT_COMMENT_FIELDS[index];
SNS_OBJECT_EXT_AUTHOR_ID_FIELD = SNS_OBJECT_EXT_AUTHOR_ID_FIELDS[index];
SNS_DETAIL_FROM_BIN_METHOD = SNS_DETAIL_FROM_BIN_METHODS[index];
SNS_OBJECT_FROM_BIN_METHOD = SNS_OBJECT_FROM_BIN_METHODS[index];
}

}
61 changes: 61 additions & 0 deletions app/src/main/java/moe/chionlab/wechatmomentstat/Hook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package moe.chionlab.wechatmomentstat;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageInfo;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

/**
* Created by chiontang on 2/11/16.
*/
public class Hook {

Class SnsDetail = null;
Class SnsDetailParser = null;
Class SnsObject = null;

Context wechatContext = null;

XC_LoadPackage.LoadPackageParam lpparam = null;
XC_MethodHook.MethodHookParam param = null;

SnsReader bgTask = null;

Hook(XC_LoadPackage.LoadPackageParam lpparam, XC_MethodHook.MethodHookParam param) {
this.lpparam = lpparam;
this.param = param;
}

public void initHook() throws Throwable {
initWeChatVersion(param.thisObject, "com.tencent.mm");
if (!Config.ready) {
XposedBridge.log("Unsupported WeChat version.");
return;
}
getClasses(lpparam.classLoader);
SnsReader snsReader = new SnsReader(SnsDetail, SnsDetailParser, SnsObject);
snsReader.run();
}

protected void initWeChatVersion(Object wechatActivity, String packageName) throws Throwable{
XposedBridge.log("LauncherUI hooked.");
Context appContext = ((Activity)wechatActivity).getApplicationContext();
wechatContext = appContext;
PackageInfo pInfo = appContext.getPackageManager().getPackageInfo(packageName, 0);
String wechatVersion = "";
if (pInfo != null)
wechatVersion = pInfo.versionName;
XposedBridge.log("WeChat version=" + wechatVersion);
Config.initWeChatVersion(wechatVersion);
}

protected void getClasses(ClassLoader classLoader) throws Throwable {
SnsDetailParser = XposedHelpers.findClass(Config.SNS_XML_GENERATOR_CLASS, classLoader);
SnsDetail = XposedHelpers.findClass(Config.PROTOCAL_SNS_DETAIL_CLASS, classLoader);
SnsObject = XposedHelpers.findClass(Config.PROTOCAL_SNS_OBJECT_CLASS, classLoader);
}

}
Loading

0 comments on commit 0e0914e

Please sign in to comment.