|
|
@@ -6,22 +6,23 @@ import path from "path"
|
|
|
const filePath = url.fileURLToPath(import.meta.url)
|
|
|
const __dirname = path.dirname(filePath)
|
|
|
|
|
|
-const device = await frida.getUsbDevice()
|
|
|
const mcc = "255"
|
|
|
const mnc = "06"
|
|
|
const simOperator = "25506"
|
|
|
const networkOperator = "25506"
|
|
|
-const simSerialNumber = "89380062300689131836"
|
|
|
-const iccId = "89380062300689131836"
|
|
|
-const number = "733765567"
|
|
|
+const simSerialNumber = "89380062300689131876"
|
|
|
+const iccId = simSerialNumber
|
|
|
+const number = "731848010"
|
|
|
const imei = "864929043714851"
|
|
|
-const imsi = "255065007246414"
|
|
|
+const imsi = "255065007246456"
|
|
|
+const countryIso = "ua"
|
|
|
+const subId = ""
|
|
|
|
|
|
const scriptContent = fs
|
|
|
.readFileSync(path.resolve(__dirname, "../scripts/spoof.js"))
|
|
|
.toString()
|
|
|
- .replace('"{{mcc}}"', mcc)
|
|
|
- .replace('"{{mnc}}"', mnc)
|
|
|
+ .replace("{{mcc}}", mcc)
|
|
|
+ .replace("{{mnc}}", mnc)
|
|
|
.replace("{{simOperator}}", simOperator)
|
|
|
.replace("{{networkOperator}}", networkOperator)
|
|
|
.replace("{{simSerialNumber}}", simSerialNumber)
|
|
|
@@ -29,42 +30,109 @@ const scriptContent = fs
|
|
|
.replace("{{number}}", number)
|
|
|
.replace("{{imei}}", imei)
|
|
|
.replace("{{imsi}}", imsi)
|
|
|
+ .replace("{{countryIso}}", countryIso)
|
|
|
+ .replace("{{subId}}", subId)
|
|
|
|
|
|
-console.log(scriptContent)
|
|
|
+fs.writeFileSync(path.resolve(__dirname, "../scripts/_spoof.js"), scriptContent)
|
|
|
|
|
|
-// fs.writeFileSync("../_sendsms.js", scriptContent)
|
|
|
+let device = null
|
|
|
+let tracers = []
|
|
|
|
|
|
-async function attachRcsService() {
|
|
|
- const rcsProcess = (await device.enumerateProcesses()).filter(
|
|
|
- p => p.name === "com.google.android.apps.messaging:rcs"
|
|
|
- )[0]
|
|
|
-
|
|
|
- const session = await device.attach(rcsProcess.pid)
|
|
|
+async function stop() {
|
|
|
+ console.log("[*] Stopping all tracers")
|
|
|
+ for (const tracer of tracers) {
|
|
|
+ console.log("[*] Stopping", tracer.pid)
|
|
|
+ tracer.session.detach()
|
|
|
+ try {
|
|
|
+ await device.kill(tracer.pid)
|
|
|
+ } catch (error) {}
|
|
|
+ }
|
|
|
+ process.exit(1)
|
|
|
+}
|
|
|
|
|
|
- const script = await session.createScript(scriptContent)
|
|
|
- script.message.connect(message => {
|
|
|
- console.log("[*] Message:", message)
|
|
|
+process.on("SIGTERM", stop)
|
|
|
+process.on("SIGINT", stop)
|
|
|
|
|
|
- if (message.type === "send" && message.payload === "ok") {
|
|
|
- script.unload()
|
|
|
- }
|
|
|
+async function main() {
|
|
|
+ const deviceMgr = frida.getDeviceManager()
|
|
|
+ deviceMgr.enumerateDevices().then(devices => {
|
|
|
+ devices.forEach(device => {
|
|
|
+ console.log("[*] Device:", device.id, device.name, device.type)
|
|
|
+ })
|
|
|
})
|
|
|
- await script.load()
|
|
|
-}
|
|
|
+ device = await frida.getUsbDevice()
|
|
|
+ device.spawnAdded.connect(onSpawnAdded)
|
|
|
+
|
|
|
+ console.log("[*] Enabling spawn gating")
|
|
|
+ await device.enableSpawnGating()
|
|
|
+ console.log("[*] Enabled spawn gating")
|
|
|
|
|
|
-async function attachUI() {
|
|
|
+ await showPendingSpawn()
|
|
|
+
|
|
|
+ console.log("[*] Spawning com.google.android.apps.messaging")
|
|
|
const pid = await device.spawn("com.google.android.apps.messaging")
|
|
|
- const session = await device.attach(pid)
|
|
|
- const script = await session.createScript(scriptContent)
|
|
|
- script.message.connect(message => {
|
|
|
- console.log("[*] Message:", message)
|
|
|
-
|
|
|
- if (message.type === "send" && message.payload === "ok") {
|
|
|
- console.log("Unloading script")
|
|
|
- script.unload()
|
|
|
+ console.log("[*] Spawned com.google.android.apps.messaging: " + pid)
|
|
|
+ const tracer = await Tracer.open(pid)
|
|
|
+ tracers.push(tracer)
|
|
|
+}
|
|
|
+
|
|
|
+async function showPendingSpawn() {
|
|
|
+ const pending = await device.enumeratePendingSpawn()
|
|
|
+ console.log("[*] enumeratePendingSpawn():", pending)
|
|
|
+}
|
|
|
+
|
|
|
+async function onSpawnAdded(spawn) {
|
|
|
+ try {
|
|
|
+ await showPendingSpawn()
|
|
|
+
|
|
|
+ if (spawn.identifier.startsWith("com.google.android.apps.messaging")) {
|
|
|
+ console.log("[*] Tracing", spawn.pid, spawn.identifier)
|
|
|
+ const tracer = await Tracer.open(spawn.pid)
|
|
|
+ tracers.push(tracer)
|
|
|
+ } else {
|
|
|
+ console.log("[*] Resuming", spawn.pid)
|
|
|
+ await device.resume(spawn.pid)
|
|
|
}
|
|
|
- })
|
|
|
- await script.load()
|
|
|
+ } catch (e) {
|
|
|
+ console.error("err: ", e)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class Tracer {
|
|
|
+ static async open(pid) {
|
|
|
+ const tracer = new Tracer(pid)
|
|
|
+ await tracer._initialize()
|
|
|
+ return tracer
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor(pid) {
|
|
|
+ this.pid = pid
|
|
|
+ this.session = null
|
|
|
+ this.script = null
|
|
|
+ }
|
|
|
+
|
|
|
+ async _initialize() {
|
|
|
+ const session = await device.attach(this.pid)
|
|
|
+ this.session = session
|
|
|
+ session.detached.connect(this._onSessionDetached.bind(this))
|
|
|
+
|
|
|
+ const script = await session.createScript(scriptContent)
|
|
|
+ this.script = script
|
|
|
+ script.message.connect(this._onScriptMessage.bind(this))
|
|
|
+ await script.load()
|
|
|
+
|
|
|
+ await device.resume(this.pid)
|
|
|
+ }
|
|
|
+
|
|
|
+ _onSessionDetached(reason) {
|
|
|
+ console.log(`[PID ${this.pid}] onSessionDetached(reason='${reason}')`)
|
|
|
+ }
|
|
|
+
|
|
|
+ _onScriptMessage(message, data) {
|
|
|
+ console.log(`[PID ${this.pid}] onScriptMessage()`, message)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-await attachUI()
|
|
|
+main().catch(e => {
|
|
|
+ console.error(e)
|
|
|
+})
|