binhexa
Name: binhexa Description: How well can you perfom basic binary operations? Start searching for the flag here nc titan.picoctf.net 50052 Author: Nana Ama Atombo-Sackey Tags: Easy, General Skills, picoCTF 2024, shell, browser_webshell_solvable Challenge from: picoCTF 2024
Theory
According to the description, to get the flag we have do some binary operations, which I think we can solve by just using python. So like this, using int to convert to integer number, then doing the operation, then converting it back to binary, but then remove the 0b at the beginning, it's just an identifier to know it's binary, so for example hexadecimal uses 0x. For example, this one is for adding two binary numbers:
>>> print(bin(int('10101010', 2) + int('01010101', 2))) 0b11111111
Solution
First, let's enter to the NetCat, and now we can use the python code to get the answer for each of these:
shukularuni-picoctf@webshell:~$ nc titan.picoctf.net 50052 Welcome to the Binary Challenge!" Your task is to perform the unique operations in the given order and find the final result in hexadecimal that yields the flag. Binary Number 1: 11011100 Binary Number 2: 00101001 Question 1/6: Operation 1: '|' Perform the operation on Binary Number 1&2. Enter the binary result: >>> print(bin(int('11011100', 2) | int('00101001', 2))) 0b11111101 Enter the binary result: 11111101 Correct! Question 2/6: Operation 2: '+' Perform the operation on Binary Number 1&2. Enter the binary result: >>> print(bin(int('11011100', 2) + int('00101001', 2))) 0b100000101 100000101 Correct! Question 3/6: Operation 3: '<<' Perform a left shift of Binary Number 1 by 1 bits. Enter the binary result:
Now here comes the tricky part, it says to do a left shift with the number 1 by 1 bit, so only one of the numbers is involved not the number 2:
>>> print(bin(int('11011100', 2) << 1)) 0b110111000 Enter the binary result: 110111000 Correct! Question 4/6: Operation 4: '*' Perform the operation on Binary Number 1&2. Enter the binary result: >>> print(bin(int('11011100', 2) * int('00101001', 2))) 0b10001100111100 Enter the binary result: 10001100111100 Correct! Question 5/6: Operation 5: '>>' Perform a right shift of Binary Number 2 by 1 bits . Enter the binary result:
And this one is a right shift, BUT ON THE SECOND NUMBER, so the command is this:
>>> print(bin(int('00101001', 2) >> 1)) 0b10100 Enter the binary result: 10100 Correct! Question 6/6: Operation 6: '&' Perform the operation on Binary Number 1&2. Enter the binary result: >>> print(bin(int('11011100', 2) & int('00101001', 2))) 0b1000 Enter the binary result: 1000 Correct! Enter the results of the last operation in hexadecimal:
Finally we have to get the last's operation result in hexadecimal, which is actually really easy, you just need to change the output from bin to hex, to make it convert to hexadecimal after the operation is done, also remember to remove the 0x from the beginning:
>>> print(hex(int('11011100', 2) & int('00101001', 2))) 0x8 Enter the results of the last operation in hexadecimal: 8 Correct answer! The flag is: picoCTF{b1tw^3se_0p3eR@tI0n_su33essFuL_aeaf4b09} ^C
There we go! That's the flag.
I rated this level as "good"! :3
https://play.picoctf.org/practice/challenge/404