Hack The Box — Low Logic
Solution to Hack The Box Hardware Challenge
Introduction
In this challenge, our goal is to analyze the chip diagram (chip.jpg
) and predict the output based on inputs from input.csv
.
Solution
First, let’s take a look at the chip diagram:
Understanding the Diagram
The diagram shows that the chip takes four inputs labelled at the top as IN0
, IN1
, IN2
, and IN3
. These inputs are passed through a series of resistors and NPN BJTs (Bipolar Junction Transistors), which ultimately produce the output OUT0
.
The transistors in this circuit are used to create logic gates. For anyone interested in learning more about logic gates and transistors, I recommend this article: https://www.101computing.net/creating-logic-gates-using-transistors/.
From the diagram, we see that the circuit consists of:
- Two AND gates
- One OR gate
We can now simplify our circuit diagram like this:
Generating the Output
With the simplified diagram in mind, we can now process the input values from input.csv
to generate the output.
To save time, I wrote a small Python script that:
- Reads the input values.
- Performs AND operations on pairs of inputs (
IN0 & IN1
andIN2 & IN3
). - Combines the results using an OR operation to produce the final output.
Here’s the script:
import csv
def process_logic_operations(input_file):
results = []
# Open input.csv
with open(input_file, mode='r') as infile:
csvreader = csv.reader(infile)
next(csvreader)
# Read input from input.csv
for row in csvreader:
input1 = int(row[0])
input2 = int(row[1])
input3 = int(row[2])
input4 = int(row[3])
and_output1 = input1 & input2 # First AND operation
and_output2 = input3 & input4 # Second AND operation
final_output = and_output1 | and_output2 # Final OR operation
results.append(str(final_output))
return ''.join(results)
input_file = 'input.csv'
output = process_logic_operations(input_file)
print(output)
Output Extraction
After running the script, we get the following binary output:
010010000101010001000010011110110011010001011111010001110011000000110000011001000101111101000011011011010011000000110101010111110011001101111000001101000110110101110000011011000011001101111101
We can use Cyber Chef to convert this binary data to ASCII and get the flag: HTB{4_G00d_Cm05_3x4mpl3}
Conclusion
This was a fun challenge, and I will be posting more Hardware and Reverse Engineering challenges from Hack The Box in the future. Stay tuned!