Skip to content

Instantly share code, notes, and snippets.

@kjensenxz
Created Jun 25, 2017
Embed
What would you like to do?
BITS 64
CPU X64
section .text
global _start
%macro mount 3
mov rax, 0x53 ; sys_mkdir
mov rdi, %1 ; location
mov rsi, %3 ; mode
syscall
mov rax, 0xA5 ; sys_mount
; mov rdi, 0 ; device name, not needed
mov rsi, %1 ; location
mov rdx, %2 ; filesystem
; mov r10, 0 ; flags, not needed
; mov r8, 0 ; data, not needed
syscall
%endmacro
_start:
mount p_path, p_fs, 755o
mount s_path, s_fs, 755o
mount t_path, t_fs, 777o
mov rax, 0x3B ; sys_execve
mov rdi, sh_path
mov rsi, sh_argv
xor rdx, rdx
syscall
p_path:
db "/"
p_fs:
db "proc", 0
s_path:
db "/sys", 0
s_fs:
db "sysfs", 0
t_path:
db "/tmp", 0
t_fs:
db "ramfs", 0
sh_path:
db "/bin/sh", 0
sh_argv:
dq sh_path, 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment