martes, 17 de diciembre de 2024

endianess Walktrough - picoCTF 2024

I must say that I am not a particulary advanced programmer yet. Still, now and then i like to try and solve some of the challenges that are uploaded to picoCTF every year. For those that do not know, picoCTF is a Capture The Flag challenge website. In there, you can put your cybersecurity knowledge to the test and try out a variety of challenges that range from easy challenges to the more difficult ones that require a deeper understanding of what is asked of you in them.

 The challenge I managed to solve is not really difficult one. The challenge is called endianess and was made by Nana Ama Atombo-Sackey for this years picoCTF competiton.

 

 

I had never heard of the term endianess before, so I just went ahead and looked for it on Wikipedia:

In computing, endianness is the order in which bytes within a word of digital data are(...) adressed on computer memory. (...) A big-endian system stores the most significant byte of a word at the smallest memory address and the least significant byte at the largest. A little-endian system, in contrast, stores the least-significant byte at the smallest address.

Looking for a clearer definition of the concept, I also found a simpler explanation of it on GeeksForGeeks:

Endianness refers to the order in which bytes are arranged in memory. Different languages read their text in different orders. for example, English reads from left to right, while Arabic reads from right to left. 

 Endianness works similarly for computers. If one computer reads bytes from left to right and another reads them from right to left, issues arise when these computers need to communicate. Endianness ensures that bytes in computer memory are read in a specific order.

Summing up, Big Endian stores the bites from left tor right where as Little Endian stores them form right to left.

For Example, let us say we have the hex string of Hello World:

Big Endian (Be) : 48656C6C6F20576F726C64  -> Hello World

Little Endian (Le): 646C726F57206F6C6C6548 -> dlroW olleH

It's actually a pretty simple concept! Now that we undestand it, let us take a look at the challenge itself.

When we start the challenge by running the instance and connecting through Netcat to the server, we are greeted with the following prompt:

 That is actually pretty simple. We just need to convert the given word, in this case alail, to hexadecimal and set it to the required representation, Little Endian.

We can start by turning the word arround: 

alail --->  liala

Then we can easily convert it to hexadecimal with an online tool: 

liala --> 6C 69 61 6C 61

Let's try to answer with 6C 69 61 6C 61 , we also have to keep in mind to remove the spaces between the characters.

Now the comandline asks to give the Big Endian representation of the word. Pretty simple too! We just need to answer with the hexadecimal representation of the word alail !

alail --->  616C61696C

Now, we answer with 61 6C 61 69 6C.

And there we have it ! The challenge has been successfully compleated. Now we just have to copy the flag and post it to the flag window.

Overall, I think this challenge was an excellent way to get a grip on how characters and data are stored in computer memory. It also helps to develop a better appreciation on how small differences in the memory organization can lead to significant changes, especially when it comes to cross-platform communication and low-level programming.

I hope you found this small walkthrough of the endianness challenge from picoCTF 2024 helpful. If you enjoyed this post, I plan to share more content on this blog, so stay tuned for future updates!