Closed the 0ctf challenge

This commit is contained in:
Tempest 2024-12-23 08:41:06 +07:00
parent 9e22bdef3b
commit 79e02c61ed
5 changed files with 2626 additions and 1077 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
$date
Sat Dec 21 20:09:40 2024
Sun Dec 22 12:30:21 2024
$end
$version
Icarus Verilog
@ -611,7 +611,7 @@ b10 1
b1 0
b0 /
b101010 &
b110111100110000 %
b11000001101111 %
$end
#0
$dumpvars
@ -1195,56 +1195,26 @@ b101000 (
0t
0'
#85000000
1r"
1j"
1b"
1Z"
14#
1,#
1p"
1h"
1`"
1X"
12#
1$#
1*#
b1111 y"
b1101111 _
b110 C#
1l
b10 E"
1D"
1m
b10 A"
1@"
1n
b10 ="
1<"
b1111 z"
1o
b10 9"
18"
1"#
b110000 _
b11 C#
1g
b10 V"
1U"
b11 D#
1h
b10 R"
1Q"
b110 D#
1i
b10 N"
1M"
1v
1u
1x
1w
1z
1y
1|
1{
1~
1}
b110000 r
1""
1!"
b1101111 r
1$"
1#"
b1101111 *
b1101111 [
b110000 *
b110000 [
b101001 (
b100111 )
1s
@ -1255,91 +1225,76 @@ b100111 )
0t
0'
#87000000
1<#
1b
1:#
04#
1`
1a
02#
1,#
1F#
0Z"
1H#
1*#
b111 I#
1G#
0X"
b1010 C#
b10101110 _
b1110 y"
0l
b0 E"
0D"
0@"
0<"
08"
1U"
0M"
1i
b1 N"
1L"
1("
1'"
0g
b11 V"
1T"
1*"
1)"
1r"
1p"
1e
1|"
1d
14#
1$#
1c
1f
0j"
0b"
1}"
12#
1"#
1~"
b1111 !#
1{"
0h"
0`"
b111 C#
b1111000 _
b1000 y"
1D"
1m
b1 A"
1?"
1,"
1+"
b111 B#
b100 D#
0h
b11 R"
1P"
1."
1-"
1o
b1 9"
b10 A"
1@"
1n
b10 ="
1<"
18"
0g
b0 V"
0U"
b110 D#
1i
b10 N"
1M"
0l
b11 E"
1C"
10"
1/"
b1001 x"
b110 z"
0o
b11 9"
17"
b110000 $
b110000 q
12"
11"
b1110 x"
b1110 z"
1n
b1 ="
1;"
b1101111 $
b1101111 q
14"
13"
0v
0u
0x
0w
0z
0y
0|
0{
1~
1}
b110000 r
0$"
0#"
1["
1c"
1k"
1s"
1v
1u
1x
1w
1z
1y
1|
1{
0~
0}
b1101111 r
1$"
1#"
1%#
b110000 p
1-#
b1101111 p
15#
b101000 )
b110000 *
b110000 [
b1101111 *
b1101111 [
b101010 (
1s
1t
@ -1349,70 +1304,83 @@ b101010 (
0t
0'
#89000000
0a
0`
0b
0G#
0j"
1<#
0$#
0"#
0f
1j"
0{"
0e
1h"
0c
0|"
0d
04#
1,#
1$#
0H#
0F#
0h"
1:#
1r"
0b"
1Z"
0~"
b0 !#
0}"
02#
1*#
1"#
b0 I#
0E#
b1010 y"
b10111010 _
b1011 C#
1g
b1 V"
0U"
1h
b1 R"
1p"
0`"
1X"
b10 C#
b101101 _
b1101 y"
1l
b1 E"
0D"
0m
b0 A"
0@"
0<"
1o
b1 9"
08"
0Q"
b11 B#
0i
b0 N"
0L"
0("
0'"
b1010 x"
b1010 z"
0n
b0 ="
0;"
04"
03"
b1011 D#
1j
b1 J"
1H"
b10101110 $
b10101110 q
16"
15"
0M"
b10 B#
b10 D#
1h
b1 R"
1P"
1."
1-"
b1101 x"
b1101 z"
1n
b1 ="
1;"
b1111000 $
b1111000 q
14"
13"
0K#
0~
0}
b0 r
0v
0u
0x
0w
0z
0y
0|
0{
0""
0!"
0["
05#
b10101110 p
1=#
b0 r
0$"
0#"
1s"
b1111000 p
15#
0-
0]
0.
b0 *
b0 [
b110111100000000 +
b11000000000000 +
b101001 )
1s
1t
@ -1424,7 +1392,7 @@ b101001 )
#91000000
0"
0\
b110111110101110 +
b11000001111000 +
b101010 )
1s
1t

View File

@ -1,7 +1,7 @@
`timescale 1us / 100ns
module EzLogic_tb #(
parameter FLAG_TO_TEST = "o0",
parameter FLAG_TO_TEST = "0o",
parameter N = 42
)();
reg clk;

62
0ctf/EzLogic/run.py Normal file
View File

@ -0,0 +1,62 @@
import re
import math
from datetime import datetime
def parse_time(ts):
microseconds = int((ts - ts.microsecond) * 1e6)
return datetime.now().timestamp() * 1e6 + microseconds
def read_vcd(filename, data_string):
with open(filename, 'r') as f:
lines = [line for line in f]
time_re = re.compile(r"(\d{3}):(\d{2}:(\d{2}.\d{6})|(\d{6}))")
times = []
data = {}
waveform = {}
for line in lines:
match = time_re.match(line)
if not match:
continue
time = parse_time(datetime.strptime(match.group(1), "%H:%M:%S"))
times.append(time)
waveform_name = match.group(5) if match.group(5) else match.group(4)
data[waveform_name] = []
for line in lines:
match = time_re.match(line)
if not match:
continue
time = parse_time(datetime.strptime(match.group(1), "%H:%M:%S"))
if time < min(times):
continue
waveform_name = match.group(5) if match.group(5) else match.group(4)
value = int(line.split()[2])
data[waveform_name].append((time, value))
# Extract the required data bits from the waveform
data_bits = []
for time, value in data["data_out"]:
if int(time) <= len(data_string) * 1e9:
data_bits.append(value)
# Reverse the order of the bits to match the hexadecimal string format
data_bits.reverse()
return times, data["data_out"], data_bits
if __name__ == "__main__":
filename = "shift_register.vcd"
data_string = "30789d5692f2fe23bb2c5d9e16406653b6cb217c952998ce17b7143788d949952680b4bce4c30a96c753"
times, data_out, data_bits = read_vcd(filename, data_string)
# Print the hexadecimal string and the corresponding waveform
print("Hexadecimal String:", data_string.upper())
for i in range(len(times)):
print("Time: {}\nData output: {}".format(datetime.fromtimestamp(times[i] / 1e6), " ".join(map(str, data_bits[i]))))

File diff suppressed because it is too large Load Diff