From 72690147623f6fabe96c5499b2020da22576bcac Mon Sep 17 00:00:00 2001 From: d4rkk3y <43563783+d4rkk3y@users.noreply.github.com> Date: Mon, 21 Nov 2022 22:14:58 +0700 Subject: [PATCH] feat(tiktok): `tiktok-web-login` patch (#593) --- .../TikTokWebLoginCompatibility.kt | 14 ++++++ .../GoogleAuthAvailableFingerprint.kt | 20 +++++++++ .../GoogleOneTapAuthAvailableFingerprint.kt | 20 +++++++++ .../patch/TikTokLoginFallbackPatch.kt | 44 +++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/annotations/TikTokWebLoginCompatibility.kt create mode 100644 src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleAuthAvailableFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleOneTapAuthAvailableFingerprint.kt create mode 100644 src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/patch/TikTokLoginFallbackPatch.kt diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/annotations/TikTokWebLoginCompatibility.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/annotations/TikTokWebLoginCompatibility.kt new file mode 100644 index 00000000..dcdd93c5 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/annotations/TikTokWebLoginCompatibility.kt @@ -0,0 +1,14 @@ +package app.revanced.patches.tiktok.misc.loginfallback.annotations + +import app.revanced.patcher.annotation.Compatibility +import app.revanced.patcher.annotation.Package + +@Compatibility( + [ + Package("com.ss.android.ugc.trill"), + Package("com.zhiliaoapp.musically") + ] +) +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.RUNTIME) +internal annotation class TikTokWebLoginCompatibility \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleAuthAvailableFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleAuthAvailableFingerprint.kt new file mode 100644 index 00000000..1ebace78 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleAuthAvailableFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.tiktok.misc.loginfallback.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("google-one-tap-auth-available-fingerprint") +@TikTokWebLoginCompatibility +@Version("0.0.1") +object GoogleAuthAvailableFingerprint : MethodFingerprint( + returnType = "Z", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf(), + customFingerprint = { methodDef -> + methodDef.definingClass == "Lcom/bytedance/lobby/google/GoogleAuth;" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleOneTapAuthAvailableFingerprint.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleOneTapAuthAvailableFingerprint.kt new file mode 100644 index 00000000..04472149 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/fingerprints/GoogleOneTapAuthAvailableFingerprint.kt @@ -0,0 +1,20 @@ +package app.revanced.patches.tiktok.misc.loginfallback.fingerprints + +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.extensions.or +import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint +import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility +import org.jf.dexlib2.AccessFlags + +@Name("google-one-tap-auth-available-fingerprint") +@TikTokWebLoginCompatibility +@Version("0.0.1") +object GoogleOneTapAuthAvailableFingerprint : MethodFingerprint( + returnType = "Z", + access = AccessFlags.PUBLIC or AccessFlags.FINAL, + parameters = listOf(), + customFingerprint = { methodDef -> + methodDef.definingClass == "Lcom/bytedance/lobby/google/GoogleOneTapAuth;" + } +) \ No newline at end of file diff --git a/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/patch/TikTokLoginFallbackPatch.kt b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/patch/TikTokLoginFallbackPatch.kt new file mode 100644 index 00000000..9b32a902 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/tiktok/misc/loginfallback/patch/TikTokLoginFallbackPatch.kt @@ -0,0 +1,44 @@ +package app.revanced.patches.tiktok.misc.loginfallback.patch + +import app.revanced.patcher.annotation.Description +import app.revanced.patcher.annotation.Name +import app.revanced.patcher.annotation.Version +import app.revanced.patcher.data.BytecodeContext +import app.revanced.patcher.extensions.addInstructions +import app.revanced.patcher.patch.BytecodePatch +import app.revanced.patcher.patch.PatchResult +import app.revanced.patcher.patch.PatchResultSuccess +import app.revanced.patcher.patch.annotations.Patch +import app.revanced.patches.tiktok.misc.loginfallback.annotations.TikTokWebLoginCompatibility +import app.revanced.patches.tiktok.misc.loginfallback.fingerprints.GoogleAuthAvailableFingerprint +import app.revanced.patches.tiktok.misc.loginfallback.fingerprints.GoogleOneTapAuthAvailableFingerprint + +@Patch +@Name("tiktok-web-login") +@Description("Allows logging in with a Google account.") +@TikTokWebLoginCompatibility +@Version("0.0.1") +class TikTokLoginFallbackPatch : BytecodePatch( + listOf( + GoogleOneTapAuthAvailableFingerprint, + GoogleAuthAvailableFingerprint + ) +) { + override fun execute(context: BytecodeContext): PatchResult { + listOf( + GoogleOneTapAuthAvailableFingerprint, + GoogleAuthAvailableFingerprint + ).forEach { + with(it.result!!.mutableMethod) { + addInstructions( + 0, + """ + const/4 v0, 0x0 + return v0 + """ + ) + } + } + return PatchResultSuccess() + } +} \ No newline at end of file