Skip to content

Commit

Permalink
fix: wrong wire type in group recall
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqiuluo committed Jul 23, 2024
1 parent f52575c commit 3f995b7
Show file tree
Hide file tree
Showing 19 changed files with 140 additions and 159 deletions.
19 changes: 15 additions & 4 deletions app/src/main/java/moe/qwq/miko/ActionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ package moe.qwq.miko

import android.content.Context
import moe.qwq.miko.actions.ActionProcess
import moe.qwq.miko.internals.hooks.BrowserAccessRestrictions
import moe.qwq.miko.hooks.BrowserAccessRestrictions
import moe.qwq.miko.actions.FetchService
import moe.qwq.miko.actions.*
import moe.qwq.miko.internals.hooks.*
import moe.qwq.miko.hooks.AllowGroupFlashPic
import moe.qwq.miko.hooks.DefaultPacketHijacker
import moe.qwq.miko.hooks.DisableFlashPictures
import moe.qwq.miko.hooks.ForceTabletMode
import moe.qwq.miko.hooks.HotUpdateSoPatch
import moe.qwq.miko.hooks.MessageEncrypt
import moe.qwq.miko.hooks.MessageTail
import moe.qwq.miko.hooks.OneClickLike
import moe.qwq.miko.hooks.QQCrashHook
import moe.qwq.miko.hooks.RepeatMessage
import moe.qwq.miko.hooks.SimplifyHomepageSidebar

object ActionManager {
// TODO(ksp实现全自动添加action)
private val FIRST_ACTION = arrayOf(
WebJsBridge::class.java, // ALWAYS RUN
FetchService::class.java, // ALWAYS RUN
PacketHijacker::class.java, // ALWAYS RUN
PatchMsfCore::class.java, // ALWAYS RUN
HookCodec::class.java, // ALWAYS RUN

OneClickLike::class.java,
ForceTabletMode::class.java,
Expand All @@ -24,7 +34,8 @@ object ActionManager {
HotUpdateSoPatch::class.java,

RepeatMessage::class.java,
MessageHook::class.java,
MessageTail::class.java,
MessageEncrypt::class.java,
DisableFlashPictures::class.java,
AllowGroupFlashPic::class.java,
QQCrashHook::class.java,
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/moe/qwq/miko/actions/HookCodec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@file:Suppress("LocalVariableName", "SpellCheckingInspection")
package moe.qwq.miko.actions

import android.content.Context
import de.robv.android.xposed.XposedBridge
import moe.fuqiuluo.processor.HookAction
import moe.fuqiuluo.xposed.loader.LuoClassloader
import moe.qwq.miko.ext.beforeHook
import moe.qwq.miko.ext.hookMethod

@HookAction(desc = "HookWrapperCodec实现捕获抓包")
class HookCodec: AlwaysRunAction() {
override fun onRun(ctx: Context) {
val CodecWarpper = LuoClassloader.load("com.tencent.qphone.base.util.CodecWarpper")
if (CodecWarpper == null) {
XposedBridge.log("[QwQ] 无法注入CodecWarpper!")
return
}
CodecWarpper.hookMethod("nativeEncodeRequest", beforeHook {

})
}
}
91 changes: 0 additions & 91 deletions app/src/main/java/moe/qwq/miko/actions/PacketHijacker.kt

This file was deleted.

64 changes: 46 additions & 18 deletions app/src/main/java/moe/qwq/miko/actions/PatchMsfCore.kt
Original file line number Diff line number Diff line change
@@ -1,37 +1,65 @@
@file:Suppress("LocalVariableName")
package moe.qwq.miko.actions

import android.content.Context
import com.tencent.mobileqq.msf.sdk.MsfMessagePair
import com.tencent.qphone.base.remote.ToServiceMsg
import de.robv.android.xposed.XposedBridge
import moe.qwq.miko.internals.msf.MSFHandler.onPush
import moe.qwq.miko.internals.msf.MSFHandler.onResp
import moe.fuqiuluo.processor.HookAction
import moe.fuqiuluo.xposed.loader.LuoClassloader
import moe.qwq.miko.ext.beforeHook
import moe.qwq.miko.ext.hookMethod
import moe.qwq.miko.internals.hijackers.IHijacker

@HookAction("注入MSF收包任务")
class PatchMsfCore: AlwaysRunAction() {
override fun onRun(ctx: Context) {
runCatching {
val MSFRespHandleTask = LuoClassloader.load("mqq.app.msghandle.MSFRespHandleTask")
if (MSFRespHandleTask == null) {
XposedBridge.log("[QwQ] 无法注入MSFRespHandleTask!")
} else {
val msfPair = MSFRespHandleTask.declaredFields.first {
it.type == MsfMessagePair::class.java
}
msfPair.isAccessible = true
MSFRespHandleTask.hookMethod("run").before {
val pair = msfPair.get(it.thisObject) as MsfMessagePair
if (pair.toServiceMsg == null) {
onPush(pair.fromServiceMsg)
} else {
onResp(pair.toServiceMsg, pair.fromServiceMsg)
}
val MSFRespHandleTask = LuoClassloader.load("mqq.app.msghandle.MSFRespHandleTask")
if (MSFRespHandleTask == null) {
XposedBridge.log("[QwQ] 无法注入MSFRespHandleTask!")
} else {
val msfPair = MSFRespHandleTask.declaredFields.first {
it.type == MsfMessagePair::class.java
}
msfPair.isAccessible = true
MSFRespHandleTask.hookMethod("run").before {
val pair = msfPair.get(it.thisObject) as MsfMessagePair
if (pair.toServiceMsg == null) {
onPush(pair.fromServiceMsg)
} else {
onResp(pair.toServiceMsg, pair.fromServiceMsg)
}
}
}.onFailure {
XposedBridge.log(it)
}

/* val MobileQQServiceBase = LuoClassloader.load("com.tencent.mobileqq.service.MobileQQServiceBase")
if (MobileQQServiceBase == null) {
XposedBridge.log("[QwQ] 无法注入MobileQQServiceBase!部分服务可能不可用!")
} else {
val realHandleRequest = kotlin.runCatching { MobileQQServiceBase.getMethod("realHandleRequest", ToServiceMsg::class.java, Class::class.java) }
.getOrElse {
MobileQQServiceBase.methods.firstOrNull { it.returnType == Void.TYPE && it.parameterTypes.size == 2 && it.parameterTypes[0] == ToServiceMsg::class.java && it.parameterTypes[1] == Class::class.java }
}
if (realHandleRequest == null) {
XposedBridge.log("[QwQ] 无法注入MobileQQServiceBase.realHandleRequest!部分服务可能不可用!")
} else {
XposedBridge.hookMethod(realHandleRequest, beforeHook {
val toServiceMsg = it.args[0] as ToServiceMsg
val isPb = toServiceMsg.getAttribute("req_pb_protocol_flag", false)
val cmd = toServiceMsg.serviceCmd
if(hijackerList.firstOrNull {
it.command == cmd
}?.onHandle(toServiceMsg, isPb) == true) {
it.result = Unit
}
})
}
}*/
}

/* companion object {
val hijackerList = arrayListOf<IHijacker>()
}*/
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package moe.qwq.miko.internals.hooks
@file:Suppress("LocalVariableName")
package moe.qwq.miko.hooks

import android.content.Context
import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.qphone.base.util.CodecWarpper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.mobileqq.aio.msglist.AIOMsgItemFactoryProvider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@file:Suppress("LocalVariableName")

package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.common.config.pad.DeviceType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.mobileqq.earlydownload.xmldata.XmlData
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/java/moe/qwq/miko/hooks/MessageEncrypt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.qphone.base.remote.ToServiceMsg
import de.robv.android.xposed.XposedBridge
import moe.fuqiuluo.processor.HookAction
import moe.qwq.miko.actions.ActionProcess
import moe.qwq.miko.actions.IAction
import moe.qwq.miko.actions.PatchMsfCore
import moe.qwq.miko.internals.hijackers.IHijacker
import moe.qwq.miko.internals.setting.QwQSetting

@HookAction(desc = "消息加密抄送")
class MessageEncrypt: IAction {
override fun onRun(ctx: Context) {
val encryptKey = QwQSetting.getSetting<String>(name).getValue(null, null)

}

override fun canRun(): Boolean {
val setting = QwQSetting.getSetting<String>(name)
return setting.getValue(null, null).isNotBlank()
}

//override val process: ActionProcess = ActionProcess.MAIN

override val name: String = QwQSetting.MESSAGE_ENCRYPT
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
Expand All @@ -11,18 +11,14 @@ import moe.qwq.miko.actions.ActionProcess
import moe.qwq.miko.actions.IAction
import moe.qwq.miko.internals.setting.QwQSetting

@HookAction("发送消息预劫持")
class MessageHook: IAction {
@HookAction("消息小尾巴")
class MessageTail: IAction {
private fun handleMessageBody(msgs: ArrayList<MsgElement>) {
if (msgs.isActionMsg()) return
val tail by QwQSetting.getSetting<String>(name)
val encrypt by QwQSetting.getSetting<String>(QwQSetting.MESSAGE_ENCRYPT)
if (tail.isNotBlank()) {
handleMessageTail(msgs, tail)
}
if (encrypt.isNotBlank()) {
handleMessageEncrypt(msgs, encrypt)
}
}

private fun handleMessageTail(msgs: ArrayList<MsgElement>, tail: String) { // 给消息添加小尾巴
Expand All @@ -33,9 +29,6 @@ class MessageHook: IAction {
})
}

private fun handleMessageEncrypt(msgs: ArrayList<MsgElement>, encryptKey: String) {
}

override fun onRun(ctx: Context) {
/* val msgService = QRoute.api(IMsgService::class.java)
msgService.javaClass.methods.forEach {
Expand Down Expand Up @@ -90,8 +83,7 @@ class MessageHook: IAction {

override fun canRun(): Boolean {
val tail by QwQSetting.getSetting<String>(name)
val encrypt by QwQSetting.getSetting<String>(QwQSetting.MESSAGE_ENCRYPT)
return tail.isNotEmpty() || encrypt.isNotEmpty()
return tail.isNotEmpty()
}

override val name: String = QwQSetting.MESSAGE_TAIL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:Suppress("LocalVariableName")
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import de.robv.android.xposed.XposedBridge
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:Suppress("LocalVariableName", "UNCHECKED_CAST")
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import android.view.View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:Suppress("UNUSED_VARIABLE", "LocalVariableName", "UNCHECKED_CAST")
package moe.qwq.miko.internals.hooks
package moe.qwq.miko.hooks

import android.content.Context
import com.tencent.mobileqq.activity.qqsettingme.config.QQSettingMeBizBean
Expand All @@ -25,7 +25,7 @@ class SimplifyHomepageSidebar: IAction {
private lateinit var FieldQQSettingMeItemName: Field

private fun findItemNameField(bean: QQSettingMeBizBean) {
if(!::FieldQQSettingMeItemName.isInitialized) {
if(!Companion::FieldQQSettingMeItemName.isInitialized) {
DvmLocator.findField(QQSettingMeItemName)?.let {
FieldQQSettingMeItemName = it
return
Expand Down
Loading

0 comments on commit 3f995b7

Please sign in to comment.