środa, 28 lipca 2021

Quick Intro to Linux Assembly

Some time ago I decided to get back to the ASM on Intel and refresh some of the basics. Below you'll find few notes about it. Here we go... 

This time we'll start here:

 

I prepared a lab environment using Ubuntu 20.04. Next step was to install nasm using apt-get, like it is presented on the screen below: 


If everything is ready so far we should be able to start.

Today we'll start from the declaration of the sections we need to have in our (linked and compiled) program:
- section .data
- section .text

In ".data" section - we'll find  initialized data or constants.  
In ".text" section - we'll find the code.

Our 'program' will start executing the code starting from 'global _start' directive.

Very basic example is presented below:

So far - looks good. ;)

At this stage we can use one of the examples of 'hello world' codes I found online (ex. this one or this):


Let's compile our code to new object:


Next let's use a linker to create our finial file and we can check our code:

Now let's use objdump to check our (linked and compiled) ASM code:

As we now "know and understand" some of the ASM code - we can easily check relations to the C-('pseudo')-code.

According to this easy excercise - now it's should be easier to prepare for another 'reversing adventures'.

See you soon!


Cheers



Brak komentarzy:

Prześlij komentarz