-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsqlite2json.py
More file actions
37 lines (26 loc) · 886 Bytes
/
sqlite2json.py
File metadata and controls
37 lines (26 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sqlite3
import json
hash_types_dict={}
source_libs_dict={}
symbol_hashes_dict={}
conn = sqlite3.connect('sc_hashes.db')
c = conn.cursor()
c.execute("SELECT * FROM hash_types")
hash_types = c.fetchall()
for type in hash_types:
hash_types_dict.update({type[0]:type[2]})
c.execute("SELECT * FROM source_libs")
source_libs = c.fetchall()
for source_lib in source_libs:
source_libs_dict.update({source_lib[0]:source_lib[1]})
c.execute("SELECT * FROM symbol_hashes")
symbol_hashes = c.fetchall()
for symbol_hashe in symbol_hashes:
symbol_hashes_dict.update({symbol_hashe[1]:{"hash_type":symbol_hashe[2], "lib_key":symbol_hashe[3], "symbol_name":symbol_hashe[4]}})
sc_hashes = {
"hash_types":hash_types_dict,
"source_libs":source_libs_dict,
"symbol_hashes":symbol_hashes_dict
}
with open("sc_hashes.json", 'w') as f:
json.dump(sc_hashes, f)