-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage_path.py
executable file
·74 lines (63 loc) · 2.29 KB
/
storage_path.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""
Responsible to
"""
__author__ = "Gustavo Luvizotto Cesar"
__email__ = "[email protected]"
from datetime import datetime, timezone
filename_scan_dict = {
"hosts.csv": "tcp",
# SSH scan results
"host_keys.csv": "ssh",
"relations.csv": "ssh",
# TLS scan results
"certs.csv": "tls",
"cert_chain.csv": "tls",
"scsv.csv": "scsv",
"http.csv": "http",
"http_verbose.csv": "http",
"tls_verbose.csv": "tls",
"dissectls.csv": "dissectls",
"stapled_ocsp_responses.csv": "tls",
"jarm.csv": "jarm",
"tls-keylog": "tls",
"fingerprints.csv": "tls",
# ldap scan results
"starttls_ldap.csv": "starttls_ldap",
"ldap.csv": "ldap",
"ldap_root_dse.csv": "ldap_metadata",
"ldap_schema.csv": "ldap_metadata",
"ldap_root_dse_raw.csv": "ldap_metadata",
}
def _get_year_month_day(timestamp: str = None) -> str:
if timestamp:
dt = datetime.strptime(timestamp, "%Y%m%d")
else:
dt = datetime.now(timezone.utc)
year = dt.year
month = dt.month
day = dt.day
return f"year={year:02d}/month={month:02d}/day={day:02d}"
class GoScannerStoragePath(object):
"""asd"""
def get_path(self, filename: str, port: int) -> str:
"""
:param filename: E.g.
cert_chain.csv certs.csv fingerprints.csv hosts.csv tls-keylog tls_verbose.csv
:param port: port number
:return: E.g.
measurements/tool=goscanner/format=raw/port=389/scan=tls/result=fingerprints/year=2023/month=07/day=27/fingerprints.csv
List of possible results:
https://github.com/tumi8/goscanner/blob/c24ae90b07a925629bfcb3d8c45085bb8ac34df1/scanner/results/result.go#L9
List of possible scans:
https://github.com/tumi8/goscanner/blob/c24ae90b07a925629bfcb3d8c45085bb8ac34df1/scanner/scanner.go#L20
"""
year_month_day = _get_year_month_day()
result = filename.split(".")[0]
scan = filename_scan_dict[filename]
return f"measurements/tool=goscanner/format=raw/port={port}/scan={scan}/result={result}/{year_month_day}/{filename}"
class AllowlistStoragePath(object):
"""asd"""
@staticmethod
def get_prefix(port: int) -> str:
return f"measurements/tool=zmap/dataset=default/port={port}/"