Part 1 - The Why, The How…

It is 2021 and here we are once again covering a new Reverse Engineer course. This course will focus on the C programming language to which we will statically reverse the compiled ARM 32 elf binary utilizing the Radare2 debugger on a Raspberry Pi Pico microcontroller.

What are microcontrollers? We can find them in vehicles, robots, office machines, medical devices, mobile radio transceivers, vending machines and home appliances, among other devices. They are targeted machines designed to control small features of a larger component, without a complex front-end operating system.

We will be writing very basic C programs and then reverse them one at a time in ARM 32 Assembly.

I am going to assume you are working with an Ubuntu Linux distro…

You will first need a Raspberry Pi Pico.

You will need the Radare2 repo.

  1. git clone https://github.com/radareorg/radare2.git
  2. cd radare2
  3. cd radare2 sys/install.sh

You NEED to build from source! The versions that are packaged in Ubuntu and Kali Linux are older and do not have the features we require for our level of reversing.

You will need VIM.

  1. sudo apt install vim

You will need to update .vimrc file.

  1. vim ~/.vimrc

Then…

  1. set number
  2. set tabstop=2
  3. set noexpandtab
  4. %retab!
  5. syntax on
  6. set syntax=c

You will need the Raspberry Pi Pico repo.

  1. mkdir pico
  2. cd pico
  3. git clone -b master https://github.com/raspberrypi/pico-sdk.git
  4. cd pico-sdk
  5. git submodule update --init
  6. cd ..
  7. git clone -b master https://github.com/raspberrypi/pico-examples.git
  8. sudo apt update
  9. sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential

Let’s build the blink program.

  1. cd pico-examples
  2. mkdir build
  3. cd build
  4. export PICO_SDK_PATH=../../pico-sdk
  5. cmake ..
  6. cd blink
  7. make

Copy the blink.uf2 file to your Pico.

Congrats you got a blinking C program!

In our next lesson we will create a simple, “Hello, World” program.