Hack The Box — Low Logic

Pi - The Kernel Panic
3 min readDec 28, 2024

--

Solution to Hack The Box Hardware Challenge

Low Logic has been Pwned!

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:

chip.jpg

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/.

AND Gate
OR Gate

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:

Simplified circuit diagram

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:

  1. Reads the input values.
  2. Performs AND operations on pairs of inputs (IN0 & IN1 and IN2 & IN3).
  3. 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}

Cyber Chef

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!

--

--

Pi - The Kernel Panic
Pi - The Kernel Panic

Written by Pi - The Kernel Panic

Hello, I'm Pi / The Kernel Panic. I am a vulnerability researcher and malware analyst. I have created this blog to document some of my research.

No responses yet