title: Linux Shellcode "Hello, World!"
body: <p>I have the following working NASM code:</p>
  
  <pre><code>global _start
  
  section .text
  
  _start:
      mov eax, 0x4
      mov ebx, 0x1
      mov ecx, message
      mov edx, 0xF
      int 0x80
  
      mov eax, 0x1
      mov ebx, 0x0
      int 0x80
  
  section .data
      message: db "Hello, World!", 0dh, 0ah
  </code></pre>
  
  <p>which prints "Hello, World!\n" to the screen. I also have the following C wrapper which contains the previous NASM object code:</p>
  
  <pre><code>char code[] =
  "\xb8\x04\x00\x00\x00"
  "\xbb\x01\x00\x00\x00"
  "\xb9\x00\x00\x00\x00"
  "\xba\x0f\x00\x00\x00"
  "\xcd\x80\xb8\x01\x00"
  "\x00\x00\xbb\x00\x00"
  "\x00\x00\xcd\x80";
  
  int main(void)
  {
      (*(void(*)())code)();
  }
  </code></pre>
  
  <p>However when I run the code, it seems like the assembler code isn't executed, but the program exits fine. Any ideas?</p>
  
  <p>Thanks</p>