From 25e073311f631392bc1a3d6f19e3a8a304838310 Mon Sep 17 00:00:00 2001 From: Kris Date: Fri, 13 Dec 2024 10:03:45 +0200 Subject: [PATCH] fix: native RSA modulus searching in newer clients --- .../rsprox/patch/native/processors/RsaModulusProcessor.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/patch/patch-native/src/main/kotlin/net/rsprox/patch/native/processors/RsaModulusProcessor.kt b/patch/patch-native/src/main/kotlin/net/rsprox/patch/native/processors/RsaModulusProcessor.kt index 4f415679..13eb8ada 100644 --- a/patch/patch-native/src/main/kotlin/net/rsprox/patch/native/processors/RsaModulusProcessor.kt +++ b/patch/patch-native/src/main/kotlin/net/rsprox/patch/native/processors/RsaModulusProcessor.kt @@ -15,8 +15,10 @@ internal class RsaModulusProcessor( if (index == -1) { throw IllegalStateException("Unable to locate exponent 10001") } + // Begin searching for the modulus before the exponent. + // In some clients, it comes just before; in most, it comes just after it. val sliceIndices = - client.bytes.firstSliceIndices(index + 5, 256) { byte -> + client.bytes.firstSliceIndices(index - 300, 256) { byte -> isHex(byte.toInt().toChar()) } val slice = client.bytes.sliceArray(sliceIndices) @@ -65,7 +67,7 @@ internal class RsaModulusProcessor( } end++ } - if (length != -1 && end - start < length) { + if (length != -1 && (end - start) != length) { start = end continue }