droidguard.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. function trace(tag) {
  2. Log.e((tag || '') + Java.use('android.util.Log').getStackTraceString(Java.use('java.lang.Throwable').$new()))
  3. }
  4. class Log {
  5. static TAG = '[DG]'
  6. static Debug = true
  7. static format(...msg) {
  8. let m = []
  9. for (let i = 0; i < msg.length; i++) {
  10. if (typeof msg[i] === 'object') {
  11. m.push(msg[i] + '')
  12. } else {
  13. m.push(msg[i])
  14. }
  15. }
  16. m = m.join(' ')
  17. return m
  18. }
  19. static i(...msg) {
  20. if (!this.Debug) return
  21. console.log(`\x1b[30m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  22. }
  23. static w(...msg) {
  24. console.log(`\x1b[33m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  25. }
  26. static e(...msg) {
  27. console.log(`\x1b[31m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  28. }
  29. static s(...msg) {
  30. console.log(`\x1b[32m${this.TAG} ${this.format(...msg)}\x1b[0m`)
  31. }
  32. }
  33. Java.perform(function () {
  34. const classLoaders = Java.enumerateClassLoadersSync()
  35. for (let i of classLoaders) {
  36. Log.i(i)
  37. if (i.toString().includes('app_dg_cache')) {
  38. Log.s('Found DroidGuard ClassLoader:', i)
  39. Java.classFactory.loader = i
  40. }
  41. }
  42. const DroidGuard = Java.use('com.google.ccc.abuse.droidguard.DroidGuard')
  43. Log.i('DroidGuard:', DroidGuard)
  44. // .overload('android.content.Context', 'java.lang.String', '[B')
  45. // .overload('android.content.Context', 'java.lang.String', '[B', 'java.lang.Object')
  46. // .overload('android.content.Context', 'java.lang.String', '[B', 'java.lang.Object', 'android.os.Bundle')
  47. // .overload('android.content.Context', 'java.lang.String', '[B', 'java.lang.Object', 'boolean')
  48. // .overload('android.content.Context', 'java.lang.String', '[B', 'java.lang.Object', 'android.os.Bundle', 'int')
  49. // .overload('android.content.Context', 'java.lang.String', '[B', 'java.lang.Object', 'boolean', 'android.os.Bundle')
  50. DroidGuard.$init.overload('android.content.Context', 'java.lang.String', '[B').implementation = function (
  51. context,
  52. str,
  53. bytes
  54. ) {
  55. Log.s('DroidGuard.$init1', str)
  56. return this.$init(context, str, bytes)
  57. }
  58. DroidGuard.$init.overload('android.content.Context', 'java.lang.String', '[B', 'java.lang.Object').implementation =
  59. function (context, str, bytes, obj) {
  60. Log.s('DroidGuard.$init2', str, obj)
  61. return this.$init(context, str, bytes, obj)
  62. }
  63. DroidGuard.$init.overload(
  64. 'android.content.Context',
  65. 'java.lang.String',
  66. '[B',
  67. 'java.lang.Object',
  68. 'android.os.Bundle'
  69. ).implementation = function (context, str, bytes, obj, bundle) {
  70. Log.s('DroidGuard.$init3', str, obj, bundle)
  71. for(let k of Object.keys(obj)){
  72. Log.s('obj', k, obj[k])
  73. }
  74. return this.$init(context, str, bytes, obj, bundle)
  75. }
  76. DroidGuard.$init.overload(
  77. 'android.content.Context',
  78. 'java.lang.String',
  79. '[B',
  80. 'java.lang.Object',
  81. 'boolean'
  82. ).implementation = function (context, str, bytes, obj, bool) {
  83. Log.s('DroidGuard.$init4', str, obj, bool)
  84. return this.$init(context, str, bytes, obj, bool)
  85. }
  86. DroidGuard.$init.overload(
  87. 'android.content.Context',
  88. 'java.lang.String',
  89. '[B',
  90. 'java.lang.Object',
  91. 'android.os.Bundle',
  92. 'int'
  93. ).implementation = function (context, str, bytes, obj, bundle, int) {
  94. Log.s('DroidGuard.$init5', str, obj, bundle, int)
  95. return this.$init(context, str, bytes, obj, bundle, int)
  96. }
  97. DroidGuard.$init.overload(
  98. 'android.content.Context',
  99. 'java.lang.String',
  100. '[B',
  101. 'java.lang.Object',
  102. 'boolean',
  103. 'android.os.Bundle'
  104. ).implementation = function (context, str, bytes, obj, bool, bundle) {
  105. Log.s('DroidGuard.$init6', str, obj, bool, bundle)
  106. return this.$init(context, str, bytes, obj, bool, bundle)
  107. }
  108. DroidGuard.ssNative.overload('long', '[Ljava.lang.String;').implementation = function (l, strings) {
  109. Log.s('DroidGuard.ssNative', l, strings)
  110. return this.ssNative(l, strings)
  111. }
  112. })