-
Notifications
You must be signed in to change notification settings - Fork 0
jhswartz/mle
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
MACHINE LANGUAGE ENCODER
A target-agnostic machine language encoder with labels and macros.
USAGE
mle < SOURCE > CODE
INSTALLATION
# cp -a mle /usr/bin/mle
# chown root:root /usr/bin/mle
# chmod 755 /usr/bin/mle
EXAMPLE
$ cat /tmp/pwd.src
Magic:
90
Start:
# getcwd(directory, 2048);
54 5f # mov rsp rdi
66 be 00 08 # mov 2048 si
6a 4f 58 # mov SYS_GETCWD rax
0f 05 # syscall
# Replace the NUL terminator with LF.
c6 44 07 ff 0a # mov '\n' (rdi + rax - 1)
# write(STDOUT_FILENO, directory, strlen(directory));
92 # xchg eax edx
57 5e # mov rdi rsi
6a 01 5f # mov STDOUT_FILENO rdi
57 58 # mov SYS_WRITE rax
0f 05 # syscall
# exit(EXIT_SUCCESS);
31 ff # mov EXIT_SUCCESS rdi
b0 3c # mov SYS_EXIT rax
0f 05 # syscall
$ mle < /tmp/pwd.src > /tmp/pwd
$ chmod 755 /tmp/pwd
$ ls -al /tmp/pwd
-rwxr-xr-x 1 user user 33 Dec 31 02:01 /tmp/pwd
$ cd /tmp
$ strace ./pwd
execve("./pwd", ["./pwd"], 0x7ffcf3a8abc0 /* 42 vars */) = 0
open("./pwd", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0755, st_size=33, ...}) = 0
mmap(NULL, 33, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7f816a9c6000
getcwd("/tmp", 2048) = 5
write(1, "/tmp\n", 5) = 5
exit(0) = ?
+++ exited with 0 +++
SEE ALSO
http://github.com/jhswartz/mle-x86
http://github.com/jhswartz/mli-amd64
AUTHOR
Justin Swartz <justin.swartz@risingedge.co.za>
About
Target-agnostic machine language encoder with labels and macros.