ARMssembly 0 [picoCTF]

Surya Dev Singh
3 min readJan 4, 2022

category : Reverse Engineering

Description

What integer does this program print with arguments 182476535 and 3742084308? File: chall.S Flag format: picoCTF{XXXXXXXX} -> (hex, lowercase, no 0x, and 32 bits. ex. 5614267 would be picoCTF{0055aabb})

to solve this challenge we could potentially, read and understand the ARM assembly or we could compile this ARM assembly to binary and execute it , to get to know what this binary is assembly code is doing .

compiling and running it :

before that lets understand some important things :

static v/s dynamic executables :

A static executable has all the code it needs in a single file and will only require the OS Syscall interface to be compatible for that OS to be able to execute it. This was how all programs were in the past, but as programs and libraries grew in size, but computer memory did not, it became necessary to be able to share library code at run-time. So only one copy of the library would be in memory and all running programs could access it, only the data would not be shared. Programs accessing shared libraries are termed Dynamically Linked,

install cross-platform compiler and ARM emulator:

$ sudo apt install qemu-user-static && gcc-aarch64-linux-gnu

qemu is emulator/hypervisor which can execute the ARM 64 bit or 32 bit processor binary on any platform

qemu-user-static is lite version for qemu full setup , it has only the basic feature.

gcc-aarch64-linux-gnu-gcc is is cross compiler comes with gnu project

now run the following command to get the binary :

$ aarch64-linux-gnu-as -o chall.o chall.S$ aarch64-linux-gnu-gcc -static -o chall chall.o

the first command will convert the assembely file to object file of aarch64 and the second command will convert object file to the actal binary.

now if we try to run this binary , it wont run(unless you are on ARM borads like raspberry pi)

in order to run the ARM binary on our processor of x86_64 we will use qemu-user-static

this qemu-user-static runs in background , so whenever we try to run the binary , and if they are not supported by our processor , this which make them run so, we get the output

make sure to pass the argument , or else you will get segmentation fault error.

now this CTF challege is require us to give the flag in hex format , i will use python for that :

so our final flag will be :

picoCTF{df0bacd4}

writeups and help I had taken :

https://azeria-labs.com/arm-on-x86-qemu-user/

https://azeria-labs.com/arm-on-x86-qemu-user/

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

THANK YOU FOR READING MY WRITE UP !! 👊👊

please support me by following me on medium :

YOU CAN READ MY OTHER WIRTEUPS ALSO :

--

--

Surya Dev Singh

enthusiast cyber security learner and penetration tester / ethical hacker , python programmer and in my free time you will find me solving CTFs