def _cat_linux_arm(filepath, out_fd): return (open_file(filepath), 'mov r8, r0\ncat_helper1:', read_stack('r8', 48, False), 'cmp r0, #0\nble cat_helper2', write_stack(out_fd, 'r0'), 'b cat_helper1\ncat_helper2:')
def _cat_amd64(filepath, out_fd, use_sendfile): if use_sendfile: return open_file(filepath), sendfile('rax', out_fd) else: return (open_file(filepath), "xchg ebp, eax\ncat_helper1:", read_stack('rbp', 48, False), "test eax, eax\njle cat_helper2", write_stack(out_fd, 'rax'), "jmp cat_helper1\ncat_helper2:")
def ls(filepath='.', out_fd=1): """Args: filepath, [out_fd (imm/reg) = STDOUT_FILENO] Opens a directory and writes its content to the specified file descriptor. """ return (open_file(filepath), "xchg ebp, eax\nls_helper1:", getdents('ebp', 255, False), "test eax, eax\njle ls_helper2", write_stack(out_fd, 'eax'), "jmp ls_helper1\nls_helper2:")
def _ls_linux_i386(filepath='.', out_fd = 1, in_fd = 0): out = (open_file(filepath), "xchg ebp, eax\n", "ls_helper1:\n", getdents('ebp', 255, False), "test eax, eax\n", "jle ls_helper2\n", write_stack(out_fd, 'eax'), "jmp ls_helper1\n", "ls_helper2:\n") return out
def ls(filepath = '.', out_fd = 1): """Args: filepath, [out_fd (imm/reg) = STDOUT_FILENO] Opens a directory and writes its content to the specified file descriptor. """ return (open_file(filepath), "xchg ebp, eax\nls_helper1:", getdents('ebp', 255, False), "test eax, eax\njle ls_helper2", write_stack(out_fd, 'eax'), "jmp ls_helper1\nls_helper2:")
def _ls_linux_arm(filepath='.', out_fd = 1, in_fd = 0): out = (open_file(filepath), "mov r6, r0\n", # backup the file descriptor "loop:\n", getdents(in_fd), "sub r4, r4, r4\n", "cmp r0, r4\n", "ble next\n", write_stack(out_fd, size=255), "sub r4, r4, r4\n", "cmp r0, r4\n", "bgt loop\n", "next:\n", ) return out
def echo(str, out=1): """Args: str, [out = 1] Writes <str> to <out> (default: STDOUT_FILENO).""" return pushstr(str, null=False), write_stack(out, len(str))
def echo(str, out = 1): """Args: str, [out = 1] Writes <str> to <out> (default: STD_OUT).""" return pushstr(str, null=False), write_stack(out, len(str))