Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Jul 3, 2023
1 parent 881f431 commit 4018697
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 41 deletions.
6 changes: 6 additions & 0 deletions .idea/codeStyles/Project.xml

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

1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

4 changes: 1 addition & 3 deletions .idea/misc.xml

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

10 changes: 7 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ android {
namespace 'com.chrxw.purenga'
compileSdk 33

buildFeatures {
buildConfig = true
}

defaultConfig {
applicationId "com.chrxw.purenga"
minSdk 24
targetSdk 33
versionCode 4
versionName "1.2.0"
versionCode 5
versionName "1.3.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
proguardFiles
Expand All @@ -29,7 +33,7 @@ android {
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = '11'
}
buildToolsVersion '31.0.0'
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/chrxw/purenga/XposedInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package com.chrxw.purenga

import android.content.res.Resources
import android.content.res.XModuleResources
import com.chrxw.purenga.hook.VipHook
import com.chrxw.purenga.hook.BaseHook
import com.chrxw.purenga.hook.RewardHook
import com.chrxw.purenga.hook.SplashHook
import com.chrxw.purenga.utils.Log
import de.robv.android.xposed.*
import de.robv.android.xposed.callbacks.XC_LoadPackage
import java.text.MessageFormat

/**
* 初始化Xposed
Expand Down Expand Up @@ -37,12 +39,13 @@ class XposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {
Log.d("NGA内运行" + lpparam.packageName)
startHook(SplashHook(lpparam.classLoader))
startHook(RewardHook(lpparam.classLoader))
startHook(VipHook(lpparam.classLoader))
}
}

private fun startHook(hooker: BaseHook) {
try {
Log.i(hooker::class.java.name + " start")
Log.i(MessageFormat.format("Hook {0} Start", hooker::class.java.name))
hooker.startHook()
} catch (e: Throwable) {
Log.e(e)
Expand Down
69 changes: 69 additions & 0 deletions app/src/main/java/com/chrxw/purenga/hook/AdHook.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.chrxw.purenga.hook

import com.chrxw.purenga.utils.Log
import de.robv.android.xposed.XC_MethodReplacement
import de.robv.android.xposed.XposedHelpers


/**
* 广告钩子
*/
class AdHook(classLoader: ClassLoader) : BaseHook(classLoader) {
override fun startHook() {
try {
val clsB = XposedHelpers.findClass(
"com.nga.admodule.AdManager\$b",
mClassLoader
)
XposedHelpers.findAndHookMethod(
clsB,
"onAdLoad",
object : XC_MethodReplacement() {
@Throws(Throwable::class)
override fun replaceHookedMethod(param: MethodHookParam) {
Log.i("onAdLoad ")
}
}
)
XposedHelpers.findAndHookMethod(
clsB,
"onAdShow",
object : XC_MethodReplacement() {
@Throws(Throwable::class)
override fun replaceHookedMethod(param: MethodHookParam) {
Log.i("onAdShow ")
}
}
)

val clsD = XposedHelpers.findClass(
"com.nga.admodule.AdManager\$d",
mClassLoader
)
XposedHelpers.findAndHookMethod(
clsD,
"onAdLoad",
object : XC_MethodReplacement() {
@Throws(Throwable::class)
override fun replaceHookedMethod(param: MethodHookParam) {
Log.i("onAdLoad ")
}
}
)
XposedHelpers.findAndHookMethod(
clsD,
"onAdShow",
object : XC_MethodReplacement() {
@Throws(Throwable::class)
override fun replaceHookedMethod(param: MethodHookParam) {
Log.i("onAdShow ")
}
}
)


} catch (e: Exception) {
Log.e(e)
}
}
}
19 changes: 6 additions & 13 deletions app/src/main/java/com/chrxw/purenga/hook/RewardHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ import de.robv.android.xposed.XposedHelpers
class RewardHook(classLoader: ClassLoader) : BaseHook(classLoader) {
override fun startHook() {
try {
// 获取LoginWebView.b类实例
val clsNamelessB = XposedHelpers.findClass(
"gov.pianzong.androidnga.activity.user.LoginWebView.b",
mClassLoader
)
// Hook onRewardVerify 方法
XposedHelpers.findAndHookMethod(
clsNamelessB,
"gov.pianzong.androidnga.activity.user.LoginWebView.b",
mClassLoader,
"onAdShow",
object : XC_MethodReplacement() {
@Throws(Throwable::class)
Expand All @@ -37,14 +33,10 @@ class RewardHook(classLoader: ClassLoader) : BaseHook(classLoader) {
}
})

// 获取LoginWebView.a类实例
val clsNamelessA = XposedHelpers.findClass(
"gov.pianzong.androidnga.activity.user.LoginWebView.a",
mClassLoader
)
// Hook onRewardVerify 方法
XposedHelpers.findAndHookMethod(
clsNamelessA,
"gov.pianzong.androidnga.activity.user.LoginWebView.a",
mClassLoader,
"onAdShow",
object : XC_MethodReplacement() {
@Throws(Throwable::class)
Expand All @@ -53,7 +45,8 @@ class RewardHook(classLoader: ClassLoader) : BaseHook(classLoader) {
val obj = param?.thisObject

val webView = XposedHelpers.getObjectField(obj, "a")
onAdClose(webView)
XposedHelpers.setBooleanField(webView, "mFreeRewardVerify", true)
XposedHelpers.callMethod(obj, "onAdClose")

// XposedHelpers.setBooleanField(webView, "mFreeRewardVerify", true)
// XposedHelpers.callMethod(obj, "onAdClose")
Expand Down
21 changes: 7 additions & 14 deletions app/src/main/java/com/chrxw/purenga/hook/SplashHook.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.chrxw.purenga.hook

import android.app.Activity
import com.chrxw.purenga.BuildConfig
import com.chrxw.purenga.utils.Log
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
Expand All @@ -12,19 +13,15 @@ class SplashHook(classLoader: ClassLoader) : BaseHook(classLoader) {

override fun startHook() {
try {
// 获取ActivityLifecycleImpl类
val clsLifeCycle = XposedHelpers.findClass(
"com.donews.nga.interfaces.ActivityLifecycleImpl",
mClassLoader
)
// 获取LoadingActivity类
val clsLoadingActivity = XposedHelpers.findClass(
"gov.pianzong.androidnga.activity.LoadingActivity",
mClassLoader
)
// Hook toForeGround 方法
XposedHelpers.findAndHookMethod(
clsLifeCycle,
"com.donews.nga.interfaces.ActivityLifecycleImpl",
mClassLoader,
"toForeGround",
Activity::class.java,
object : XC_MethodHook() {
Expand All @@ -39,15 +36,14 @@ class SplashHook(classLoader: ClassLoader) : BaseHook(classLoader) {
XposedHelpers.setBooleanField(activity, "isADShow", true)
XposedHelpers.callMethod(activity, "goHome")
}
Log.d(activity.toString())
//Log.d(activity.toString())
}
})
// 获取SPUtil类
val clsSPUtil =
XposedHelpers.findClass("com.donews.nga.common.utils.SPUtil", mClassLoader)

// 修改时间戳实现切屏无广告
XposedHelpers.findAndHookMethod(
clsSPUtil,
"com.donews.nga.common.utils.SPUtil",
mClassLoader,
"getInt",
String::class.java,
Int::class.java,
Expand All @@ -63,9 +59,6 @@ class SplashHook(classLoader: ClassLoader) : BaseHook(classLoader) {
Log.d("BG " + param.result.toString())
param.result = 0
}
else -> {
// Log.d(param.args[0].toString() + " " + param.result.toString())
}
}
}
})
Expand Down
58 changes: 58 additions & 0 deletions app/src/main/java/com/chrxw/purenga/hook/VipHook.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.chrxw.purenga.hook

import com.chrxw.purenga.utils.Log
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers

/**
* Vip钩子
*/
class VipHook(classLoader: ClassLoader) : BaseHook(classLoader) {
override fun startHook() {
try {
// Hook getIsVip 方法
XposedHelpers.findAndHookMethod(
"com.donews.nga.vip.entitys.VipStatus",
mClassLoader,
"getIsVip",
object : XC_MethodHook() {
@Throws(Throwable::class)
override fun beforeHookedMethod(param: MethodHookParam?) {
Log.d("getIsVip")
super.beforeHookedMethod(param)
}

@Throws(Throwable::class)
override fun afterHookedMethod(param: MethodHookParam?) {
Log.d("getIsVip " + param?.result.toString())
param?.result = true
super.afterHookedMethod(param)
}
}
)

XposedHelpers.findAndHookMethod(
"gov.pianzong.androidnga.model.UserInfoDataBean",
mClassLoader,
"getAdfree",
object : XC_MethodHook() {
@Throws(Throwable::class)
override fun beforeHookedMethod(param: MethodHookParam) {
Log.d("getAdfree")
super.beforeHookedMethod(param)
}

@Throws(Throwable::class)
override fun afterHookedMethod(param: MethodHookParam) {
Log.d("getAdfree " + param.result.toString())
super.afterHookedMethod(param)
}
}
)


} catch (e: Exception) {
Log.e(e)
}
}
}
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'com.android.application' version '8.0.2' apply false
id 'org.jetbrains.kotlin.android' version '1.7.21' apply false
}
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Jan 19 10:26:43 CST 2023
#Mon Jul 03 10:04:11 CST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 4018697

Please sign in to comment.