|
@@ -1,26 +1,34 @@
|
|
|
package com.example.modifier
|
|
package com.example.modifier
|
|
|
|
|
|
|
|
|
|
+import android.Manifest
|
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
|
import android.app.AlarmManager
|
|
import android.app.AlarmManager
|
|
|
import android.app.PendingIntent
|
|
import android.app.PendingIntent
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
|
import android.os.Build
|
|
import android.os.Build
|
|
|
|
|
+import android.telephony.SubscriptionManager
|
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
import androidx.core.content.ContextCompat
|
|
import androidx.core.content.ContextCompat
|
|
|
|
|
+import com.example.modifier.constants.CMD_HOME
|
|
|
|
|
+import com.example.modifier.constants.CMD_MESSAGING_APP
|
|
|
|
|
+import com.example.modifier.constants.CMD_START_PLAY_STORE
|
|
|
|
|
+import com.example.modifier.constants.PACKAGE_GMS
|
|
|
|
|
+import com.example.modifier.constants.PACKAGE_GSF
|
|
|
|
|
+import com.example.modifier.constants.PACKAGE_MESSAGING
|
|
|
import com.example.modifier.data.BackupItem
|
|
import com.example.modifier.data.BackupItem
|
|
|
import com.example.modifier.data.BackupItemDao
|
|
import com.example.modifier.data.BackupItemDao
|
|
|
-import com.example.modifier.http.KtorClient
|
|
|
|
|
|
|
+import com.example.modifier.extension.clear
|
|
|
|
|
+import com.example.modifier.extension.disable
|
|
|
|
|
+import com.example.modifier.extension.enable
|
|
|
|
|
+import com.example.modifier.extension.kill
|
|
|
|
|
+import com.example.modifier.extension.resume
|
|
|
|
|
+import com.example.modifier.extension.suspend
|
|
|
import com.example.modifier.model.TelephonyConfig
|
|
import com.example.modifier.model.TelephonyConfig
|
|
|
import com.example.modifier.serializer.Json
|
|
import com.example.modifier.serializer.Json
|
|
|
-import com.example.modifier.ui.shellRun
|
|
|
|
|
-import com.example.modifier.utils.RcsHackTool
|
|
|
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
|
-import io.ktor.client.request.head
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
-import kotlinx.coroutines.coroutineScope
|
|
|
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
|
-import kotlinx.coroutines.launch
|
|
|
|
|
import kotlinx.coroutines.withContext
|
|
import kotlinx.coroutines.withContext
|
|
|
import kotlinx.serialization.encodeToString
|
|
import kotlinx.serialization.encodeToString
|
|
|
import org.apache.commons.io.FileUtils
|
|
import org.apache.commons.io.FileUtils
|
|
@@ -28,12 +36,7 @@ import org.apache.commons.io.IOUtils
|
|
|
import org.apache.commons.lang3.RandomStringUtils
|
|
import org.apache.commons.lang3.RandomStringUtils
|
|
|
import java.io.File
|
|
import java.io.File
|
|
|
import java.nio.file.Files
|
|
import java.nio.file.Files
|
|
|
-import java.time.ZoneId
|
|
|
|
|
-import java.time.ZonedDateTime
|
|
|
|
|
-import java.time.format.DateTimeFormatter
|
|
|
|
|
-import java.util.Base64
|
|
|
|
|
import java.util.Date
|
|
import java.util.Date
|
|
|
-import java.util.Locale
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
object Global {
|
|
object Global {
|
|
@@ -113,8 +116,9 @@ object Global {
|
|
|
FileUtils.write(file, Json.encodeToString(telephonyConfig), "UTF-8")
|
|
FileUtils.write(file, Json.encodeToString(telephonyConfig), "UTF-8")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @SuppressLint("MissingPermission")
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
- fun save(telephonyConfig: TelephonyConfig, suspend: Boolean? = true) {
|
|
|
|
|
|
|
+ suspend fun save(telephonyConfig: TelephonyConfig, suspend: Boolean? = true) {
|
|
|
Global.telephonyConfig.mcc = telephonyConfig.mcc
|
|
Global.telephonyConfig.mcc = telephonyConfig.mcc
|
|
|
Global.telephonyConfig.mnc = telephonyConfig.mnc
|
|
Global.telephonyConfig.mnc = telephonyConfig.mnc
|
|
|
Global.telephonyConfig.number = telephonyConfig.number
|
|
Global.telephonyConfig.number = telephonyConfig.number
|
|
@@ -129,11 +133,11 @@ object Global {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
if (suspend == true) {
|
|
if (suspend == true) {
|
|
|
- suspend(gms = true, sms = true)
|
|
|
|
|
|
|
+ suspendPackage(PACKAGE_GMS, PACKAGE_MESSAGING)
|
|
|
}
|
|
}
|
|
|
save()
|
|
save()
|
|
|
|
|
|
|
|
- Utils.runAsRoot(
|
|
|
|
|
|
|
+ shellRun(
|
|
|
"setprop persist.spoof.mcc ${telephonyConfig.mcc}",
|
|
"setprop persist.spoof.mcc ${telephonyConfig.mcc}",
|
|
|
"setprop persist.spoof.mnc ${telephonyConfig.mnc}",
|
|
"setprop persist.spoof.mnc ${telephonyConfig.mnc}",
|
|
|
"setprop persist.spoof.number ${telephonyConfig.number}",
|
|
"setprop persist.spoof.number ${telephonyConfig.number}",
|
|
@@ -141,11 +145,37 @@ object Global {
|
|
|
"setprop persist.spoof.iccid ${telephonyConfig.iccid}",
|
|
"setprop persist.spoof.iccid ${telephonyConfig.iccid}",
|
|
|
"setprop persist.spoof.imei ${telephonyConfig.imei}",
|
|
"setprop persist.spoof.imei ${telephonyConfig.imei}",
|
|
|
"setprop persist.spoof.imsi ${telephonyConfig.imsi}",
|
|
"setprop persist.spoof.imsi ${telephonyConfig.imsi}",
|
|
|
- "setprop persist.spoof.carrier.id ${telephonyConfig.carrierId}",
|
|
|
|
|
- "setprop persist.spoof.carrier.name ${telephonyConfig.carrierName}",
|
|
|
|
|
|
|
+ "setprop persist.spoof.carrier.id ${
|
|
|
|
|
+ telephonyConfig.carrierId.replace(
|
|
|
|
|
+ "^\\W*\$".toRegex(),
|
|
|
|
|
+ "''"
|
|
|
|
|
+ )
|
|
|
|
|
+ }",
|
|
|
|
|
+ "setprop persist.spoof.carrier.name ${
|
|
|
|
|
+ telephonyConfig.carrierName.replace(
|
|
|
|
|
+ "^\\W*\$".toRegex(),
|
|
|
|
|
+ "''"
|
|
|
|
|
+ )
|
|
|
|
|
+ }",
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+ val context = Utils.getContext()
|
|
|
|
|
+ val subscriptionManager: SubscriptionManager =
|
|
|
|
|
+ context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager
|
|
|
|
|
+
|
|
|
|
|
+ if (hasPermission(Manifest.permission.READ_PHONE_STATE)) {
|
|
|
|
|
+ val simCount = subscriptionManager.activeSubscriptionInfoCountMax
|
|
|
|
|
+ for (i in 0 until simCount) {
|
|
|
|
|
+ val info = subscriptionManager.getActiveSubscriptionInfoForSimSlotIndex(i)
|
|
|
|
|
+ if (info != null) {
|
|
|
|
|
+ val mcc = info.mccString
|
|
|
|
|
+ val mnc = info.mncString
|
|
|
|
|
+ Log.i(TAG, "mccmnc spoofed: $mcc$mnc")
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
if (suspend == true) {
|
|
if (suspend == true) {
|
|
|
- unsuspend(gms = true, sms = true)
|
|
|
|
|
|
|
+ resumePackage(PACKAGE_GMS, PACKAGE_MESSAGING)
|
|
|
}
|
|
}
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
e.printStackTrace()
|
|
e.printStackTrace()
|
|
@@ -164,7 +194,7 @@ object Global {
|
|
|
return oldVersion
|
|
return oldVersion
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- fun saveMock() {
|
|
|
|
|
|
|
+ suspend fun saveMock() {
|
|
|
if (isOldVersion()) {
|
|
if (isOldVersion()) {
|
|
|
val content = Utils.getContext().assets.open("us_numbers.txt").bufferedReader().use {
|
|
val content = Utils.getContext().assets.open("us_numbers.txt").bufferedReader().use {
|
|
|
it.readText()
|
|
it.readText()
|
|
@@ -221,56 +251,56 @@ object Global {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
- fun clear(gsf: Boolean, gms: Boolean, sms: Boolean) {
|
|
|
|
|
|
|
+ suspend fun clear(gsf: Boolean, gms: Boolean, sms: Boolean) {
|
|
|
try {
|
|
try {
|
|
|
- suspend(gsf, gms, sms)
|
|
|
|
|
|
|
+ suspendPackage(PACKAGE_GSF, PACKAGE_GMS, PACKAGE_MESSAGING)
|
|
|
val cmds: MutableList<String> = ArrayList()
|
|
val cmds: MutableList<String> = ArrayList()
|
|
|
// suspend
|
|
// suspend
|
|
|
if (gsf) {
|
|
if (gsf) {
|
|
|
- cmds.add("pm suspend com.google.android.gsf")
|
|
|
|
|
- cmds.add("am force-stop com.google.android.gsf")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_GSF.suspend())
|
|
|
|
|
+ cmds.add(PACKAGE_GSF.kill())
|
|
|
cmds.add("echo 'gsf suspended'")
|
|
cmds.add("echo 'gsf suspended'")
|
|
|
}
|
|
}
|
|
|
if (gms) {
|
|
if (gms) {
|
|
|
- cmds.add("pm suspend com.google.android.gms")
|
|
|
|
|
- cmds.add("am force-stop com.google.android.gms")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_GMS.suspend())
|
|
|
|
|
+ cmds.add(PACKAGE_GMS.kill())
|
|
|
cmds.add("echo 'gms suspended'")
|
|
cmds.add("echo 'gms suspended'")
|
|
|
}
|
|
}
|
|
|
if (sms) {
|
|
if (sms) {
|
|
|
- cmds.add(CMD_SUSPEND_MESSAGING_APP)
|
|
|
|
|
- cmds.add("am force-stop com.google.android.apps.messaging")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_MESSAGING.suspend())
|
|
|
|
|
+ cmds.add(PACKAGE_MESSAGING.kill())
|
|
|
cmds.add("echo 'sms suspended'")
|
|
cmds.add("echo 'sms suspended'")
|
|
|
}
|
|
}
|
|
|
cmds.add("sleep 1")
|
|
cmds.add("sleep 1")
|
|
|
// clear
|
|
// clear
|
|
|
if (gsf) {
|
|
if (gsf) {
|
|
|
- cmds.add("pm clear com.google.android.gsf")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_GSF.clear())
|
|
|
cmds.add("echo 'cleared gsf'")
|
|
cmds.add("echo 'cleared gsf'")
|
|
|
}
|
|
}
|
|
|
if (gms) {
|
|
if (gms) {
|
|
|
- cmds.add("pm clear com.google.android.gms")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_GMS.clear())
|
|
|
cmds.add("echo 'cleared gms'")
|
|
cmds.add("echo 'cleared gms'")
|
|
|
}
|
|
}
|
|
|
if (sms) {
|
|
if (sms) {
|
|
|
- cmds.add("pm clear com.google.android.apps.messaging")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_MESSAGING.clear())
|
|
|
cmds.add("echo 'cleared sms'")
|
|
cmds.add("echo 'cleared sms'")
|
|
|
}
|
|
}
|
|
|
cmds.add("sleep 1")
|
|
cmds.add("sleep 1")
|
|
|
// unsuspend
|
|
// unsuspend
|
|
|
if (gsf) {
|
|
if (gsf) {
|
|
|
- cmds.add("pm unsuspend com.google.android.gsf")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_GSF.resume())
|
|
|
cmds.add("echo 'gsf unsuspend'")
|
|
cmds.add("echo 'gsf unsuspend'")
|
|
|
}
|
|
}
|
|
|
if (gms) {
|
|
if (gms) {
|
|
|
- cmds.add("pm unsuspend com.google.android.gms")
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_GMS.resume())
|
|
|
cmds.add("echo 'gms unsuspend'")
|
|
cmds.add("echo 'gms unsuspend'")
|
|
|
}
|
|
}
|
|
|
if (sms) {
|
|
if (sms) {
|
|
|
- cmds.add(CMD_RESUME_MESSAGING_APP)
|
|
|
|
|
|
|
+ cmds.add(PACKAGE_MESSAGING.resume())
|
|
|
cmds.add("echo 'sms unsuspend'")
|
|
cmds.add("echo 'sms unsuspend'")
|
|
|
}
|
|
}
|
|
|
cmds.add("sleep 1")
|
|
cmds.add("sleep 1")
|
|
|
- Utils.runAsRoot(*cmds.toTypedArray<String>())
|
|
|
|
|
|
|
+ shellRun(*cmds.toTypedArray<String>())
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
e.printStackTrace()
|
|
e.printStackTrace()
|
|
|
}
|
|
}
|
|
@@ -281,16 +311,16 @@ object Global {
|
|
|
// try {
|
|
// try {
|
|
|
// val cmds: MutableList<String> = ArrayList()
|
|
// val cmds: MutableList<String> = ArrayList()
|
|
|
// if (gsf == true) {
|
|
// if (gsf == true) {
|
|
|
-// cmds.add("am force-stop com.google.android.gsf")
|
|
|
|
|
|
|
+// cmds.add(PACKAGE_GSF.kill())
|
|
|
// cmds.add("echo 'stopped gsf'")
|
|
// cmds.add("echo 'stopped gsf'")
|
|
|
// }
|
|
// }
|
|
|
// if (gms == true) {
|
|
// if (gms == true) {
|
|
|
-// cmds.add("am force-stop com.google.android.gms")
|
|
|
|
|
|
|
+// cmds.add(PACKAGE_GMS.kill())
|
|
|
// cmds.add("echo 'stopped gms'")
|
|
// cmds.add("echo 'stopped gms'")
|
|
|
// Thread.sleep(1000)
|
|
// Thread.sleep(1000)
|
|
|
// }
|
|
// }
|
|
|
// if (sms == true) {
|
|
// if (sms == true) {
|
|
|
-// cmds.add("am force-stop com.google.android.apps.messaging")
|
|
|
|
|
|
|
+// cmds.add(PACKAGE_MESSAGING.kill())
|
|
|
// cmds.add("echo 'stopped sms'")
|
|
// cmds.add("echo 'stopped sms'")
|
|
|
// }
|
|
// }
|
|
|
// Utils.runAsRoot(*cmds.toTypedArray<String>())
|
|
// Utils.runAsRoot(*cmds.toTypedArray<String>())
|
|
@@ -300,51 +330,24 @@ object Global {
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
- fun suspend(gsf: Boolean? = false, gms: Boolean? = false, sms: Boolean? = false) {
|
|
|
|
|
- try {
|
|
|
|
|
- val cmds: MutableList<String> = ArrayList()
|
|
|
|
|
- if (gsf == true) {
|
|
|
|
|
- cmds.add("pm suspend com.google.android.gsf")
|
|
|
|
|
- cmds.add("am force-stop com.google.android.gsf")
|
|
|
|
|
- cmds.add("echo 'gsf suspended'")
|
|
|
|
|
- }
|
|
|
|
|
- if (gms == true) {
|
|
|
|
|
- cmds.add("pm suspend com.google.android.gms")
|
|
|
|
|
- cmds.add("am force-stop com.google.android.gms")
|
|
|
|
|
- cmds.add("echo 'gms suspended'")
|
|
|
|
|
- }
|
|
|
|
|
- if (sms == true) {
|
|
|
|
|
- cmds.add(CMD_SUSPEND_MESSAGING_APP)
|
|
|
|
|
- cmds.add("am force-stop com.google.android.apps.messaging")
|
|
|
|
|
- cmds.add("echo 'sms suspended'")
|
|
|
|
|
- }
|
|
|
|
|
- cmds.add("sleep 1")
|
|
|
|
|
- Utils.runAsRoot(*cmds.toTypedArray<String>())
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- e.printStackTrace()
|
|
|
|
|
|
|
+ suspend fun suspendPackage(vararg packages: String) {
|
|
|
|
|
+ packages.forEach {
|
|
|
|
|
+ shellRun(
|
|
|
|
|
+ it.suspend(),
|
|
|
|
|
+ it.kill()
|
|
|
|
|
+ )
|
|
|
|
|
+ delay(1000)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
- fun unsuspend(gsf: Boolean? = false, gms: Boolean? = false, sms: Boolean? = false) {
|
|
|
|
|
- try {
|
|
|
|
|
- val cmds: MutableList<String> = ArrayList()
|
|
|
|
|
- if (gsf == true) {
|
|
|
|
|
- cmds.add("pm unsuspend com.google.android.gsf")
|
|
|
|
|
- cmds.add("echo 'gsf unsuspend'")
|
|
|
|
|
- }
|
|
|
|
|
- if (gms == true) {
|
|
|
|
|
- cmds.add("pm unsuspend com.google.android.gms")
|
|
|
|
|
- cmds.add("echo 'gms unsuspend'")
|
|
|
|
|
- }
|
|
|
|
|
- if (sms == true) {
|
|
|
|
|
- cmds.add(CMD_RESUME_MESSAGING_APP)
|
|
|
|
|
- cmds.add("echo 'sms unsuspend'")
|
|
|
|
|
- }
|
|
|
|
|
- cmds.add("sleep 1")
|
|
|
|
|
- Utils.runAsRoot(*cmds.toTypedArray<String>())
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- e.printStackTrace()
|
|
|
|
|
|
|
+ suspend fun resumePackage(vararg packages: String) {
|
|
|
|
|
+ packages.forEach {
|
|
|
|
|
+ shellRun(
|
|
|
|
|
+ it.resume(),
|
|
|
|
|
+ it.kill()
|
|
|
|
|
+ )
|
|
|
|
|
+ delay(1000)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -390,7 +393,7 @@ object Global {
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
val sqlite3 = sqlite3path()
|
|
val sqlite3 = sqlite3path()
|
|
|
- suspend(sms = true)
|
|
|
|
|
|
|
+ suspendPackage(PACKAGE_MESSAGING)
|
|
|
val dataDir = ContextCompat.getDataDir(context)
|
|
val dataDir = ContextCompat.getDataDir(context)
|
|
|
val providerDir = File(dataDir, "telephony_provider/$model")
|
|
val providerDir = File(dataDir, "telephony_provider/$model")
|
|
|
if (!providerDir.exists()) {
|
|
if (!providerDir.exists()) {
|
|
@@ -421,7 +424,7 @@ object Global {
|
|
|
"$sqlite3 /data/data/com.google.android.apps.messaging/databases/bugle_db \"DELETE FROM messages;\"",
|
|
"$sqlite3 /data/data/com.google.android.apps.messaging/databases/bugle_db \"DELETE FROM messages;\"",
|
|
|
*cmds.toTypedArray(),
|
|
*cmds.toTypedArray(),
|
|
|
)
|
|
)
|
|
|
- unsuspend(sms = true)
|
|
|
|
|
|
|
+ resumePackage(PACKAGE_MESSAGING)
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
|
e.printStackTrace()
|
|
e.printStackTrace()
|
|
|
}
|
|
}
|
|
@@ -432,18 +435,18 @@ object Global {
|
|
|
try {
|
|
try {
|
|
|
clearConv()
|
|
clearConv()
|
|
|
shellRun(
|
|
shellRun(
|
|
|
- CMD_SUSPEND_MESSAGING_APP,
|
|
|
|
|
- CMD_KILL_MESSAGING_APP,
|
|
|
|
|
- CMD_CLEAR_MESSAGING_APP,
|
|
|
|
|
- CMD_CLEAR_GSF,
|
|
|
|
|
- CMD_CLEAR_GMS,
|
|
|
|
|
|
|
+ PACKAGE_MESSAGING.suspend(),
|
|
|
|
|
+ PACKAGE_MESSAGING.kill(),
|
|
|
|
|
+ PACKAGE_MESSAGING.clear(),
|
|
|
|
|
+ PACKAGE_GSF.clear(),
|
|
|
|
|
+ PACKAGE_GMS.clear(),
|
|
|
"sleep 1",
|
|
"sleep 1",
|
|
|
CMD_START_PLAY_STORE,
|
|
CMD_START_PLAY_STORE,
|
|
|
"sleep 1",
|
|
"sleep 1",
|
|
|
CMD_HOME,
|
|
CMD_HOME,
|
|
|
"sleep 10",
|
|
"sleep 10",
|
|
|
- CMD_CLEAR_GMS,
|
|
|
|
|
- CMD_RESUME_MESSAGING_APP,
|
|
|
|
|
|
|
+ PACKAGE_GMS.clear(),
|
|
|
|
|
+ PACKAGE_MESSAGING.resume(),
|
|
|
CMD_MESSAGING_APP
|
|
CMD_MESSAGING_APP
|
|
|
)
|
|
)
|
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
@@ -455,13 +458,13 @@ object Global {
|
|
|
suspend fun killPhoneProcess(force: Boolean = false): Boolean {
|
|
suspend fun killPhoneProcess(force: Boolean = false): Boolean {
|
|
|
try {
|
|
try {
|
|
|
if (!force) {
|
|
if (!force) {
|
|
|
- if (shellRun("getprop phonekilled")["output"]!!.contains("yes")) {
|
|
|
|
|
|
|
+ if (shellRun("getprop phonekilled").component1().contains("yes")) {
|
|
|
return true
|
|
return true
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
run kill@{
|
|
run kill@{
|
|
|
repeat(3) {
|
|
repeat(3) {
|
|
|
- val pid = shellRun("pidof com.android.phone")["output"]!!.trim()
|
|
|
|
|
|
|
+ val pid = shellRun("pidof com.android.phone").component1().trim()
|
|
|
if (!Regex("[0-9]+").matches(pid)) {
|
|
if (!Regex("[0-9]+").matches(pid)) {
|
|
|
Log.e(TAG, "killPhoneProcess: pid not found")
|
|
Log.e(TAG, "killPhoneProcess: pid not found")
|
|
|
return true
|
|
return true
|
|
@@ -470,7 +473,7 @@ object Global {
|
|
|
shellRun("kill -9 $pid")
|
|
shellRun("kill -9 $pid")
|
|
|
delay(1000)
|
|
delay(1000)
|
|
|
|
|
|
|
|
- val pidNew = shellRun("pidof com.android.phone")["output"]!!.trim()
|
|
|
|
|
|
|
+ val pidNew = shellRun("pidof com.android.phone").component1().trim()
|
|
|
if (pidNew == pid) {
|
|
if (pidNew == pid) {
|
|
|
Log.e(TAG, "killPhoneProcess: failed to kill phone process")
|
|
Log.e(TAG, "killPhoneProcess: failed to kill phone process")
|
|
|
} else {
|
|
} else {
|
|
@@ -486,75 +489,6 @@ object Global {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @JvmStatic
|
|
|
|
|
- suspend fun sendSmsFrida(sender: String, msg: String) {
|
|
|
|
|
- val context = Utils.getContext()
|
|
|
|
|
- try {
|
|
|
|
|
- val dataDir = ContextCompat.getDataDir(context)
|
|
|
|
|
- Utils.copyAssetFolder(context.assets, "bin", File(dataDir, "bin").path)
|
|
|
|
|
- val binPath = File(dataDir, "bin/frida-inject-16.3.3-android-arm64").path
|
|
|
|
|
- val pduBase64 =
|
|
|
|
|
- String(Base64.getEncoder().encode(RcsHackTool.createFakeSms(sender, msg)))
|
|
|
|
|
- Log.i("Modifier", "pduBase64: $pduBase64")
|
|
|
|
|
- val script = IOUtils.toString(context.assets.open("scripts/sms.js"), "UTF-8")
|
|
|
|
|
- .replace("{pduBase64}", pduBase64)
|
|
|
|
|
-
|
|
|
|
|
- val tmpFile: File
|
|
|
|
|
- withContext(Dispatchers.IO) {
|
|
|
|
|
- tmpFile = File.createTempFile("script", ".js")
|
|
|
|
|
- FileUtils.writeStringToFile(tmpFile, script, "UTF-8")
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- val pid = Utils.runAsRoot("pidof com.android.phone").trim()
|
|
|
|
|
- if (!Regex("[0-9]+").matches(pid)) {
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Log.i("Modifier", "sendSms: $binPath -p $pid -s $tmpFile")
|
|
|
|
|
-
|
|
|
|
|
- val p = withContext(Dispatchers.IO) {
|
|
|
|
|
- Runtime.getRuntime().exec("su -M")
|
|
|
|
|
- }
|
|
|
|
|
- p.outputStream.bufferedWriter().use {
|
|
|
|
|
- it.write("chmod +x $binPath")
|
|
|
|
|
- it.newLine()
|
|
|
|
|
- it.flush()
|
|
|
|
|
- it.write("$binPath -p $pid -s $tmpFile")
|
|
|
|
|
- it.newLine()
|
|
|
|
|
- it.flush()
|
|
|
|
|
- }
|
|
|
|
|
- coroutineScope {
|
|
|
|
|
- launch {
|
|
|
|
|
- p.errorStream.bufferedReader().useLines { lines ->
|
|
|
|
|
- lines.forEach {
|
|
|
|
|
- Log.e("Modifier", it)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- launch {
|
|
|
|
|
- p.inputStream
|
|
|
|
|
- .bufferedReader()
|
|
|
|
|
- .useLines { lines ->
|
|
|
|
|
- lines.forEach {
|
|
|
|
|
- Log.i("Modifier", it)
|
|
|
|
|
- if (it == "OK") {
|
|
|
|
|
- p.inputStream.close()
|
|
|
|
|
- p.errorStream.close()
|
|
|
|
|
- p.destroy()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- withContext(Dispatchers.IO) {
|
|
|
|
|
- p.waitFor()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- e.printStackTrace()
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
fun sendSmsIntent(sender: String, msg: String) {
|
|
fun sendSmsIntent(sender: String, msg: String) {
|
|
|
val intent = Intent()
|
|
val intent = Intent()
|
|
@@ -568,48 +502,6 @@ object Global {
|
|
|
context.sendBroadcast(intent)
|
|
context.sendBroadcast(intent)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @JvmStatic
|
|
|
|
|
- suspend fun syncTime() {
|
|
|
|
|
- try {
|
|
|
|
|
- Log.i("Modifier", "syncTime: start")
|
|
|
|
|
- val response = KtorClient.head("http://www.baidu.com")
|
|
|
|
|
- val dateHeader = response.headers["Date"]
|
|
|
|
|
- val date = ZonedDateTime.parse(
|
|
|
|
|
- dateHeader,
|
|
|
|
|
- DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH)
|
|
|
|
|
- )
|
|
|
|
|
- // convert to Asia/Shanghai
|
|
|
|
|
- val dateInZone = date.withZoneSameInstant(ZoneId.of("Asia/Shanghai"))
|
|
|
|
|
- Log.i(
|
|
|
|
|
- TAG,
|
|
|
|
|
- "CurrentTime from Baidu: ${dateInZone.format(DateTimeFormatter.ISO_DATE_TIME)}"
|
|
|
|
|
- )
|
|
|
|
|
- shellRun(
|
|
|
|
|
- "settings put system time_12_24 24",
|
|
|
|
|
- "settings put global auto_time 0",
|
|
|
|
|
- "settings put global auto_time_zone 0",
|
|
|
|
|
- "setprop persist.sys.timezone Asia/Shanghai",
|
|
|
|
|
- "date \"${dateInZone.format(DateTimeFormatter.ofPattern("MMddHHmmyyyy.ss"))}\""
|
|
|
|
|
- )
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- Log.e(TAG, "Error SyncTime", e)
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @JvmStatic
|
|
|
|
|
- suspend fun hasRoot(): Boolean {
|
|
|
|
|
- val hasRoot = run checkRoot@{
|
|
|
|
|
- repeat(5) {
|
|
|
|
|
- if (Utils.hasRootAccess()) {
|
|
|
|
|
- return@checkRoot true
|
|
|
|
|
- }
|
|
|
|
|
- delay(500)
|
|
|
|
|
- }
|
|
|
|
|
- return@checkRoot false
|
|
|
|
|
- }
|
|
|
|
|
- return hasRoot
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@SuppressLint("DefaultLocale")
|
|
@SuppressLint("DefaultLocale")
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
fun genICCID(mnc: String, areaCode: String): String {
|
|
fun genICCID(mnc: String, areaCode: String): String {
|
|
@@ -619,7 +511,7 @@ object Global {
|
|
|
|
|
|
|
|
@JvmStatic
|
|
@JvmStatic
|
|
|
suspend fun rebooted(): Boolean {
|
|
suspend fun rebooted(): Boolean {
|
|
|
- if (shellRun("getprop rebooted")["output"]!!.contains("yes")) {
|
|
|
|
|
|
|
+ if (shellRun("getprop rebooted").component1().contains("yes")) {
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
shellRun("setprop rebooted yes")
|
|
shellRun("setprop rebooted yes")
|
|
@@ -655,9 +547,9 @@ object Global {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
val packages = mutableListOf(
|
|
val packages = mutableListOf(
|
|
|
- "com.google.android.apps.messaging",
|
|
|
|
|
- "com.google.android.gms",
|
|
|
|
|
- "com.google.android.gsf",
|
|
|
|
|
|
|
+ PACKAGE_MESSAGING,
|
|
|
|
|
+ PACKAGE_GMS,
|
|
|
|
|
+ PACKAGE_GSF
|
|
|
)
|
|
)
|
|
|
packages.forEach {
|
|
packages.forEach {
|
|
|
File(dest, it).mkdirs()
|
|
File(dest, it).mkdirs()
|
|
@@ -666,13 +558,19 @@ object Global {
|
|
|
val cmds = mutableListOf<String>()
|
|
val cmds = mutableListOf<String>()
|
|
|
|
|
|
|
|
for (pkg in packages) {
|
|
for (pkg in packages) {
|
|
|
- if (!shellRun("ls /data/data/$pkg")["error"]!!.contains("No such file or directory")) {
|
|
|
|
|
|
|
+ if (!shellRun("ls /data/data/$pkg").component2()
|
|
|
|
|
+ .contains("No such file or directory")
|
|
|
|
|
+ ) {
|
|
|
cmds.add("tar zcpf $dest/$pkg/data.tar.gz -C /data/data $pkg ")
|
|
cmds.add("tar zcpf $dest/$pkg/data.tar.gz -C /data/data $pkg ")
|
|
|
}
|
|
}
|
|
|
- if (!shellRun("ls /data/user_de/0/$pkg")["error"]!!.contains("No such file or directory")) {
|
|
|
|
|
|
|
+ if (!shellRun("ls /data/user_de/0/$pkg").component2()
|
|
|
|
|
+ .contains("No such file or directory")
|
|
|
|
|
+ ) {
|
|
|
cmds.add("tar zcpf $dest/$pkg/data_de.tar.gz -C /data/user_de/0 $pkg ")
|
|
cmds.add("tar zcpf $dest/$pkg/data_de.tar.gz -C /data/user_de/0 $pkg ")
|
|
|
}
|
|
}
|
|
|
- if (!shellRun("ls /sdcard/Android/data/$pkg")["error"]!!.contains("No such file or directory")) {
|
|
|
|
|
|
|
+ if (!shellRun("ls /sdcard/Android/data/$pkg").component2()
|
|
|
|
|
+ .contains("No such file or directory")
|
|
|
|
|
+ ) {
|
|
|
cmds.add("tar zcpf $dest/$pkg/data_ext.tar.gz -C /sdcard/Android/data $pkg ")
|
|
cmds.add("tar zcpf $dest/$pkg/data_ext.tar.gz -C /sdcard/Android/data $pkg ")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -728,15 +626,15 @@ object Global {
|
|
|
), false
|
|
), false
|
|
|
)
|
|
)
|
|
|
val packages = mutableListOf(
|
|
val packages = mutableListOf(
|
|
|
- "com.google.android.apps.messaging",
|
|
|
|
|
- "com.google.android.gms",
|
|
|
|
|
- "com.google.android.gsf",
|
|
|
|
|
|
|
+ PACKAGE_MESSAGING,
|
|
|
|
|
+ PACKAGE_GMS,
|
|
|
|
|
+ PACKAGE_GSF
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
shellRun(
|
|
shellRun(
|
|
|
- "pm disable-user com.google.android.apps.messaging",
|
|
|
|
|
- "pm disable-user com.google.android.gms",
|
|
|
|
|
- "pm disable-user com.google.android.gsf"
|
|
|
|
|
|
|
+ PACKAGE_MESSAGING.disable(),
|
|
|
|
|
+ PACKAGE_GMS.disable(),
|
|
|
|
|
+ PACKAGE_GSF.disable()
|
|
|
)
|
|
)
|
|
|
for (pkg in packages) {
|
|
for (pkg in packages) {
|
|
|
for (item in listOf("data.tar.gz", "data_de.tar.gz", "data_ext.tar.gz")) {
|
|
for (item in listOf("data.tar.gz", "data_de.tar.gz", "data_ext.tar.gz")) {
|
|
@@ -758,12 +656,12 @@ object Global {
|
|
|
}
|
|
}
|
|
|
shellRun(
|
|
shellRun(
|
|
|
// "pm clear com.google.android.gsf",
|
|
// "pm clear com.google.android.gsf",
|
|
|
- "pm enable com.google.android.gsf",
|
|
|
|
|
|
|
+ PACKAGE_GSF.enable(),
|
|
|
"sleep 1",
|
|
"sleep 1",
|
|
|
// "pm clear com.google.android.gms",
|
|
// "pm clear com.google.android.gms",
|
|
|
- "pm enable com.google.android.gms",
|
|
|
|
|
|
|
+ PACKAGE_GMS.enable(),
|
|
|
// "sleep 30",
|
|
// "sleep 30",
|
|
|
- "pm enable com.google.android.apps.messaging",
|
|
|
|
|
|
|
+ PACKAGE_MESSAGING.enable(),
|
|
|
"sleep 3",
|
|
"sleep 3",
|
|
|
CMD_MESSAGING_APP,
|
|
CMD_MESSAGING_APP,
|
|
|
"sleep 5",
|
|
"sleep 5",
|