Shell Scripting

[Level 2] Write the shortest assembly program that you can that launches a UNIX shell. The program should produce machine code (visible using objdump -D that is as short as possible). Your program may not use the .string directive; instead, it must launch the shell code without such a hard-coded string.

Fore!!

Digital Forensics

    .global main
main:
    movabs $0x68732f6e69622fff, %rax
    shr $8, %rax
    pushq %rax
    movq %rsp, %rdi
    xorl %eax, %eax
    movb $59, %al
    syscall
                            

Source code: Boyer_Addison.S

gcc -c Boyer_Addison.S

   0:   48 b8 ff 2f 62 69 6e    movabs $0x68732f6e69622fff,%rax
   7:   2f 73 68
   a:   48 c1 e8 08             shr    $0x8,%rax
   e:   50                      push   %rax
   f:   48 89 e7                mov    %rsp,%rdi
  12:   31 c0                   xor    %eax,%eax
  14:   b0 3b                   mov    $0x3b,%al
  16:   0f 05                   syscall
                            

objdump -D Boyer_Addison.o

The anatomy of a stack, taken from Oliver Serangs' textbook here.