Skip to content

Commit 3c11569

Browse files
authored
Merge pull request #38 from LuckyPray/servlet
Servlet
2 parents 9996fb1 + 7baf313 commit 3c11569

File tree

19 files changed

+492
-75
lines changed

19 files changed

+492
-75
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android {
2121
//noinspection OldTargetApi
2222
targetSdkVersion 31
2323
versionCode mVersionCode
24-
versionName "3.0.5"
24+
versionName "3.0.6"
2525

2626
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2727

app/src/main/java/me/teble/xposed/autodaily/hook/BugHook.kt

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
11
package me.teble.xposed.autodaily.hook
22

3+
import android.os.Build
4+
import androidx.annotation.RequiresApi
35
import com.github.kyuubiran.ezxhelper.utils.findMethod
6+
import com.github.kyuubiran.ezxhelper.utils.hookAfter
47
import com.github.kyuubiran.ezxhelper.utils.hookReplace
8+
import com.tencent.qphone.base.remote.ToServiceMsg
9+
import de.robv.android.xposed.XC_MethodHook
510
import de.robv.android.xposed.XposedBridge
611
import me.teble.xposed.autodaily.config.PACKAGE_NAME_QQ
712
import me.teble.xposed.autodaily.hook.annotation.MethodHook
813
import me.teble.xposed.autodaily.hook.base.BaseHook
914
import me.teble.xposed.autodaily.hook.base.ProcUtil
1015
import me.teble.xposed.autodaily.hook.base.hostPackageName
1116
import me.teble.xposed.autodaily.hook.base.load
17+
import me.teble.xposed.autodaily.hook.servlets.FavoriteServlet
18+
import me.teble.xposed.autodaily.utils.LogUtil
1219
import me.teble.xposed.autodaily.utils.new
20+
import me.teble.xposed.autodaily.utils.toMap
21+
import mqq.app.MSFServlet
22+
import mqq.app.MainService
23+
import mqq.app.NewIntent
1324

14-
class BugHook: BaseHook() {
25+
class BugHook : BaseHook() {
1526

1627
override val isCompatible: Boolean
1728
get() = ProcUtil.isMain && hostPackageName == PACKAGE_NAME_QQ
1829
override val enabled: Boolean
19-
get() = true
30+
get() = false
2031

2132

2233
@MethodHook("fuck No value for gdt_report_list")
@@ -36,4 +47,55 @@ class BugHook: BaseHook() {
3647
}
3748
}
3849
}
50+
51+
@RequiresApi(Build.VERSION_CODES.O)
52+
@MethodHook("测试")
53+
fun test() {
54+
kotlin.runCatching {
55+
findMethod(MainService::class.java) {
56+
name == "sendMessageToMSF"
57+
}.hookAfter {
58+
val toServiceMsg = it.args[0] as? ToServiceMsg ?: return@hookAfter
59+
val servlet = it.args[1] as? MSFServlet ?: return@hookAfter
60+
if (toServiceMsg.serviceCmd.startsWith("OidbSvc.0xeb7")) {
61+
LogUtil.d("sendMessageToMSF: " + servlet::class.java.name)
62+
LogUtil.d(toServiceMsg.appSeq.toString())
63+
LogUtil.d(toServiceMsg.serviceCmd)
64+
LogUtil.d(toServiceMsg.toString())
65+
LogUtil.d(toServiceMsg.extraData.toMap().toString())
66+
LogUtil.printStackTrace()
67+
}
68+
}
69+
}.onFailure { LogUtil.e(it) }
70+
71+
kotlin.runCatching {
72+
findMethod("mqq.app.AppRuntime") {
73+
name == "startServlet"
74+
}.hookAfter {
75+
val newIntent = it.args[0] as NewIntent
76+
if (newIntent.component?.className == "com.tencent.mobileqq.x.a" ||
77+
newIntent.component?.className == FavoriteServlet::class.java.name) {
78+
val toServiceMsg = newIntent.getParcelableExtra<ToServiceMsg>("ToServiceMsg")
79+
toServiceMsg?.let {
80+
if (it.serviceCmd.startsWith("OidbSvc.0xeb7")) {
81+
LogUtil.d("startServlet: " + it.serviceCmd)
82+
LogUtil.d(it.toString())
83+
LogUtil.d(it.extraData.toMap().toString())
84+
LogUtil.printStackTrace()
85+
}
86+
}
87+
}
88+
}
89+
}
90+
91+
kotlin.runCatching {
92+
XposedBridge.hookAllConstructors(load("Lcom/tencent/mobileqq/troop/d/b/a;"),
93+
object : XC_MethodHook() {
94+
override fun afterHookedMethod(param: MethodHookParam?) {
95+
LogUtil.d("Lcom/tencent/mobileqq/troop/d/b/a;-><init>")
96+
LogUtil.printStackTrace()
97+
}
98+
})
99+
}
100+
}
39101
}

app/src/main/java/me/teble/xposed/autodaily/hook/MainHook.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import me.teble.xposed.autodaily.hook.config.Config.hooksVersion
2929
import me.teble.xposed.autodaily.hook.enums.QQTypeEnum
3030
import me.teble.xposed.autodaily.hook.proxy.ProxyManager
3131
import me.teble.xposed.autodaily.hook.proxy.activity.injectRes
32+
import me.teble.xposed.autodaily.hook.servlets.ServletPool
3233
import me.teble.xposed.autodaily.hook.utils.ToastUtil
3334
import me.teble.xposed.autodaily.task.util.ConfigUtil
3435
import me.teble.xposed.autodaily.utils.LogUtil
@@ -180,8 +181,8 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
180181
}
181182

182183
private fun doInit() {
183-
val encumberStep = NewRuntime
184-
findMethod(encumberStep) { returnType == Boolean::class.java && emptyParam }.hookAfter {
184+
val mNewRuntime = findMethod(NewRuntime) { returnType == Boolean::class.java && emptyParam }
185+
mNewRuntime.hookAfter {
185186
runCatching {
186187
if (hookIsInit) {
187188
return@hookAfter
@@ -196,6 +197,11 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
196197
ToastUtil.send("初始化失败: " + it.stackTraceToString())
197198
}
198199
}
200+
mNewRuntime.hookBefore {
201+
runCatching {
202+
ServletPool.injectServlet()
203+
}.onFailure { LogUtil.e(it) }
204+
}
199205
}
200206

201207
private fun doDexInit() {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package me.teble.xposed.autodaily.hook
2+
3+
import com.github.kyuubiran.ezxhelper.utils.findMethod
4+
import com.github.kyuubiran.ezxhelper.utils.hookReplace
5+
import de.robv.android.xposed.XposedBridge
6+
import me.teble.xposed.autodaily.BuildConfig
7+
import me.teble.xposed.autodaily.hook.annotation.MethodHook
8+
import me.teble.xposed.autodaily.hook.base.BaseHook
9+
import me.teble.xposed.autodaily.hook.base.ProcUtil
10+
import mqq.app.MSFServlet
11+
import mqq.app.MainService
12+
import java.util.concurrent.atomic.AtomicInteger
13+
14+
class MainServiceHook: BaseHook() {
15+
16+
override val isCompatible: Boolean
17+
get() = ProcUtil.isMain
18+
19+
override val enabled: Boolean
20+
get() = true
21+
22+
val id: AtomicInteger = AtomicInteger(0)
23+
24+
override fun init() {
25+
super.init()
26+
}
27+
28+
@MethodHook("receiveMessageFromMSF")
29+
fun receiveMessageFromMSF() {
30+
findMethod(MainService::class.java) {
31+
name == "receiveMessageFromMSF"
32+
}.hookReplace {
33+
val msfServlet = it.args[1] as MSFServlet
34+
if (!msfServlet::class.java.name.startsWith(BuildConfig.APPLICATION_ID)) {
35+
XposedBridge.invokeOriginalMethod(it.method, it.thisObject, it.args)
36+
}
37+
38+
return@hookReplace Unit
39+
}
40+
}
41+
42+
@MethodHook("sendMessageToMSF")
43+
fun sendMessageToMSF() {
44+
findMethod(MainService::class.java) {
45+
name == "sendMessageToMSF"
46+
}.hookReplace {
47+
return@hookReplace Unit
48+
}
49+
}
50+
}

app/src/main/java/me/teble/xposed/autodaily/hook/QLogHook.kt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package me.teble.xposed.autodaily.hook
22

3+
import android.util.Log
34
import com.github.kyuubiran.ezxhelper.utils.findMethod
45
import com.github.kyuubiran.ezxhelper.utils.hookReplace
56
import me.teble.xposed.autodaily.BuildConfig
67
import me.teble.xposed.autodaily.config.QLog
78
import me.teble.xposed.autodaily.hook.annotation.MethodHook
89
import me.teble.xposed.autodaily.hook.base.BaseHook
9-
import me.teble.xposed.autodaily.utils.LogUtil
1010

1111
class QLogHook : BaseHook() {
1212

@@ -17,11 +17,18 @@ class QLogHook : BaseHook() {
1717
get() = false
1818

1919
private val qTagFilter = setOf<String>(
20-
"PublicAccountManager",
21-
"reportsendMenuEventequest",
22-
"PublicAccountManager-Click:",
23-
"PublicAccountManager-Event:",
24-
"PublicAccountManager-Location:",
20+
// "PublicAccountManager",
21+
// "reportsendMenuEventequest",
22+
// "PublicAccountManager-Click:",
23+
// "PublicAccountManager-Event:",
24+
// "PublicAccountManager-Location:",
25+
"VisitorsActivity",
26+
"MobileQQServiceBase",
27+
"FaceInfo",
28+
"MsgRespHandler",
29+
"CardHandler",
30+
"MsgRespHandleReporter",
31+
"mqq"
2532
)
2633

2734
private fun containsTag(tag: String?): Boolean {
@@ -50,7 +57,7 @@ class QLogHook : BaseHook() {
5057
&& parameterTypes.contentEquals(arrayOf(String::class.java, Int::class.java, String::class.java, Throwable::class.java))
5158
}.hookReplace {
5259
if (qTagFilter.isEmpty() || containsTag(it.args[0] as String?)) {
53-
LogUtil.i("QTag: ${it.args[0]}, msg: ${it.args[2]}")
60+
Log.i("XALog", "QTag: ${it.args[0]}, msg: ${it.args[2]}")
5461
}
5562
return@hookReplace Unit
5663
}
@@ -63,7 +70,7 @@ class QLogHook : BaseHook() {
6370
&& parameterTypes.contentEquals(arrayOf(String::class.java, Int::class.java, String::class.java, Throwable::class.java))
6471
}.hookReplace {
6572
if (qTagFilter.isEmpty() || containsTag(it.args[0] as String?)) {
66-
LogUtil.i("QTag: ${it.args[0]}, msg: ${it.args[2]}")
73+
Log.i("XALog", "QTag: ${it.args[0]}, msg: ${it.args[2]}")
6774
}
6875
return@hookReplace Unit
6976
}

app/src/main/java/me/teble/xposed/autodaily/hook/QQSettingSettingActivityHook.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,48 @@ class QQSettingSettingActivityHook : BaseHook() {
5858
}
5959
}
6060
entity.setOnLongClickListener {
61+
// val cBaseService = load("com.tencent.mobileqq.service.MobileQQServiceBase")!!
62+
// lateinit var mRealHandleReq: Method
63+
// cBaseService.getMethods(false).forEach {
64+
// if (it.returnType == Void.TYPE && it.isPublic) {
65+
// val paramTypes = it.parameterTypes
66+
// if (paramTypes.size >= 2
67+
// && paramTypes.first() == ToServiceMsg::class.java
68+
// && paramTypes.last() == Class::class.java) {
69+
// mRealHandleReq = it
70+
// LogUtil.d(it.toString())
71+
// }
72+
// }
73+
// }
74+
// val toServiceMsg: ToServiceMsg = ToServiceMsg(
75+
// "mobileqq.service",
76+
// "${QApplicationUtil.currentUin}", "VisitorSvc.ReqFavorite"
77+
// ).apply {
78+
// appSeq = 1234
79+
// timeout = 10000L
80+
// extraData.putLong("selfUin", QApplicationUtil.currentUin)
81+
// extraData.putLong("targetUin", qq)
82+
// extraData.putByteArray("vCookies", null)
83+
// // 好友1,陌生人66 陌生人能突破非会员10次上限
84+
// extraData.putInt("favoriteSource", 66)
85+
// extraData.putInt("iCount", 1)
86+
// extraData.putInt("from", 0)
87+
// }
88+
// kotlin.runCatching {
89+
//
90+
// appInterface.getFields(false).forEach {
91+
// if (cBaseService.isAssignableFrom(it.type)) {
92+
// LogUtil.d(it.name)
93+
// it.isAccessible = true
94+
// val mqqService = it.get(appInterface)!!
95+
// if (mRealHandleReq.parameterTypes.size == 2) {
96+
// MethodHandleUtil.invokeSpecial<Unit>(mqqService, mRealHandleReq, toServiceMsg, FavoriteServlet::class.java)
97+
// } else {
98+
// MethodHandleUtil.invokeSpecial<Unit>(mqqService, mRealHandleReq, toServiceMsg, null, FavoriteServlet::class.java)
99+
// }
100+
// }
101+
// }
102+
// }.onFailure { LogUtil.e(it) }
61103
true
62104
}
63105
val id: Int = context.resources

app/src/main/java/me/teble/xposed/autodaily/hook/config/Config.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ object Config {
6868
),
6969
"Lcom/tencent/mobileqq/troop/clockin/handler/TroopClockInHandler;" to setOf(
7070
"^TroopClockInHandler$"
71-
)
71+
),
72+
"Lcom/tencent/mobileqq/service/MobileQQServiceBase;" to setOf(
73+
"^PB cmd: req cmd:", "^MobileQQServiceBase$"
74+
),
7275
)
7376
const val hooksVersion = 1
7477
val confuseInfo = mutableMapOf<String, Set<String>>().apply {

0 commit comments

Comments
 (0)