sendsms.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import frida from 'frida'
  2. import fs from 'fs'
  3. import url from 'url'
  4. import path from 'path'
  5. import { execSync } from 'child_process'
  6. const filePath = url.fileURLToPath(import.meta.url)
  7. const __dirname = path.dirname(filePath)
  8. function pushFile(file, dest, force = false) {
  9. const fileName = path.basename(file)
  10. const srcPath = path.resolve(__dirname, file)
  11. const destPath = dest + fileName
  12. if (!force) {
  13. console.log(`Checking if ${destPath} exists`)
  14. try {
  15. if (execSync(`adb shell ls ${destPath}`).toString().includes('No such file or directory')) {
  16. throw new Error('File not found')
  17. }
  18. console.log(`File ${fileName} already exists`)
  19. return
  20. } catch (e) {
  21. console.log(`File ${fileName} not found`)
  22. }
  23. }
  24. // execSync(`adb shell mkdir ${dest}`)
  25. console.log(`Pushing ${srcPath} to ${destPath}`)
  26. execSync(`adb push ${srcPath} ${destPath}`)
  27. console.log(`Push success: ${fileName}`)
  28. console.log(`set permission 777 to ${destPath}`)
  29. execSync(`adb shell chmod 777 ${destPath}`)
  30. console.log(`set permission success: ${fileName}`)
  31. }
  32. pushFile('../RcsHackTool.dex', '/sdcard/Download/')
  33. const source = fs
  34. .readFileSync(path.resolve(__dirname, '../scripts/sendsms.js'))
  35. .toString()
  36. .replace('{{sender}}', '3538')
  37. .replace('{{msg}}', `Your Messenger verification code is G-950141`)
  38. const device = await frida.getUsbDevice()
  39. const processes = await device.enumerateProcesses()
  40. let phoneProcess
  41. try {
  42. phoneProcess = await device.getProcess('com.android.phone')
  43. } catch (error) {
  44. try {
  45. phoneProcess = await device.getProcess('SIM 卡工具包')
  46. } catch (error) {}
  47. }
  48. if (!phoneProcess) {
  49. console.error('Phone process not found')
  50. process.exit(1)
  51. }
  52. const session = await device.attach(phoneProcess.pid)
  53. const script = await session.createScript(source)
  54. script.message.connect((message) => {
  55. console.log('[*] Message:', message)
  56. if (message.type === 'send' && message.payload === 'ok') {
  57. script.unload()
  58. }
  59. })
  60. await script.load()