mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 21:27:47 +02:00
fix(core): add friend source spoof
This commit is contained in:
@ -445,7 +445,7 @@ class BulkMessagingAction : AbstractAction() {
|
||||
private fun removeFriend(userId: String) {
|
||||
context.mappings.useMapper(FriendRelationshipChangerMapper::class) {
|
||||
val friendRelationshipChangerInstance = context.feature(AddFriendSourceSpoof::class).friendRelationshipChangerInstance!!
|
||||
val removeMethod = removeFriendClass.getAsClass()?.methods?.first {
|
||||
val removeMethod = friendshipRelationshipChangerKtx.getAsClass()?.methods?.first {
|
||||
it.name == removeFriendMethod.getAsString()
|
||||
} ?: throw Exception("Failed to find removeFriend method")
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package me.rhunk.snapenhance.core.features.impl.experiments
|
||||
|
||||
import me.rhunk.snapenhance.common.data.FriendAddSource
|
||||
import me.rhunk.snapenhance.common.util.protobuf.ProtoEditor
|
||||
import me.rhunk.snapenhance.core.event.events.impl.UnaryCallEvent
|
||||
import me.rhunk.snapenhance.core.features.Feature
|
||||
import me.rhunk.snapenhance.core.features.FeatureLoadParams
|
||||
import me.rhunk.snapenhance.core.util.hook.HookStage
|
||||
import me.rhunk.snapenhance.core.util.hook.hook
|
||||
import me.rhunk.snapenhance.core.util.hook.hookConstructor
|
||||
import me.rhunk.snapenhance.mapper.impl.FriendRelationshipChangerMapper
|
||||
|
||||
@ -16,51 +18,50 @@ class AddFriendSourceSpoof : Feature("AddFriendSourceSpoof", loadParams = Featur
|
||||
classReference.get()?.hookConstructor(HookStage.AFTER) { param ->
|
||||
friendRelationshipChangerInstance = param.thisObject()
|
||||
}
|
||||
}
|
||||
|
||||
classReference.get()?.hook(addFriendMethod.get()!!, HookStage.BEFORE) { param ->
|
||||
val spoofedSource = context.config.experimental.addFriendSourceSpoof.getNullable() ?: return@hook
|
||||
context.event.subscribe(UnaryCallEvent::class) { event ->
|
||||
if (event.uri != "/snapchat.friending.server.FriendAction/AddFriends") return@subscribe
|
||||
val spoofedSource = context.config.experimental.addFriendSourceSpoof.getNullable() ?: return@subscribe
|
||||
event.buffer = ProtoEditor(event.buffer).apply {
|
||||
edit {
|
||||
fun setPage(value: String) {
|
||||
remove(1)
|
||||
addString(1, value)
|
||||
}
|
||||
|
||||
fun setEnum(index: Int, value: String) {
|
||||
val enumData = param.arg<Any>(index)
|
||||
enumData::class.java.enumConstants.first { it.toString() == value }.let {
|
||||
param.setArg(index, it)
|
||||
editEach(2) {
|
||||
remove(3) // remove suggestion token
|
||||
fun setSource(source: FriendAddSource) {
|
||||
remove(2)
|
||||
addVarInt(2, source.id)
|
||||
}
|
||||
|
||||
when (spoofedSource) {
|
||||
"added_by_group_chat" -> {
|
||||
setPage("group_profile")
|
||||
setSource(FriendAddSource.GROUP_CHAT)
|
||||
}
|
||||
"added_by_username" -> {
|
||||
setPage("search")
|
||||
setSource(FriendAddSource.USERNAME)
|
||||
}
|
||||
"added_by_qr_code" -> {
|
||||
setPage("scan_snapcode")
|
||||
setSource(FriendAddSource.QR_CODE)
|
||||
}
|
||||
"added_by_mention" -> {
|
||||
setPage("context_card")
|
||||
setSource(FriendAddSource.MENTION)
|
||||
}
|
||||
"added_by_community" -> {
|
||||
setPage("profile")
|
||||
setSource(FriendAddSource.COMMUNITY)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
when (spoofedSource) {
|
||||
"added_by_quick_add" -> {
|
||||
setEnum(1, "PROFILE")
|
||||
setEnum(2, "ADD_FRIENDS_BUTTON_ON_TOP_BAR_ON_FRIENDS_FEED")
|
||||
setEnum(3, "ADDED_BY_SUGGESTED")
|
||||
}
|
||||
"added_by_group_chat" -> {
|
||||
setEnum(1, "PROFILE")
|
||||
setEnum(2, "GROUP_PROFILE")
|
||||
setEnum(3, "ADDED_BY_GROUP_CHAT")
|
||||
}
|
||||
"added_by_username" -> {
|
||||
setEnum(1, "SEARCH")
|
||||
setEnum(2, "SEARCH")
|
||||
setEnum(3, "ADDED_BY_USERNAME")
|
||||
}
|
||||
"added_by_qr_code" -> {
|
||||
setEnum(1, "PROFILE")
|
||||
setEnum(2, "PROFILE")
|
||||
setEnum(3, "ADDED_BY_QR_CODE")
|
||||
}
|
||||
"added_by_mention" -> {
|
||||
setEnum(1, "CONTEXT_CARDS")
|
||||
setEnum(2, "CONTEXT_CARD")
|
||||
setEnum(3, "ADDED_BY_MENTION")
|
||||
}
|
||||
"added_by_community" -> {
|
||||
setEnum(1, "PROFILE")
|
||||
setEnum(2, "PROFILE")
|
||||
setEnum(3, "ADDED_BY_COMMUNITY")
|
||||
}
|
||||
else -> return@hook
|
||||
}
|
||||
}
|
||||
}.toByteArray()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user