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,15 @@ 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")
+ if (phoneNumber != null) {
+ val password = decode(ciphertext, phoneNumber)
+ Log.d(TAG, "password = $password")
+ }
+ }
}
val messageBody = smsMessage.messageBody
Log.d(TAG, "Message body: $messageBody")
@@ -36,4 +53,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