首页
社区
课程
招聘
[原创]硬件安全 hardware ctf Low Logic Hack the box
发表于: 3天前 433

[原创]硬件安全 hardware ctf Low Logic Hack the box

3天前
433

题目

首先下载题目压缩包,unzip解压之后得到了一个电路图和input.csv:

电路图

在这之前先介绍一些基本的简单的电路:

AND

在与门配置中:

两个NPN晶体管串联连接。

电源VCC接入第一个晶体管(T1)的集电极,该集电极连接至T2,电流最终流向地。

输入端A和B分别连接至对应晶体管的基极。

仅当两个晶体管同时导通(输入端为高电平)时电流才会流动

——这是标准与门的特性。

OR

在或门电路中:

晶体管呈并联连接。

当任一晶体管基极接收到高电平输入时,电流便会流向输出端。

经典或门行为——只要任一输入端有效,输出端即被触发。

chip.jpg

接下来回到题目给的电路图,我们用红线标出电源的流向,然后拆解一下电路,可以看到,这整个电路是先由IN0和IN1组成了AND门得到result1,然后又由IN2和IN3组成了AND门得到result2,最后由result1与result2进行OR操作得到OUT0。

csv文件

用head指令查看一下


可以看到,这个csv文件中每一行都是in0到in3的输入值,但是没给出输出值,我们经过电路分析,已知了逻辑关系,或许可以用python脚本计算出对应到OUT0序列是什么。

exp

import csv

def evaluate_logic_from_csv(file_path):
    output_bits = []

    # Open and read the CSV file
    with open(file_path, 'r') as file:
        reader = csv.reader(file)
        next(reader)  # Skip header row
        #print(reader)

        # Process each row of inputs
        for inputs in reader:
            #print(inputs)
            in0 = int(inputs[0])
            in1 = int(inputs[1])
            in2 = int(inputs[2])
            in3 = int(inputs[3])

            # Apply logical AND to pairs
            result1 = in0 & in1
            result2 = in2 & in3

            # Combine results using logical OR
            final_result = result1 | result2

            # Store output as string
            output_bits.append(str(final_result))

    return ''.join(output_bits)

# Define input CSV and execute logic
input_csv = 'input.csv'
logic_output = evaluate_logic_from_csv(input_csv)

print(logic_output)

再转化为ascii

python3 -c "s='binarystring'; 
print(''.join([chr(int(s[i:i+8], 2)) for i in range(0, len(s), 8)]))"

引用和参考的博客:

Hack The Box Hardware Exploitation Track: Low Logic | 1337 Sheets

Introduction of Logic Gates - GeeksforGeeks


[培训]Windows内核深度攻防:从Hook技术到Rootkit实战!

收藏
免费 0
支持
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回