From 7076ca5c746fe60094fb0160307be37b9fa47561 Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Fri, 21 Jun 2024 12:31:58 -0400 Subject: [PATCH] decode passwords using XOR ciphering - retrieve phone number from phone rather than hardcoding --- .idea/deploymentTargetSelector.xml | 10 + .idea/inspectionProfiles/Project_Default.xml | 41 +++ .idea/other.xml | 263 ++++++++++++++++++ app/src/main/AndroidManifest.xml | 3 + .../beckmeyer/vvmsmsreceiver/SmsReceiver.kt | 52 +++- 5 files changed, 367 insertions(+), 2 deletions(-) create mode 100644 .idea/deploymentTargetSelector.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/other.xml diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..44ca2d9 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..0d3a1fb --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,263 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ab2024f..14b6a17 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,9 @@ android:name="android.hardware.telephony" android:required="false" /> + + + @@ -26,6 +34,13 @@ class SmsReceiver : BroadcastReceiver() { smsMessage?.let { if (intent.action == Telephony.Sms.Intents.DATA_SMS_RECEIVED_ACTION) { Log.d(TAG, "Data SMS received on port 5499") + val bodyUri = Uri.parse("advvm://" + smsMessage.messageBody) + bodyUri.getQueryParameter("p")?.let { p -> + val ciphertext = Base64.decode(p).toString(Charsets.US_ASCII) + Log.d(TAG, "ciphertext = $ciphertext") + val password = decode(ciphertext, "8107308422") + Log.d(TAG, "password = $password") + } } val messageBody = smsMessage.messageBody Log.d(TAG, "Message body: $messageBody") @@ -36,4 +51,37 @@ class SmsReceiver : BroadcastReceiver() { } } } + + + fun getNumber(context: Context): String? { + // Create obj of TelephonyManager and ask for current telephone service + val telephonyManager = context.getSystemService(TELEPHONY_SERVICE) as TelephonyManager + val phoneNumber = telephonyManager.line1Number + return phoneNumber.replace("\\D".toRegex(), "").takeLast(10) + } + + private fun stripPrefix(char: Char): Int { + return char.code and 0x0F + } + + private fun getStripped(text: String): ByteArray { + val stripped = text.map { stripPrefix(it).toByte() } + return stripped.toByteArray() + } + + fun decode(cipher: String, phoneNumber: String): String { + val cipherStripped = getStripped(cipher) + val phoneNumberStripped = getStripped(phoneNumber) + val secret = byteArrayOf(12, 5, 3, 11, 9, 4, 5, 3, 8, 14) + + val text = cipherStripped.zip(phoneNumberStripped) + .zip(secret.asIterable()) { (c, p), s -> (c.toInt() xor p.toInt() xor s.toInt()).toByte() } + .toMutableList() + + if (cipherStripped.size > 10) { + text.addAll(cipherStripped.slice(10 until cipherStripped.size).toMutableList()) + } + + return text.toByteArray().map { (it + 0x30).toChar() }.joinToString("") + } } \ No newline at end of file