-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyse.py
44 lines (39 loc) · 991 Bytes
/
analyse.py
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
38
39
40
41
42
43
44
import duckdb
import json
import base64
import struct
# First, read the JSON file
with open('files/masterlist_284.json', 'r') as f:
data = json.load(f)
# Create a table from the data
query = """
WITH json_data AS (
SELECT *
FROM data
)
SELECT
pubkey->>'exponent' as exponent,
COUNT(*) as count
FROM json_data
WHERE pubkey->>'type' = 'RSA'
GROUP BY pubkey->>'exponent'
ORDER BY count DESC;
"""
# Execute the query
result = duckdb.sql(query)
print("\nExponent distribution:")
print(result.df())
# To also show the actual decimal values of the exponents
def b64_to_int(b64_str):
try:
decoded = base64.b64decode(b64_str)
# Convert bytes to integer
return int.from_bytes(decoded, 'big')
except:
return None
print("\nDecimal values of exponents:")
for row in result.fetchall():
b64_exp = row[0]
count = row[1]
decimal_value = b64_to_int(b64_exp)
print(f"Base64: {b64_exp}, Decimal: {decimal_value}, Count: {count}")