frida-java-bridge 6.2.3 → 6.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/android.js CHANGED
@@ -139,7 +139,7 @@ function _getApi () {
139
139
 
140
140
  const temporaryApi = {
141
141
  module: vmModule,
142
- flavor: flavor,
142
+ flavor,
143
143
  addLocalReference: null
144
144
  };
145
145
 
@@ -472,10 +472,10 @@ function _getApi () {
472
472
 
473
473
  temporaryApi.artClassLinker = {
474
474
  address: classLinker,
475
- quickResolutionTrampoline: quickResolutionTrampoline,
476
- quickImtConflictTrampoline: quickImtConflictTrampoline,
477
- quickGenericJniTrampoline: quickGenericJniTrampoline,
478
- quickToInterpreterBridgeTrampoline: quickToInterpreterBridgeTrampoline
475
+ quickResolutionTrampoline,
476
+ quickImtConflictTrampoline,
477
+ quickGenericJniTrampoline,
478
+ quickToInterpreterBridgeTrampoline
479
479
  };
480
480
 
481
481
  const vm = new VM(temporaryApi);
@@ -1020,7 +1020,7 @@ function _getArtMethodSpec (vm) {
1020
1020
  const size = (apiLevel <= 21) ? (quickCodeOffset + 32) : (quickCodeOffset + pointerSize);
1021
1021
 
1022
1022
  spec = {
1023
- size: size,
1023
+ size,
1024
1024
  offset: {
1025
1025
  jniCode: jniCodeOffset,
1026
1026
  quickCode: quickCodeOffset,
@@ -3525,12 +3525,12 @@ class DalvikMethodMangler {
3525
3525
  vtablePtr.writePointer(shadowVtable);
3526
3526
 
3527
3527
  entry = {
3528
- classObject: classObject,
3529
- vtablePtr: vtablePtr,
3530
- vtableCountPtr: vtableCountPtr,
3531
- vtable: vtable,
3532
- vtableCount: vtableCount,
3533
- shadowVtable: shadowVtable,
3528
+ classObject,
3529
+ vtablePtr,
3530
+ vtableCountPtr,
3531
+ vtable,
3532
+ vtableCount,
3533
+ shadowVtable,
3534
3534
  shadowVtableCount: vtableCount,
3535
3535
  targetMethods: new Map()
3536
3536
  };
@@ -186,39 +186,94 @@ class ClassFactory {
186
186
  _make (name, getClassHandle, env) {
187
187
  const C = makeClassWrapperConstructor();
188
188
  const proto = Object.create(Wrapper.prototype, {
189
- $n: {
189
+ [Symbol.for('n')]: {
190
190
  value: name
191
191
  },
192
- $C: {
192
+ $n: {
193
+ get () {
194
+ return this[Symbol.for('n')];
195
+ }
196
+ },
197
+ [Symbol.for('C')]: {
193
198
  value: C
194
199
  },
195
- $w: {
200
+ $C: {
201
+ get () {
202
+ return this[Symbol.for('C')];
203
+ }
204
+ },
205
+ [Symbol.for('w')]: {
196
206
  value: null,
197
207
  writable: true
198
208
  },
199
- $_s: {
209
+ $w: {
210
+ get () {
211
+ return this[Symbol.for('w')];
212
+ },
213
+ set (val) {
214
+ this[Symbol.for('w')] = val;
215
+ }
216
+ },
217
+ [Symbol.for('_s')]: {
200
218
  writable: true
201
219
  },
202
- $c: {
220
+ $_s: {
221
+ get () {
222
+ return this[Symbol.for('_s')];
223
+ },
224
+ set (val) {
225
+ this[Symbol.for('_s')] = val;
226
+ }
227
+ },
228
+ [Symbol.for('c')]: {
203
229
  value: [null]
204
230
  },
205
- $m: {
231
+ $c: {
232
+ get () {
233
+ return this[Symbol.for('c')];
234
+ }
235
+ },
236
+ [Symbol.for('m')]: {
206
237
  value: new Map()
207
238
  },
208
- $l: {
239
+ $m: {
240
+ get () {
241
+ return this[Symbol.for('m')];
242
+ }
243
+ },
244
+ [Symbol.for('l')]: {
209
245
  value: null,
210
246
  writable: true
211
247
  },
212
- $gch: {
248
+ $l: {
249
+ get () {
250
+ return this[Symbol.for('l')];
251
+ },
252
+ set (val) {
253
+ this[Symbol.for('l')] = val;
254
+ }
255
+ },
256
+ [Symbol.for('gch')]: {
213
257
  value: getClassHandle
214
258
  },
215
- $f: {
259
+ $gch: {
260
+ get () {
261
+ return this[Symbol.for('gch')];
262
+ }
263
+ },
264
+ [Symbol.for('f')]: {
216
265
  value: this
266
+ },
267
+ $f: {
268
+ get () {
269
+ return this[Symbol.for('f')];
270
+ }
217
271
  }
218
272
  });
219
273
  C.prototype = proto;
220
274
 
221
275
  const classWrapper = new C(null);
276
+ proto[Symbol.for('w')] = classWrapper;
222
277
  proto.$w = classWrapper;
223
278
 
224
279
  const h = classWrapper.$borrowClassHandle(env);
@@ -809,14 +864,20 @@ wrapperHandler = {
809
864
  };
810
865
 
811
866
  Object.defineProperties(Wrapper.prototype, {
812
- $new: {
813
- enumerable: true,
867
+ [Symbol.for('new')]: {
868
+ enumerable: false,
814
869
  get () {
815
870
  return this.$getCtor('allocAndInit');
816
871
  }
817
872
  },
818
- $alloc: {
873
+ $new: {
819
874
  enumerable: true,
875
+ get () {
876
+ return this[Symbol.for('new')];
877
+ }
878
+ },
879
+ [Symbol.for('alloc')]: {
880
+ enumerable: false,
820
881
  value () {
821
882
  const env = vm.getEnv();
822
883
  const h = this.$borrowClassHandle(env);
@@ -829,14 +890,26 @@ Object.defineProperties(Wrapper.prototype, {
829
890
  }
830
891
  }
831
892
  },
832
- $init: {
893
+ $alloc: {
833
894
  enumerable: true,
895
+ get () {
896
+ return this[Symbol.for('$alloc')];
897
+ }
898
+ },
899
+ [Symbol.for('init')]: {
900
+ enumerable: false,
834
901
  get () {
835
902
  return this.$getCtor('initOnly');
836
903
  }
837
904
  },
838
- $dispose: {
905
+ $init: {
839
906
  enumerable: true,
907
+ get () {
908
+ return this[Symbol.for('init')];
909
+ }
910
+ },
911
+ [Symbol.for('dispose')]: {
912
+ enumerable: false,
840
913
  value () {
841
914
  const ref = this.$r;
842
915
  if (ref !== null) {
@@ -849,14 +922,26 @@ Object.defineProperties(Wrapper.prototype, {
849
922
  }
850
923
  }
851
924
  },
852
- $clone: {
925
+ $dispose: {
926
+ enumerable: true,
927
+ get () {
928
+ return this[Symbol.for('dispose')];
929
+ }
930
+ },
931
+ [Symbol.for('clone')]: {
932
+ enumerable: false,
853
933
  value (env) {
854
934
  const C = this.$C;
855
935
  return new C(this.$h, this.$t, env);
856
936
  }
857
937
  },
858
- class: {
859
- enumerable: true,
938
+ $clone: {
939
+ value (env) {
940
+ return this[Symbol.for('clone')](env);
941
+ }
942
+ },
943
+ [Symbol.for('class')]: {
944
+ enumerable: false,
860
945
  get () {
861
946
  const env = vm.getEnv();
862
947
  const h = this.$borrowClassHandle(env);
@@ -868,8 +953,14 @@ Object.defineProperties(Wrapper.prototype, {
868
953
  }
869
954
  }
870
955
  },
871
- $className: {
956
+ class: {
872
957
  enumerable: true,
958
+ get () {
959
+ return this[Symbol.for('class')];
960
+ }
961
+ },
962
+ [Symbol.for('className')]: {
963
+ enumerable: false,
873
964
  get () {
874
965
  const handle = this.$h;
875
966
  if (handle === null) {
@@ -879,22 +970,41 @@ Object.defineProperties(Wrapper.prototype, {
879
970
  return vm.getEnv().getObjectClassName(handle);
880
971
  }
881
972
  },
882
- $ownMembers: {
973
+ $className: {
883
974
  enumerable: true,
975
+ get () {
976
+ return this[Symbol.for('className')];
977
+ }
978
+ },
979
+ [Symbol.for('ownMembers')]: {
980
+ enumerable: false,
884
981
  get () {
885
982
  const model = this.$l;
886
983
  return model.list();
887
984
  }
888
985
  },
889
- $super: {
986
+ $ownMembers: {
890
987
  enumerable: true,
988
+ get () {
989
+ return this[Symbol.for('ownMembers')];
990
+ }
991
+ },
992
+ [Symbol.for('super')]: {
993
+ enumerable: false,
891
994
  get () {
892
995
  const env = vm.getEnv();
893
996
  const C = this.$s.$C;
894
997
  return new C(this.$h, STRATEGY_DIRECT, env);
895
998
  }
896
999
  },
897
- $s: {
1000
+ $super: {
1001
+ enumerable: true,
1002
+ get () {
1003
+ return this[Symbol.for('super')];
1004
+ }
1005
+ },
1006
+ [Symbol.for('s')]: {
1007
+ enumerable: false,
898
1008
  get () {
899
1009
  const proto = Object.getPrototypeOf(this);
900
1010
 
@@ -934,13 +1044,25 @@ Object.defineProperties(Wrapper.prototype, {
934
1044
  return superWrapper;
935
1045
  }
936
1046
  },
937
- $isSameObject: {
1047
+ $s: {
1048
+ get () {
1049
+ return this[Symbol.for('s')];
1050
+ }
1051
+ },
1052
+ [Symbol.for('isSameObject')]: {
1053
+ enumerable: false,
938
1054
  value (obj) {
939
1055
  const env = vm.getEnv();
940
1056
  return env.isSameObject(obj.$h, this.$h);
941
1057
  }
942
1058
  },
943
- $getCtor: {
1059
+ $isSameObject: {
1060
+ value (obj) {
1061
+ return this[Symbol.for('isSameObject')](obj);
1062
+ }
1063
+ },
1064
+ [Symbol.for('getCtor')]: {
1065
+ enumerable: false,
944
1066
  value (type) {
945
1067
  const slot = this.$c;
946
1068
 
@@ -959,7 +1081,13 @@ Object.defineProperties(Wrapper.prototype, {
959
1081
  return ctor[type];
960
1082
  }
961
1083
  },
962
- $borrowClassHandle: {
1084
+ $getCtor: {
1085
+ value (type) {
1086
+ return this[Symbol.for('getCtor')](type);
1087
+ }
1088
+ },
1089
+ [Symbol.for('borrowClassHandle')]: {
1090
+ enumerable: false,
963
1091
  value (env) {
964
1092
  const className = this.$n;
965
1093
  const classHandles = this.$f._classHandles;
@@ -973,7 +1101,13 @@ Object.defineProperties(Wrapper.prototype, {
973
1101
  return handle.ref();
974
1102
  }
975
1103
  },
976
- $copyClassHandle: {
1104
+ $borrowClassHandle: {
1105
+ value (env) {
1106
+ return this[Symbol.for('borrowClassHandle')](env);
1107
+ }
1108
+ },
1109
+ [Symbol.for('copyClassHandle')]: {
1110
+ enumerable: false,
977
1111
  value (env) {
978
1112
  const h = this.$borrowClassHandle(env);
979
1113
  try {
@@ -983,7 +1117,13 @@ Object.defineProperties(Wrapper.prototype, {
983
1117
  }
984
1118
  }
985
1119
  },
986
- $getHandle: {
1120
+ $copyClassHandle: {
1121
+ value (env) {
1122
+ return this[Symbol.for('copyClassHandle')](env);
1123
+ }
1124
+ },
1125
+ [Symbol.for('getHandle')]: {
1126
+ enumerable: false,
987
1127
  value (env) {
988
1128
  const handle = this.$h;
989
1129
 
@@ -996,7 +1136,13 @@ Object.defineProperties(Wrapper.prototype, {
996
1136
  return handle;
997
1137
  }
998
1138
  },
999
- $list: {
1139
+ $getHandle: {
1140
+ value (env) {
1141
+ return this[Symbol.for('getHandle')](env);
1142
+ }
1143
+ },
1144
+ [Symbol.for('list')]: {
1145
+ enumerable: false,
1000
1146
  value () {
1001
1147
  const superWrapper = this.$s;
1002
1148
  const superMembers = (superWrapper !== null) ? superWrapper.$list() : [];
@@ -1005,7 +1151,13 @@ Object.defineProperties(Wrapper.prototype, {
1005
1151
  return Array.from(new Set(superMembers.concat(model.list())));
1006
1152
  }
1007
1153
  },
1008
- $has: {
1154
+ $list: {
1155
+ get () {
1156
+ return this[Symbol.for('list')];
1157
+ }
1158
+ },
1159
+ [Symbol.for('has')]: {
1160
+ enumerable: false,
1009
1161
  value (member) {
1010
1162
  const members = this.$m;
1011
1163
  if (members.has(member)) {
@@ -1025,7 +1177,13 @@ Object.defineProperties(Wrapper.prototype, {
1025
1177
  return false;
1026
1178
  }
1027
1179
  },
1028
- $find: {
1180
+ $has: {
1181
+ value (member) {
1182
+ return this[Symbol.for('has')](member);
1183
+ }
1184
+ },
1185
+ [Symbol.for('find')]: {
1186
+ enumerable: false,
1029
1187
  value (member) {
1030
1188
  const members = this.$m;
1031
1189
 
@@ -1056,7 +1214,13 @@ Object.defineProperties(Wrapper.prototype, {
1056
1214
  return null;
1057
1215
  }
1058
1216
  },
1059
- toJSON: {
1217
+ $find: {
1218
+ value (member) {
1219
+ return this[Symbol.for('find')](member);
1220
+ }
1221
+ },
1222
+ [Symbol.for('toJSON')]: {
1223
+ enumerable: false,
1060
1224
  value () {
1061
1225
  const wrapperName = this.$n;
1062
1226
 
@@ -1072,6 +1236,11 @@ Object.defineProperties(Wrapper.prototype, {
1072
1236
 
1073
1237
  return `<instance: ${wrapperName}, $className: ${actualName}>`;
1074
1238
  }
1239
+ },
1240
+ toJSON: {
1241
+ get () {
1242
+ return this[Symbol.for('toJSON')];
1243
+ }
1075
1244
  }
1076
1245
  });
1077
1246
 
@@ -1409,6 +1578,10 @@ dispatcherPrototype = Object.create(Function.prototype, {
1409
1578
  return method.apply(receiver, args);
1410
1579
  }
1411
1580
 
1581
+ if (this.methodName === 'toString') {
1582
+ return `<class: ${receiver.$n}>`;
1583
+ }
1584
+
1412
1585
  throwOverloadError(this.methodName, this.overloads, 'argument types do not match any of:');
1413
1586
  }
1414
1587
  }
@@ -1647,6 +1820,12 @@ methodPrototype = Object.create(Function.prototype, {
1647
1820
  env.popLocalFrame(NULL);
1648
1821
  }
1649
1822
  }
1823
+ },
1824
+ toString: {
1825
+ enumerable: true,
1826
+ value () {
1827
+ return `function ${this.methodName}(${this.argumentTypes.map(t => t.className).join(', ')}): ${this.returnType.className}`;
1828
+ }
1650
1829
  }
1651
1830
  });
1652
1831
 
@@ -1972,6 +2151,22 @@ Object.defineProperties(Field.prototype, {
1972
2151
  get () {
1973
2152
  return this._p[2];
1974
2153
  }
2154
+ },
2155
+ toString: {
2156
+ enumerable: true,
2157
+ value () {
2158
+ const inlineString = `Java.Field{holder: ${this.holder}, fieldType: ${this.fieldType}, fieldReturnType: ${this.fieldReturnType}, value: ${this.value}}`;
2159
+ if (inlineString.length < 200) {
2160
+ return inlineString;
2161
+ }
2162
+ const multilineString = `Java.Field{
2163
+ \tholder: ${this.holder},
2164
+ \tfieldType: ${this.fieldType},
2165
+ \tfieldReturnType: ${this.fieldReturnType},
2166
+ \tvalue: ${this.value},
2167
+ }`;
2168
+ return multilineString.split('\n').map(l => l.length > 200 ? l.slice(0, l.indexOf(' ') + 1) + '...,' : l).join('\n');
2169
+ },
1975
2170
  }
1976
2171
  });
1977
2172
 
package/lib/jvm.js CHANGED
@@ -765,7 +765,7 @@ function readJvmMethod (method, constMethod, constMethodSize) {
765
765
  : NULL;
766
766
 
767
767
  return {
768
- method: method,
768
+ method,
769
769
  methodSize: spec.method.size,
770
770
  const: constMethod,
771
771
  constSize: constMethodSize,
@@ -844,7 +844,7 @@ function _getJvmMethodSpec () {
844
844
  };
845
845
 
846
846
  return {
847
- getAdapterPointer: getAdapterPointer,
847
+ getAdapterPointer,
848
848
  method: {
849
849
  size: methodSize,
850
850
  constMethodOffset,
package/lib/mkdex.js CHANGED
@@ -800,7 +800,7 @@ function computeModel (classes) {
800
800
  methods: methodItems,
801
801
  protos: protoItems,
802
802
  parameters: parameterItems,
803
- annotationDirectories: annotationDirectories,
803
+ annotationDirectories,
804
804
  annotationSets: annotationSetItems,
805
805
  throwsAnnotations: throwsAnnotationItems,
806
806
  types: typeItems,
package/lib/result.js CHANGED
@@ -7,6 +7,6 @@ function checkJniResult (name, result) {
7
7
  }
8
8
 
9
9
  module.exports = {
10
- checkJniResult: checkJniResult,
10
+ checkJniResult,
11
11
  JNI_OK: 0
12
12
  };
package/lib/types.js CHANGED
@@ -51,6 +51,9 @@ const primitiveTypes = {
51
51
  },
52
52
  write (address, value) {
53
53
  address.writeU8(value);
54
+ },
55
+ toString () {
56
+ return this.name;
54
57
  }
55
58
  },
56
59
  byte: {
@@ -69,6 +72,9 @@ const primitiveTypes = {
69
72
  },
70
73
  write (address, value) {
71
74
  address.writeS8(value);
75
+ },
76
+ toString () {
77
+ return this.name;
72
78
  }
73
79
  },
74
80
  char: {
@@ -96,6 +102,9 @@ const primitiveTypes = {
96
102
  },
97
103
  write (address, value) {
98
104
  address.writeU16(value);
105
+ },
106
+ toString () {
107
+ return this.name;
99
108
  }
100
109
  },
101
110
  short: {
@@ -114,6 +123,9 @@ const primitiveTypes = {
114
123
  },
115
124
  write (address, value) {
116
125
  address.writeS16(value);
126
+ },
127
+ toString () {
128
+ return this.name;
117
129
  }
118
130
  },
119
131
  int: {
@@ -132,6 +144,9 @@ const primitiveTypes = {
132
144
  },
133
145
  write (address, value) {
134
146
  address.writeS32(value);
147
+ },
148
+ toString () {
149
+ return this.name;
135
150
  }
136
151
  },
137
152
  long: {
@@ -150,6 +165,9 @@ const primitiveTypes = {
150
165
  },
151
166
  write (address, value) {
152
167
  address.writeS64(value);
168
+ },
169
+ toString () {
170
+ return this.name;
153
171
  }
154
172
  },
155
173
  float: {
@@ -168,6 +186,9 @@ const primitiveTypes = {
168
186
  },
169
187
  write (address, value) {
170
188
  address.writeFloat(value);
189
+ },
190
+ toString () {
191
+ return this.name;
171
192
  }
172
193
  },
173
194
  double: {
@@ -186,6 +207,9 @@ const primitiveTypes = {
186
207
  },
187
208
  write (address, value) {
188
209
  address.writeDouble(value);
210
+ },
211
+ toString () {
212
+ return this.name;
189
213
  }
190
214
  },
191
215
  void: {
@@ -202,6 +226,9 @@ const primitiveTypes = {
202
226
  },
203
227
  toJni () {
204
228
  return NULL;
229
+ },
230
+ toString () {
231
+ return this.name;
205
232
  }
206
233
  }
207
234
  };
@@ -345,6 +372,9 @@ function getAnyObjectType (typeName, unbox, factory) {
345
372
  }
346
373
 
347
374
  return o.$h;
375
+ },
376
+ toString () {
377
+ return this.name;
348
378
  }
349
379
  };
350
380
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frida-java-bridge",
3
- "version": "6.2.3",
3
+ "version": "6.2.4",
4
4
  "description": "Java runtime interop from Frida",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -18,42 +18,18 @@
18
18
  },
19
19
  "homepage": "https://github.com/frida/frida-java-bridge#readme",
20
20
  "scripts": {
21
- "lint": "semistandard"
21
+ "lint": "eslint lib",
22
+ "fix": "eslint --fix lib"
22
23
  },
23
24
  "dependencies": {
24
25
  "jssha": "^3.1.2"
25
26
  },
26
27
  "devDependencies": {
27
- "semistandard": "^16.0.0"
28
- },
29
- "semistandard": {
30
- "globals": [
31
- "Arm64Relocator",
32
- "Arm64Writer",
33
- "CModule",
34
- "DebugSymbol",
35
- "File",
36
- "Instruction",
37
- "Int64",
38
- "Interceptor",
39
- "MatchPattern",
40
- "Memory",
41
- "Module",
42
- "NULL",
43
- "NativeCallback",
44
- "NativeFunction",
45
- "NativePointer",
46
- "Process",
47
- "Script",
48
- "Thread",
49
- "ThumbRelocator",
50
- "ThumbWriter",
51
- "UnixInputStream",
52
- "UnixOutputStream",
53
- "X86Relocator",
54
- "X86Writer",
55
- "ptr",
56
- "uint64"
57
- ]
28
+ "eslint": "^8.33.0",
29
+ "eslint-config-semistandard": "^17.0.0",
30
+ "eslint-config-standard": "^17.0.0",
31
+ "eslint-plugin-import": "^2.27.5",
32
+ "eslint-plugin-n": "^15.6.1",
33
+ "eslint-plugin-promise": "^6.1.1"
58
34
  }
59
35
  }