HTB Low Logic - Flag & Python Code
by mhsoraa - Saturday December 7, 2024 at 02:35 PM
#1
Flag:
HTB{4_G00d_Cm05_3x4mpl3}

Python Code:
import csv # Function to process the logic for each row def process_logic(in0, in1, in2, in3):     # Convert the input values from strings to boolean (True/False)     in0 = bool(int(in0))     in1 = bool(int(in1))     in2 = bool(int(in2))     in3 = bool(int(in3))         # Apply the logic: out = (in0 AND in1) OR (in2 AND in3)     out = (in0 and in1) or (in2 and in3)         return out # Function to convert a bit stream to an ASCII string def bit_stream_to_ascii(bit_stream):     # Split the bit stream into chunks of 8 bits (1 byte)     byte_chunks = [bit_stream[i:i+8] for i in range(0, len(bit_stream), 8)]         # Convert each byte chunk to a character     ascii_string = ''.join(chr(int(byte, 2)) for byte in byte_chunks)         return ascii_string # Open and read the CSV file with open('input.csv', newline='') as csvfile:     reader = csv.DictReader(csvfile)         # Initialize an empty bit stream     bit_stream = ""         # Process each row     for row in reader:         # Read the inputs from the CSV row         in0 = row['in0']         in1 = row['in1']         in2 = row['in2']         in3 = row['in3']                 # Process the logic and compute the output (True -> '1', False -> '0')         result = process_logic(in0, in1, in2, in3)         bit_stream += str(int(result))  # Append the result as '1' or '0' to the bit stream             # Convert the bit stream to an ASCII string     ascii_output = bit_stream_to_ascii(bit_stream)         # Print the ASCII output (this will be readable text)     print(f"Flag:\n{ascii_output}")
Reply
#2
thank you !!!! <3
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [FREE] 300+ Writeups PDF HackTheBox/HTB premium retired Tamarisk 360 90,839 03-28-2026, 09:28 AM
Last Post: catsweet
  [FREE] HTB-ProLabs APTLABS Just Flags kewlsunny 23 4,306 03-28-2026, 03:30 AM
Last Post: lulaladrow
  [MEGALEAK] HackTheBox ProLabs, Fortress, Endgame - Alchemy, 250 Flags, leak htb-bot htb-bot 87 9,469 03-27-2026, 07:22 PM
Last Post: stn
  HTB Eloquia User and Root Flags - Insane Box 69646B 13 2,292 03-27-2026, 06:14 PM
Last Post: vlxw
  HTB - ALL Challenges you Stuck in osamy7593 2 2,590 03-27-2026, 04:24 PM
Last Post: catsweet



 Users browsing this thread: 1 Guest(s)