Skip to content

Run amd64 machine code executables without an object file format.

Notifications You must be signed in to change notification settings

jhswartz/mli-amd64

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MACHINE LANGUAGE INTERPRETER / AMD64

  Run amd64 machine code executables without an object file format.


BUILD

  $ mle < src/mli.src > src/mli.raw
  $ tools/shelf tools/plan src/mli.raw > bin/mli
  $ chmod 755 bin/mli
  $ ls -al bin/mli
  -rwxr-xr-x 1 user user 4096 Aug 26 05:08 bin/mli


INSTALLATION

  # cp -a bin/mli /bin/mli 
  # mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
  # cat misc/binfmt/mli-amd64 > /proc/sys/fs/binfmt_misc/register
  # cat /proc/sys/fs/binfmt_misc/mli-amd64
  enabled
  flags:
  offset 0
  magic 90


USAGE

  $ mle < demo/src/kill.src > demo/bin/kill
  $ chmod u+x demo/bin/kill

  $ ls -al demo/bin/kill
  -rwxr-xr-x 1 user user 107 Oct 15 14:43 demo/bin/kill

  $ strace demo/bin/kill -15 1 2 3 4 0
  execve("demo/bin/kill", ["demo/bin/kill", "-15", "1", "2", "3", "4", "0"], 0x7ffdf65d2950 /* 38 vars */) = 0
  open("demo/bin/kill", O_RDONLY)         = 3
  fstat(3, {st_mode=S_IFREG|0755, st_size=107, ...}) = 0
  mmap(NULL, 107, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7f73a97a2000
  kill(1, SIGTERM)                        = -1 EPERM (Operation not permitted)
  kill(2, SIGTERM)                        = -1 EPERM (Operation not permitted)
  kill(3, SIGTERM)                        = -1 EPERM (Operation not permitted)
  kill(4, SIGTERM)                        = -1 EPERM (Operation not permitted)
  kill(0, SIGTERM)                        = 0
  strace: Process 31999 detached
  Terminated


DEBUGGING

  $ gdb -q --args bin/mli demo/bin/sleep 1
  Reading symbols from bin/mli...
  (No debugging symbols found in bin/mli)

  (gdb) b *0x40000800
  Breakpoint 1 at 0x40000800

  (gdb) b *0x4000085b
  Breakpoint 2 at 0x4000085b

  (gdb) display/4i $pc
  1: x/4i $pc
  <error: No registers.>

  (gdb) r
  Breakpoint 1, 0x0000000040000800 in ?? ()
  1: x/4i $pc
  => 0x40000800:  pop    %rcx
     0x40000801:  dec    %rcx
     0x40000804:  cmp    $0x1,%rcx
     0x40000808:  jl     0x4000085d

  (gdb) c
  Breakpoint 2, 0x000000004000085b in ?? () 
  1: x/4i $pc
  => 0x4000085b:  jmp    *%rax
     0x4000085d:  push   $0x1
     0x4000085f:  pop    %rdi
     0x40000860:  push   $0x3c

  (gdb) stepi
  0x00007ffff7ff8000 in ?? ()
  1: x/4i $pc
  => 0x7ffff7ff8000:      nop
     0x7ffff7ff8001:      pop    %rcx
     0x7ffff7ff8002:      cmp    $0x2,%rcx
     0x7ffff7ff8006:      jne    0x7ffff7ff8041

 
SEE ALSO

  https://github.com/jhswartz/shelf
  https://github.com/jhswartz/mle
  https://github.com/jhswartz/mlx


AUTHOR

  Justin Swartz <justin.swartz@risingedge.co.za>

About

Run amd64 machine code executables without an object file format.

Topics

Resources

Stars

Watchers

Forks

Languages