cscg is loooong
This commit is contained in:
21
2026/cscg/misc/can-i-have-flag/big_endian.py
Normal file
21
2026/cscg/misc/can-i-have-flag/big_endian.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import struct
|
||||
|
||||
with open("digital-0.bin", "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
num_transitions = (len(data) - 44) // 8
|
||||
|
||||
# Read integers as little-endian (normal), but doubles as big-endian
|
||||
initial_state = struct.unpack_from('<I', data, 16)[0]
|
||||
begin_time = struct.unpack_from('>d', data, 20)[0] # big-endian
|
||||
end_time = struct.unpack_from('>d', data, 28)[0] # big-endian
|
||||
|
||||
print(f"initial_state={initial_state}, begin={begin_time:.9f}, end={end_time:.9f}")
|
||||
|
||||
transitions = []
|
||||
for i in range(num_transitions):
|
||||
t = struct.unpack_from('>d', data, 44 + i * 8)[0]
|
||||
transitions.append(t)
|
||||
|
||||
for i, t in enumerate(transitions[:20]):
|
||||
print(f" [{i}] {t:.9f}s")
|
||||
BIN
2026/cscg/misc/can-i-have-flag/digital_edited.bin
Normal file
BIN
2026/cscg/misc/can-i-have-flag/digital_edited.bin
Normal file
Binary file not shown.
23
2026/cscg/misc/can-i-have-flag/fingerprint.py
Normal file
23
2026/cscg/misc/can-i-have-flag/fingerprint.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import struct
|
||||
|
||||
with open("digital-0.bin", "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
# Skip header (already known to be mangled)
|
||||
offset = 16
|
||||
|
||||
# Try Version 0 interpretation
|
||||
v0_initial_state = struct.unpack_from('<I', data, offset)[0]
|
||||
v0_begin_time = struct.unpack_from('<d', data, offset + 4)[0]
|
||||
v0_end_time = struct.unpack_from('<d', data, offset + 12)[0]
|
||||
v0_num_trans = struct.unpack_from('<Q', data, offset + 20)[0]
|
||||
print(f"V0: init={v0_initial_state}, begin={v0_begin_time:.4f}, end={v0_end_time:.4f}, transitions={v0_num_trans}")
|
||||
|
||||
# Try Version 1 interpretation
|
||||
v1_chunk_count = struct.unpack_from('<Q', data, offset)[0]
|
||||
v1_initial_state = struct.unpack_from('<I', data, offset + 8)[0]
|
||||
v1_sample_rate = struct.unpack_from('<d', data, offset + 12)[0]
|
||||
v1_begin_time = struct.unpack_from('<d', data, offset + 20)[0]
|
||||
v1_end_time = struct.unpack_from('<d', data, offset + 28)[0]
|
||||
v1_num_trans = struct.unpack_from('<Q', data, offset + 36)[0]
|
||||
print(f"V1: chunks={v1_chunk_count}, init={v1_initial_state}, rate={v1_sample_rate:.0f}, begin={v1_begin_time:.4f}, end={v1_end_time:.4f}, transitions={v1_num_trans}")
|
||||
18
2026/cscg/misc/can-i-have-flag/guess.py
Normal file
18
2026/cscg/misc/can-i-have-flag/guess.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import struct
|
||||
|
||||
with open("digital-0.bin", "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
num_transitions = (len(data) - 44) // 8
|
||||
SAMPLE_RATE = 125_000_000
|
||||
|
||||
initial_state = struct.unpack_from('<I', data, 16)[0]
|
||||
print(f"initial_state={initial_state}")
|
||||
|
||||
transitions = []
|
||||
for i in range(num_transitions):
|
||||
raw = struct.unpack_from('<Q', data, 44 + i * 8)[0] # uint64 little-endian
|
||||
t = raw / SAMPLE_RATE
|
||||
transitions.append(t)
|
||||
if i < 30:
|
||||
print(f" [{i}] raw={raw}, time={t:.9f}s")
|
||||
26
2026/cscg/misc/can-i-have-flag/measure_distance.py
Normal file
26
2026/cscg/misc/can-i-have-flag/measure_distance.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from collections import Counter
|
||||
|
||||
|
||||
HEADER = bytes.fromhex("4769495E417C4370")
|
||||
|
||||
|
||||
idx = []
|
||||
|
||||
with open("./digital-0.bin", "rb") as f:
|
||||
data = f.read()
|
||||
four_bytes = [data[i:i+4] for i in range(0, len(data), 4)]
|
||||
eight_bytes = [data[i:i+8] for i in range(0, len(data), 8)]
|
||||
|
||||
counts_four = Counter(four_bytes)
|
||||
counts_eight = Counter(eight_bytes)
|
||||
|
||||
print(counts_four)
|
||||
print(counts_eight)
|
||||
|
||||
for i in range(len(idx)):
|
||||
if i > 0:
|
||||
print(idx[i] - idx[i-1])
|
||||
else:
|
||||
print(idx[i] )
|
||||
|
||||
|
||||
17
2026/cscg/misc/can-i-have-flag/parse_v0.py
Normal file
17
2026/cscg/misc/can-i-have-flag/parse_v0.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import struct
|
||||
|
||||
with open("digital-0.bin", "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
file_size = len(data)
|
||||
num_transitions = (file_size - 44) // 8
|
||||
|
||||
print(f"File size: {file_size}")
|
||||
print(f"Computed transitions: {num_transitions}")
|
||||
|
||||
# Parse transitions
|
||||
transitions = struct.unpack_from(f'<{num_transitions}d', data, 44)
|
||||
|
||||
# Print first few
|
||||
for i, t in enumerate(transitions[:20]):
|
||||
print(f" [{i}] {t:.9f}s")
|
||||
Reference in New Issue
Block a user