xiongzhu 10 ماه پیش
والد
کامیت
99f10a4b0f
2فایلهای تغییر یافته به همراه28 افزوده شده و 25 حذف شده
  1. 11 11
      scripts/phone.js
  2. 17 14
      scripts/system_server.js

+ 11 - 11
scripts/phone.js

@@ -17,6 +17,7 @@ function buff2json(buf) {
 class Interaction {
     failure(err) {
         console.error(err.message)
+        Java.use('android.util.Log').d('frida-phone', err.message)
     }
 
     accepted(connection) {
@@ -167,22 +168,21 @@ setImmediate(() => {
         }
 
         // log(readConfig('serial_no'))
-        let config = readConfig()
-        setTimeout(() => {
-            new Interaction().start(23946, (msg) => {
-                log(`received message: ${JSON.stringify(msg)}`)
-                if (msg.action === 'saveConfig') {
-                    config = msg.data
-                    saveConfig(config)
-                }
-            })
-        }, 10000)
+        // setTimeout(() => {
+        //     new Interaction().start(23946, (msg) => {
+        //         log(`received message: ${JSON.stringify(msg)}`)
+        //         if (msg.action === 'saveConfig') {
+        //             config = msg.data
+        //             saveConfig(config)
+        //         }
+        //     })
+        // }, 30000)
 
         const PhoneInterfaceManager = Java.use('com.android.phone.PhoneInterfaceManager')
         PhoneInterfaceManager.getImeiForSlot.overload('int', 'java.lang.String', 'java.lang.String').implementation =
             function (slotId, callingPackage, callingFeatureId) {
                 const original = this.getImeiForSlot(slotId, callingPackage, callingFeatureId)
-                const spoofed = config.imei || original
+                const spoofed = readConfig().imei || original
                 log(`PhoneInterfaceManager.getImeiForSlot(${slotId}, ${callingPackage}, ${callingFeatureId}) called`)
                 log(`  ${original} -> ${spoofed}`)
                 return spoofed

+ 17 - 14
scripts/system_server.js

@@ -25,11 +25,13 @@ function buff2json(buf) {
 class Interaction {
     failure(err) {
         console.error(err.message)
+        Java.use('android.util.Log').d('frida-system_server', err.message)
     }
 
     accepted(connection) {
         console.warn('accepted')
         connection.input.read(2000).then((data) => {
+            Java.use('android.util.Log').d('frida-system_server', data + '')
             try {
                 const json = buff2json(data)
                 console.log('received', json)
@@ -174,15 +176,6 @@ setImmediate(() => {
 
         // saveConfig({ a: 1 })
         let config = readConfig()
-        setTimeout(() => {
-            new Interaction().start(23947, (msg) => {
-                log(`received message: ${JSON.stringify(msg)}`)
-                if (msg.action === 'saveConfig') {
-                    config = msg.data
-                    saveConfig(config)
-                }
-            })
-        }, 10000)
 
         const DeviceIdentifiersPolicy = Java.use(
             'com.android.server.os.DeviceIdentifiersPolicyService$DeviceIdentifiersPolicy'
@@ -190,7 +183,7 @@ setImmediate(() => {
 
         DeviceIdentifiersPolicy.getSerial.overload().implementation = function () {
             const original = this.getSerial()
-            const spoof = config.serialNo || original
+            const spoof = readConfig().serialNo || original
             log(`DeviceIdentifiersPolicy.getSerial() called, returning: ${spoof}, original: ${original}`)
             return spoof
         }
@@ -198,7 +191,7 @@ setImmediate(() => {
         DeviceIdentifiersPolicy.getSerialForPackage.overload('java.lang.String', 'java.lang.String').implementation =
             function (callingPackage, callingFeatureId) {
                 const original = this.getSerialForPackage(callingPackage, callingFeatureId)
-                const spoof = config.serialNo || original
+                const spoof = readConfig().serialNo || original
                 log(`DeviceIdentifiersPolicy.getSerialForPackage(${callingPackage}, ${callingFeatureId}) called`)
                 log(`  ${original} -> ${spoof}`)
                 return spoof
@@ -210,7 +203,7 @@ setImmediate(() => {
         const WifiServiceImpl = Java.use('com.android.server.wifi.WifiServiceImpl')
         WifiServiceImpl.getFactoryMacAddresses.overload().implementation = function () {
             const original = this.getFactoryMacAddresses()
-            const spoof = [config.mac || randomMac()]
+            const spoof = [readConfig().mac || randomMac()]
             log(`WifiServiceImpl.getFactoryMacAddresses() called`)
             log(`  ${original} -> ${spoof}`)
             return spoof
@@ -222,8 +215,8 @@ setImmediate(() => {
             const original = this.getConnectionInfo(callingPackage, callingFeatureId)
             const originalMac = original.getMacAddress()
             const originalBSSID = original.getBSSID()
-            const spoofedMac = config.mac || randomMac()
-            const spoofedBSSID = config.bssid || randomMac()
+            const spoofedMac = readConfig().mac || randomMac()
+            const spoofedBSSID = readConfig().bssid || randomMac()
             original.setMacAddress(spoofedMac)
             original.setBSSID(spoofedBSSID)
             log(`WifiServiceImpl.getConnectionInfo(${callingPackage}, ${callingFeatureId}) called`)
@@ -231,5 +224,15 @@ setImmediate(() => {
             log(`  BSSID: ${originalBSSID} -> ${spoofedBSSID}`)
             return original
         }
+
+        // setTimeout(() => {
+        //     new Interaction().start(23947, (msg) => {
+        //         log(`received message: ${JSON.stringify(msg)}`)
+        //         if (msg.action === 'saveConfig') {
+        //             config = msg.data
+        //             saveConfig(config)
+        //         }
+        //     })
+        // }, 30000)
     })
 })