cpdex.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { spawn, execSync } from "child_process"
  2. import { setTimeout } from "timers/promises"
  3. const p = spawn("adb", ["shell"])
  4. let output = ""
  5. let error = ""
  6. p.stdout.on("data", data => {
  7. output += data.toString()
  8. })
  9. p.stderr.on("data", data => {
  10. error += data.toString()
  11. })
  12. async function exec(command) {
  13. output = ""
  14. error = ""
  15. p.stdin.write(command + "\n")
  16. await setTimeout(500)
  17. if (error) {
  18. throw new Error(error)
  19. }
  20. return output + ""
  21. }
  22. // exec su command
  23. p.stdin.write("su\n")
  24. let exists = false
  25. // try {
  26. // await exec("ls /system/framework/RcsHackTool.dex")
  27. // exists = true
  28. // console.log("RcsHackTool.dex found")
  29. // } catch (e) {
  30. // console.log("RcsHackTool.dex not found")
  31. // }
  32. // if (!exists) {
  33. console.log("Pushing RcsHackTool.dex")
  34. execSync("adb push ../RcsHackTool.dex /sdcard/")
  35. console.log("Pushed RcsHackTool.dex")
  36. console.log("mounting /system as rw")
  37. await exec("mount -o rw,remount /")
  38. console.log("mounted /system as rw")
  39. console.log("Copying RcsHackTool.dex to system")
  40. await exec("cp /sdcard/RcsHackTool.dex /system/framework/")
  41. console.log("Copied RcsHackTool.dex to system")
  42. // }
  43. p.kill()