RSS

Hello- world assembly

23 Jan

Hello world program in assembly language on a 64 bit x86 machine.

  1. Open a file named hello.asm
  2. Paste the following code
  3. SECTION .data
    msg: db “Hi World”,10
    len: equ $-msgSECTION .text
    global _start
    _start:
    mov edx,len
    mov ecx,msg
    mov ebx,1
    mov eax,4
    int 0x80
    mov ebx,0
    mov eax,1
    int 0x80
  4. nasm -f elf64 hello.asm
  5. gcc -o hello hello.o -nostartfiles -nostdlib -nodefaultlibs
  6. ./hello

🙂

Wish to inject something in this binary?

Lets keep it simple!

I am going to use ghex to read or write on this binary file. System: 64 bit x86 and  OS: Ubuntu 14.04.

$sudo apt-get install ghex

Follow these steps:

1) ghex hello

2) Go to the place where you can find string “hello world”, replace it with “BUSTED”

3) You can add some signature to this file as well lets say string “ABCDEFGDIJK”. Place it in the file as well (may be three places away from “BUSTED”).

4) Remove everything following this signature string from the binary file.

5) $./hello

6) “BUSTED” You should be able to see this as output

References: https://www.tutorialspoint.com/assembly_programming/assembly_basic_syntax.htm

 

Advertisements
 
Leave a comment

Posted by on January 23, 2017 in Uncategorized

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: