forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Joey for Reddit): Add
Change OAuth client id
patch
- Loading branch information
1 parent
2ef62e5
commit 1bac47d
Showing
5 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...ced/patches/reddit/customclients/joeyforreddit/api/fingerprints/GetClientIdFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
|
||
object GetClientIdFingerprint : MethodFingerprint( | ||
returnType = "L", | ||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC, | ||
opcodes = listOf( | ||
Opcode.CONST, // R.string.valuable_cid | ||
Opcode.INVOKE_STATIC, // StringMaster.decrypt | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.RETURN_OBJECT | ||
), | ||
customFingerprint = custom@{ _, classDef -> | ||
classDef.sourceFile == "AuthUtility.java" | ||
} | ||
) |
47 changes: 47 additions & 0 deletions
47
...revanced/patches/reddit/customclients/joeyforreddit/api/patch/ChangeOAuthClientIdPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package app.revanced.patches.reddit.customclients.joeyforreddit.api.patch | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Package | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.DependsOn | ||
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch | ||
import app.revanced.patches.reddit.customclients.ChangeOAuthClientIdPatchAnnotation | ||
import app.revanced.patches.reddit.customclients.joeyforreddit.api.fingerprints.GetClientIdFingerprint | ||
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch.DisablePiracyDetectionPatch | ||
|
||
@ChangeOAuthClientIdPatchAnnotation | ||
@Description( | ||
"Changes the OAuth client ID. " + | ||
"The OAuth application type has to be \"Installed app\" " + | ||
"and the redirect URI has to be set to \"https://127.0.0.1:65023/authorize_callback\"." | ||
) | ||
@Compatibility( | ||
[ | ||
Package("o.o.joey"), | ||
Package("o.o.joey.pro"), | ||
Package("o.o.joey.dev") | ||
] | ||
) | ||
@DependsOn([DisablePiracyDetectionPatch::class]) | ||
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch( | ||
"https://127.0.0.1:65023/authorize_callback", Options, listOf(GetClientIdFingerprint) | ||
) { | ||
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult { | ||
first().mutableMethod.addInstructions( | ||
0, | ||
""" | ||
const-string v0, "$clientId" | ||
return-object v0 | ||
""" | ||
) | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer() | ||
} |
22 changes: 22 additions & 0 deletions
22
...t/customclients/joeyforreddit/detection/piracy/fingerprints/PiracyDetectionFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints | ||
|
||
import app.revanced.patcher.extensions.or | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
|
||
object PiracyDetectionFingerprint : MethodFingerprint( | ||
returnType = "V", | ||
accessFlags = AccessFlags.PRIVATE or AccessFlags.STATIC, | ||
opcodes = listOf( | ||
Opcode.NEW_INSTANCE, // new PiracyDetectionRunnable() | ||
Opcode.CONST_16, | ||
Opcode.CONST_WIDE_16, | ||
Opcode.INVOKE_DIRECT, // <init>(..) | ||
Opcode.INVOKE_VIRTUAL, // run() | ||
Opcode.RETURN_VOID | ||
), | ||
customFingerprint = custom@{ _, classDef -> | ||
classDef.type.endsWith("ProcessLifeCyleListener;") | ||
} | ||
) |
22 changes: 22 additions & 0 deletions
22
.../reddit/customclients/joeyforreddit/detection/piracy/patch/DisablePiracyDetectionPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.patch | ||
|
||
import app.revanced.extensions.toErrorResult | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patches.reddit.customclients.joeyforreddit.detection.piracy.fingerprints.PiracyDetectionFingerprint | ||
|
||
class DisablePiracyDetectionPatch : BytecodePatch(listOf(PiracyDetectionFingerprint)) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
PiracyDetectionFingerprint.result?.mutableMethod?.addInstruction( | ||
0, | ||
""" | ||
return-void | ||
""" | ||
) ?: return PiracyDetectionFingerprint.toErrorResult() | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters