frida-fusion 0.1.9__tar.gz → 0.1.10__tar.gz

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.

Potentially problematic release.


This version of frida-fusion might be problematic. Click here for more details.

Files changed (31) hide show
  1. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/PKG-INFO +1 -1
  2. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/__meta__.py +2 -2
  3. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/libs/database.py +11 -0
  4. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/libs/helpers.js +29 -0
  5. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/libs/logger.py +1 -1
  6. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/modules/crypto/crypto.js +27 -34
  7. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/modules/crypto/crypto.py +185 -66
  8. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion.egg-info/PKG-INFO +1 -1
  9. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/LICENSE +0 -0
  10. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/README.md +0 -0
  11. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/__init__.py +0 -0
  12. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/__main__.py +0 -0
  13. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/args.py +0 -0
  14. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/config.py +0 -0
  15. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/fusion.py +0 -0
  16. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/libs/__init__.py +0 -0
  17. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/libs/color.py +0 -0
  18. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/libs/scriptlocation.py +0 -0
  19. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/module.py +0 -0
  20. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/modules/__init__.py +0 -0
  21. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/modules/crypto/__init__.py +0 -0
  22. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/modules/tls_unpinning/__init__.py +0 -0
  23. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion/modules/tls_unpinning/frida_multiple_unpinning.py +0 -0
  24. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion.egg-info/SOURCES.txt +0 -0
  25. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion.egg-info/dependency_links.txt +0 -0
  26. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion.egg-info/entry_points.txt +0 -0
  27. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion.egg-info/requires.txt +0 -0
  28. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/frida_fusion.egg-info/top_level.txt +0 -0
  29. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/pyproject.toml +0 -0
  30. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/setup.cfg +0 -0
  31. {frida_fusion-0.1.9 → frida_fusion-0.1.10}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: frida-fusion
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Hook your mobile tests with Frida
5
5
  Author-email: "Helvio Junior (M4v3r1ck)" <helvio_junior@hotmail.com>
6
6
  Maintainer-email: "Helvio Junior (M4v3r1ck)" <helvio_junior@hotmail.com>
@@ -1,8 +1,8 @@
1
- __version__ = '0.1.9'
1
+ __version__ = '0.1.10'
2
2
  __title__ = "Frida Fusion"
3
3
  __description__ = "📱 frida-fusion - runtime mobile exploration"
4
4
  __url__ = "https://github.com/helviojunior/frida-fusion"
5
- __build__ = 0x2c0d061
5
+ __build__ = 0x3c147be
6
6
  __author__ = "Helvio Junior (M4v3r1ck)"
7
7
  __author_email__ = "helvio_junior@hotmail.com"
8
8
  __license__ = "GPL-3.0"
@@ -81,6 +81,17 @@ class Database(object):
81
81
  conn.execute(sql, values)
82
82
  conn.commit()
83
83
 
84
+ @connect
85
+ def insert_if_not_exists(self, conn: Connection, table_name, **kwargs):
86
+ table_name = self.scrub(table_name)
87
+
88
+ if self.select_count(table_name=table_name, **kwargs) == 0:
89
+ (columns, values) = self.parse_args(kwargs)
90
+ sql = "INSERT INTO {} ({}) VALUES ({})" \
91
+ .format(table_name, ','.join(columns), ', '.join(['?'] * len(columns)))
92
+ conn.execute(sql, values)
93
+ conn.commit()
94
+
84
95
  @connect
85
96
  def insert_ignore_one(self, conn: Connection, table_name, **kwargs):
86
97
  table_name = self.scrub(table_name)
@@ -214,6 +214,35 @@ function fusion_printMethods(targetClass)
214
214
  });
215
215
  }
216
216
 
217
+ function fusion_getClassName(obj)
218
+ {
219
+ if (obj === null || obj === undefined) return "";
220
+
221
+ try {
222
+ // Caso seja um objeto Java real
223
+ if (obj.$className !== undefined) {
224
+ // Objetos instanciados via Java.use
225
+ return obj.$className;
226
+ }
227
+
228
+ // Caso seja uma instância Java (não necessariamente via Java.use)
229
+ if (Java.isJavaObject(obj)) {
230
+ return obj.getClass().getName();
231
+ }
232
+
233
+ // Caso seja uma classe Java carregada (Java.use)
234
+ if (Java.isJavaClass(obj)) {
235
+ return obj.class.getName();
236
+ }
237
+
238
+ // Se for algo não Java, apenas retorna tipo do JS
239
+ return typeof obj;
240
+ } catch (err) {
241
+ fusion_sendMessage("W", err);
242
+ return '';
243
+ }
244
+
245
+ }
217
246
 
218
247
  Java.perform(function () {
219
248
  const Thread = Java.use('java.lang.Thread');
@@ -41,7 +41,7 @@ class Logger(object):
41
41
  if Logger.out_file != '':
42
42
  try:
43
43
  with open(Logger.out_file, "a") as text_file:
44
- text_file.write(Color.sc(text) + '\n')
44
+ text_file.write(Color.escape_ansi(Color.sc(text)) + '\n')
45
45
  except:
46
46
  pass
47
47
 
@@ -86,9 +86,10 @@ setTimeout(function() {
86
86
  const secretKeySpec = Java.use("javax.crypto.spec.SecretKeySpec");
87
87
  secretKeySpec.$init.overload("[B", "java.lang.String").implementation = function (key, cipher) {
88
88
  const keyBase64 = fusion_bytesToBase64(key);
89
- fusion_sendKeyValueData("secretKeySpec.init", [
89
+ fusion_sendKeyValueData("SecretKeySpec.init", [
90
90
  {key: "Key", value: keyBase64},
91
- {key: "Algorithm", value: cipher}
91
+ {key: "Algorithm", value: cipher},
92
+ {key: "ClassType", value: fusion_getClassName(this)}
92
93
  ]);
93
94
  return secretKeySpec.$init.overload("[B", "java.lang.String").call(this, key, cipher);
94
95
  }
@@ -141,42 +142,20 @@ setTimeout(function() {
141
142
  return output;
142
143
  };
143
144
 
144
- /*
145
- messageDigest.digest.overload("[B").implementation = function (input) {
146
- const inputBase64 = fusion_bytesToBase64(input);
147
- fusion_sendKeyValueData("messageDigest.digest", [
148
- {key: "Input", value: inputBase64},
149
- {key: "Algorithm", value: this.getAlgorithm()}
150
- ]);
151
- return this.digest.overload("[B").call(this, input);
152
- };
153
-
154
- messageDigest.digest.overload("[B", "int", "int").implementation = function (input, offset, len) {
155
- const inputBase64 = fusion_bytesToBase64(input);
156
- fusion_sendKeyValueData("messageDigest.digest", [
157
- {key: "Input", value: inputBase64},
158
- {key: "Algorithm", value: this.getAlgorithm()},
159
- {key: "Offset", value: offset},
160
- {key: "Length", value: len}
161
- ]);
162
- return this.digest.overload("[B", "int", "int").call(this, input, offset, len);
163
- };*/
164
-
165
-
166
145
  }
167
146
 
168
147
  if (MODULES.SecretKeyFactory) {
169
148
  fusion_sendMessage('*', "Module attached: javax.crypto.SecretKeyFactory");
170
149
  const secretKeyFactory = Java.use("javax.crypto.SecretKeyFactory");
171
150
  secretKeyFactory.getInstance.overload("java.lang.String").implementation = function (arg0) {
172
- fusion_sendKeyValueData("secretKeyFactory.getInstance", [
151
+ fusion_sendKeyValueData("SecretKeyFactory.getInstance", [
173
152
  {key: "Algorithm", value: arg0}
174
153
  ]);
175
154
  return this.getInstance(arg0);
176
155
  };
177
156
 
178
157
  secretKeyFactory.getInstance.overload("java.lang.String", "java.lang.String").implementation = function (arg0, arg1) {
179
- fusion_sendKeyValueData("secretKeyFactory.getInstance", [
158
+ fusion_sendKeyValueData("SecretKeyFactory.getInstance", [
180
159
  {key: "Algorithm", value: arg0},
181
160
  {key: "Provider", value: arg1}
182
161
  ]);
@@ -184,7 +163,7 @@ setTimeout(function() {
184
163
  };
185
164
 
186
165
  secretKeyFactory.getInstance.overload("java.lang.String", "java.security.Provider").implementation = function (arg0, arg1) {
187
- fusion_sendKeyValueData("secretKeyFactory.getInstance", [
166
+ fusion_sendKeyValueData("SecretKeyFactory.getInstance", [
188
167
  {key: "Algorithm", value: arg0},
189
168
  {key: "Provider", value: arg1}
190
169
  ]);
@@ -229,6 +208,7 @@ setTimeout(function() {
229
208
  fusion_sendKeyValueData("cipher.init", [
230
209
  {key: "HashCode", value: this.hashCode().toString()},
231
210
  {key: "Key", value: fusion_keyToBase64(key)},
211
+ {key: "KeyType", value: fusion_getClassName(key)},
232
212
  {key: "Opmode", value: this.getOpmodeString(opmode)},
233
213
  {key: "Algorithm", value: this.getAlgorithm()}
234
214
  ]);
@@ -238,7 +218,9 @@ setTimeout(function() {
238
218
  cipher.init.overload("int", "java.security.cert.Certificate").implementation = function (opmode, certificate) {
239
219
  fusion_sendKeyValueData("cipher.init", [
240
220
  {key: "HashCode", value: this.hashCode().toString()},
221
+ {key: "Key", value: fusion_keyToBase64(certificate)},
241
222
  {key: "Certificate", value: fusion_keyToBase64(certificate)},
223
+ {key: "KeyType", value: fusion_getClassName(certificate)},
242
224
  {key: "Opmode", value: this.getOpmodeString(opmode)},
243
225
  {key: "Algorithm", value: this.getAlgorithm()}
244
226
  ]);
@@ -249,6 +231,7 @@ setTimeout(function() {
249
231
  fusion_sendKeyValueData("cipher.init", [
250
232
  {key: "HashCode", value: this.hashCode().toString()},
251
233
  {key: "Key", value: fusion_keyToBase64(key)},
234
+ {key: "KeyType", value: fusion_getClassName(key)},
252
235
  {key: "Opmode", value: this.getOpmodeString(opmode)},
253
236
  {key: "Algorithm", value: this.getAlgorithm()}
254
237
  ]);
@@ -261,6 +244,7 @@ setTimeout(function() {
261
244
  var data = [
262
245
  {key: "HashCode", value: this.hashCode().toString()},
263
246
  {key: "Key", value: fusion_keyToBase64(key)},
247
+ {key: "KeyType", value: fusion_getClassName(key)},
264
248
  {key: "Opmode", value: this.getOpmodeString(opmode)},
265
249
  {key: "Algorithm", value: this.getAlgorithm()}
266
250
  ];
@@ -487,7 +471,8 @@ setTimeout(function() {
487
471
  const ivParameter = Java.use("javax.crypto.spec.IvParameterSpec");
488
472
  ivParameter.$init.overload("[B").implementation = function (ivKey) {
489
473
  fusion_sendKeyValueData("IvParameterSpec.init", [
490
- {key: "IV_Key", value: fusion_bytesToBase64(ivKey)}
474
+ {key: "IV_Key", value: fusion_bytesToBase64(ivKey)},
475
+ {key: "ClassType", value: fusion_getClassName(this)}
491
476
  ]);
492
477
  return this.$init.overload("[B").call(this, ivKey);
493
478
  }
@@ -496,7 +481,8 @@ setTimeout(function() {
496
481
  fusion_sendKeyValueData("IvParameterSpec.init", [
497
482
  {key: "IV Key", value: fusion_bytesToBase64(ivKey)},
498
483
  {key: "Offset", value: offset},
499
- {key: "Length", value: len}
484
+ {key: "Length", value: len},
485
+ {key: "ClassType", value: fusion_getClassName(this)}
500
486
  ]);
501
487
  return this.$init.overload("[B", "int", "int").call(this, ivKey, offset, len);
502
488
  }
@@ -508,7 +494,8 @@ setTimeout(function() {
508
494
  gcmParameter.$init.overload("int", "[B").implementation = function (tLen, ivKey) {
509
495
  fusion_sendKeyValueData("GCMParameterSpec.init", [
510
496
  {key: "IV_Key", value: fusion_bytesToBase64(ivKey)},
511
- {key: "Auth_Tag_Length", value: tLen.toString()}
497
+ {key: "Auth_Tag_Length", value: tLen.toString()},
498
+ {key: "ClassType", value: fusion_getClassName(this)}
512
499
  ]);
513
500
  return this.$init.overload("int", "[B").call(this, tLen, ivKey);
514
501
  }
@@ -518,7 +505,8 @@ setTimeout(function() {
518
505
  {key: "IV_Key", value: fusion_bytesToBase64(ivKey)},
519
506
  {key: "Auth_Tag_Length", value: tLen.toString()},
520
507
  {key: "Offset", value: offset},
521
- {key: "Length", value: len}
508
+ {key: "Length", value: len},
509
+ {key: "ClassType", value: fusion_getClassName(this)}
522
510
  ]);
523
511
  return this.$init.overload("int", "[B", "int", "int").call(this, tLen, ivKey, offset, len);
524
512
  }
@@ -530,7 +518,8 @@ setTimeout(function() {
530
518
  pbeParameter.$init.overload("[B", "int").implementation = function (salt, iterationCount) {
531
519
  fusion_sendKeyValueData("PBEParameterSpec.init", [
532
520
  {key: "PBE_Salt", value: fusion_bytesToBase64(salt)},
533
- {key: "Iteration_Count", value: iterationCount.toString()}
521
+ {key: "Iteration_Count", value: iterationCount.toString()},
522
+ {key: "ClassType", value: fusion_getClassName(this)},
534
523
  ]);
535
524
  return this.$init.overload("[B", "int").call(this, salt, iterationCount);
536
525
  }
@@ -539,7 +528,8 @@ setTimeout(function() {
539
528
 
540
529
  var data = [
541
530
  {key: "PBE_Salt", value: fusion_bytesToBase64(salt)},
542
- {key: "Iteration_Count", value: iterationCount.toString()}
531
+ {key: "Iteration_Count", value: iterationCount.toString()},
532
+ {key: "ClassType", value: fusion_getClassName(this)}
543
533
 
544
534
  ]
545
535
 
@@ -547,6 +537,7 @@ setTimeout(function() {
547
537
  data = data.concat([
548
538
  {key: "Algorithm", value: paramSpec.getAlgorithm()},
549
539
  {key: "ParamSpec", value: fusion_keyToBase64(paramSpec)},
540
+ {key: "ParamSpecType", value: fusion_getClassName(paramSpec)},
550
541
  {key: "Provider", value: paramSpec.getProvider()}
551
542
  ]);
552
543
  } catch (err) { }
@@ -561,7 +552,9 @@ setTimeout(function() {
561
552
  const x509EncodedKeySpec = Java.use("java.security.spec.X509EncodedKeySpec");
562
553
  x509EncodedKeySpec.$init.overload("[B").implementation = function (encodedKey) {
563
554
  fusion_sendKeyValueData("X509EncodedKeySpec.init", [
564
- {key: "Key", value: fusion_bytesToBase64(encodedKey)}
555
+ {key: "Key", value: fusion_bytesToBase64(encodedKey)},
556
+ {key: "ClassType", value: fusion_getClassName(this)}
557
+
565
558
  ]);
566
559
  return this.$init.overload("[B").call(this, encodedKey);
567
560
  }
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import os.path
2
3
  from pathlib import Path
3
4
  import base64
@@ -31,10 +32,10 @@ class Crypto(ModuleBase):
31
32
  cursor.execute("""
32
33
  CREATE TABLE IF NOT EXISTS [crypto] (
33
34
  id INTEGER PRIMARY KEY AUTOINCREMENT,
34
- algorithm TEXT NOT NULL,
35
- init_key TEXT NOT NULL,
35
+ hashcode TEXT NOT NULL,
36
+ algorithm TEXT NULL,
37
+ init_key TEXT NULL,
36
38
  iv TEXT NULL,
37
- hashcode TEXT NULL,
38
39
  flow TEXT NULL,
39
40
  key TEXT NULL,
40
41
  clear_text TEXT NULL,
@@ -48,6 +49,22 @@ class Crypto(ModuleBase):
48
49
 
49
50
  conn.commit()
50
51
 
52
+ cursor.execute("""
53
+ CREATE TABLE IF NOT EXISTS [crypto_key] (
54
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
55
+ key TEXT NULL,
56
+ printable_key TEXT NULL,
57
+ salt TEXT NULL,
58
+ iteration_count INTEGER NULL DEFAULT (0),
59
+ key_class TEXT NULL DEFAULT ('<unknown>'),
60
+ additional_data TEXT NULL,
61
+ created_date datetime not null DEFAULT (datetime('now','localtime')),
62
+ UNIQUE (key, key_class)
63
+ );
64
+ """)
65
+
66
+ conn.commit()
67
+
51
68
  cursor.execute("""
52
69
  CREATE TABLE IF NOT EXISTS [digest] (
53
70
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -80,7 +97,8 @@ class Crypto(ModuleBase):
80
97
  return ''
81
98
 
82
99
  def update_crypto(self, iv=None, hashcode=None, flow=None, key=None, before_final=None,
83
- after_final=None, stack_trace=None, id=None):
100
+ after_final=None, stack_trace=None, id=None, algorithm=None,
101
+ status=None):
84
102
 
85
103
  conn = self.connect_to_db(check=False)
86
104
  cursor = conn.cursor()
@@ -116,6 +134,11 @@ class Crypto(ModuleBase):
116
134
  update += " hashcode = ?,"
117
135
  data.append(hashcode)
118
136
 
137
+ if flow is not None:
138
+ integrity = True
139
+ update += " algorithm = ?,"
140
+ data.append(algorithm)
141
+
119
142
  if flow is not None:
120
143
  integrity = True
121
144
  update += " flow = ?,"
@@ -136,6 +159,11 @@ class Crypto(ModuleBase):
136
159
  update += " stack_trace = ?,"
137
160
  data.append(stack_trace)
138
161
 
162
+ if status is not None:
163
+ integrity = True
164
+ update += " status = ?,"
165
+ data.append(status)
166
+
139
167
  if before_final is not None:
140
168
  integrity = True
141
169
  if dbflow == "enc":
@@ -169,6 +197,16 @@ class Crypto(ModuleBase):
169
197
 
170
198
  cursor.execute(update, data)
171
199
 
200
+ cursor = conn.cursor()
201
+ cursor.execute("""
202
+ delete from [crypto]
203
+ where algorithm is null and init_key is null and key is null and clear_text is null
204
+ and hashcode in (
205
+ select hashcode from [crypto]
206
+ where id = ?
207
+ )
208
+ """, (id,))
209
+
172
210
  conn.commit()
173
211
 
174
212
  # Color.pl('{+} {W}Crypto atualizada. {C}ID: {O}%s{W}' % id)
@@ -215,56 +253,59 @@ class Crypto(ModuleBase):
215
253
 
216
254
  # Color.pl('{+} {W}Inserindo crypto. {C}Algorithm: {O}%s{W}' % algorithm)
217
255
 
218
- def insert_crypto(self, algorithm, init_key):
219
-
220
- conn = self.connect_to_db(check=False)
221
-
222
- cursor = conn.cursor()
223
- cursor.execute("""
224
- update [crypto] set status = 'incomplete' where status = 'open';
225
- """)
226
-
227
- cursor = conn.cursor()
228
- cursor.execute("""
229
- insert into [crypto] ([algorithm], [init_key])
230
- VALUES (?,?);
231
- """, (algorithm, init_key,))
232
-
233
- conn.commit()
234
-
235
- conn.close()
236
-
237
- # Color.pl('{+} {W}Inserindo crypto. {C}Algorithm: {O}%s{W}' % algorithm)
238
-
239
- def insert_crypto2(self, algorithm, key, iv, clear_text, cipher_data, flow='enc'):
240
-
241
- conn = self.connect_to_db(check=False)
242
-
243
- if isinstance(clear_text, bytes):
244
- clear_text = clear_text.decode("UTF-8")
245
-
246
- if isinstance(cipher_data, bytes):
247
- cipher_data = cipher_data.decode("UTF-8")
248
-
249
- if isinstance(key, bytes):
250
- key = base64.b64encode(key).decode("UTF-8")
251
-
252
- if isinstance(iv, bytes):
253
- iv = base64.b64encode(iv).decode("UTF-8")
256
+ def insert_crypto(self, hashcode, algorithm, init_key):
254
257
 
255
- clear_text_b64 = base64.b64encode(clear_text.encode("UTF-8")).decode("UTF-8")
258
+ if hashcode is None:
259
+ return
256
260
 
257
- cursor = conn.cursor()
258
- cursor.execute("""
259
- insert into [crypto] ([flow], [algorithm], [init_key], [key], [iv], [clear_text], [clear_text_b64], [cipher_data], [status])
260
- VALUES (?,?,?,?,?,?,?,?,?);
261
- """, (flow, algorithm, key, key, iv, clear_text, clear_text_b64, cipher_data, 'complete',))
262
-
263
- conn.commit()
264
-
265
- conn.close()
266
-
267
- # Color.pl('{+} {W}Inserindo crypto. {C}Algorithm: {O}%s{W}' % algorithm)
261
+ rows = self.select(
262
+ table_name='crypto',
263
+ hashcode=hashcode,
264
+ status='open'
265
+ )
266
+ if len(rows) == 0 or not any(iter([
267
+ True
268
+ for r in rows
269
+ if (
270
+ (algorithm is not None and algorithm == r['algorithm'])
271
+ or (r['algorithm'] is None or r['algorithm'].strip() == "")
272
+ ) and (
273
+ (
274
+ (init_key is not None and init_key != '' and init_key != 'IA==')
275
+ and (init_key == r['init_key'] or init_key == r['key'])
276
+ )
277
+ or (r['init_key'] is None or r['init_key'].strip() == "")
278
+ )
279
+ ])):
280
+ if init_key is not None and init_key != '' and init_key != 'IA==':
281
+ self.insert_one(
282
+ table_name='crypto',
283
+ hashcode=hashcode,
284
+ algorithm=algorithm,
285
+ init_key=init_key,
286
+ status='open')
287
+ else:
288
+ self.insert_one(
289
+ table_name='crypto',
290
+ hashcode=hashcode,
291
+ algorithm=algorithm,
292
+ status='open')
293
+
294
+ def insert_crypto_key(self, key, key_class, salt=None,
295
+ iteration_count=0, module="<unknown>", additional_data=dict):
296
+ if key is not None and key != '' and key != 'IA==':
297
+ self.insert_ignore_one(
298
+ table_name='crypto_key',
299
+ key=key,
300
+ printable_key=self.get_printable(key),
301
+ key_class=key_class,
302
+ salt=salt,
303
+ iteration_count=iteration_count,
304
+ additional_data=json.dumps({
305
+ **{"module": module},
306
+ **(additional_data if additional_data is not None and isinstance(additional_data, dict) else {})
307
+ }, default=Logger.json_serial)
308
+ )
268
309
 
269
310
  def __init__(self):
270
311
  super().__init__('Crypto', 'Hook cryptography/hashing functions')
@@ -290,31 +331,109 @@ class Crypto(ModuleBase):
290
331
  received_data: dict = None
291
332
  ) -> bool:
292
333
 
293
- if module == "secretKeySpec.init":
334
+ if module in ["X509EncodedKeySpec.init", "GCMParameterSpec.init", "PBEParameterSpec.init"]:
335
+
336
+ key_class = received_data.get('classtype', module)
337
+ salt = None
338
+ iteration_count = 0
339
+
340
+ key = received_data.get('key', None)
341
+ if module == "GCMParameterSpec.init":
342
+ key = received_data.get('iv_key', None)
343
+
344
+ if module == "PBEParameterSpec.init":
345
+ key = "None"
346
+ salt = received_data.get('pbe_salt', None)
347
+ iteration_count = received_data.get('iteration_count', None)
348
+
349
+ self._crypto_db.insert_crypto_key(
350
+ key=key,
351
+ key_class=key_class,
352
+ salt=salt,
353
+ iteration_count=iteration_count,
354
+ module=module,
355
+ additional_data=received_data
356
+ )
357
+
358
+ if module == "SecretKeySpec.init":
294
359
  algorithm = received_data.get('algorithm', None)
295
- bData = received_data.get('key', None)
296
- self._crypto_db.insert_crypto(algorithm, bData)
360
+ key = received_data.get('key', None)
361
+ hashcode = received_data.get('hashcode', None)
362
+ key_class = received_data.get('classtype', "SecretKeySpec")
363
+ self._crypto_db.insert_crypto(
364
+ hashcode=hashcode,
365
+ algorithm=algorithm,
366
+ init_key=key)
367
+
368
+ self._crypto_db.insert_crypto_key(
369
+ key=key,
370
+ key_class=key_class,
371
+ module=module,
372
+ additional_data=received_data
373
+ )
297
374
 
298
375
  elif module == "IvParameterSpec.init":
299
376
  bData = received_data.get('iv_key', None)
377
+ key_class = received_data.get('classtype', "IvParameterSpec")
300
378
  # print("IV: %s" % bData)
301
- self._crypto_db.update_crypto(bData)
379
+ self._crypto_db.update_crypto(iv=bData)
380
+
381
+ self._crypto_db.insert_crypto_key(
382
+ key=bData,
383
+ key_class=key_class,
384
+ module=module,
385
+ additional_data=received_data
386
+ )
302
387
 
303
388
  elif module == "cipher.init":
304
389
  hashcode = received_data.get('hashcode', None)
305
390
  opmode = received_data.get('opmode', "")
306
- if 'encrypt' in opmode:
307
- self._crypto_db.update_crypto(None, hashcode, 'enc')
308
- elif 'decrypt' in opmode:
309
- self._crypto_db.update_crypto(None, hashcode, 'dec')
391
+ key_class = received_data.get('keytype', "")
392
+ key = received_data.get('key', None)
393
+ algorithm = received_data.get('algorithm', None)
394
+
395
+ self._crypto_db.insert_crypto(
396
+ hashcode=hashcode,
397
+ algorithm=algorithm,
398
+ init_key=key
399
+ )
400
+
401
+ self._crypto_db.update_crypto(
402
+ hashcode=hashcode,
403
+ flow='enc' if 'encrypt' in opmode else ('dec' if 'decrypt' in opmode else str(opmode)),
404
+ key=key,
405
+ algorithm=algorithm
406
+ )
407
+
408
+ self._crypto_db.insert_crypto_key(
409
+ key=key,
410
+ key_class=key_class,
411
+ module=module,
412
+ additional_data=received_data
413
+ )
414
+
415
+ Logger.print_message(
416
+ level="W",
417
+ message=f"Cipher init received\nHashcode: {hashcode}\nOpmode: {opmode}\nKeytype: {key_class}",
418
+ script_location=script_location
419
+ )
310
420
 
311
421
  elif module == "cipher.doFinal":
312
- self._crypto_db.update_crypto(None, None, None, None,
313
- received_data.get('input', ''),
314
- stack_trace=stack_trace)
315
- self._crypto_db.update_crypto(None, None, None, None, None,
316
- received_data.get('output', ''),
317
- stack_trace=stack_trace)
422
+ hashcode = received_data.get('hashcode', None)
423
+
424
+ self._crypto_db.insert_crypto(
425
+ hashcode=hashcode,
426
+ algorithm=None,
427
+ init_key=None
428
+ )
429
+
430
+ self._crypto_db.update_crypto(
431
+ hashcode=hashcode,
432
+ before_final=received_data.get('input', ''),
433
+ after_final=received_data.get('output', ''),
434
+ stack_trace=stack_trace,
435
+ status="complete"
436
+ )
318
437
 
319
438
  Logger.print_message(
320
439
  level="D",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: frida-fusion
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Hook your mobile tests with Frida
5
5
  Author-email: "Helvio Junior (M4v3r1ck)" <helvio_junior@hotmail.com>
6
6
  Maintainer-email: "Helvio Junior (M4v3r1ck)" <helvio_junior@hotmail.com>
File without changes
File without changes
File without changes
File without changes