diff --git a/pwnlib/shellcraft/templates/aarch64/linux/sleep.asm b/pwnlib/shellcraft/templates/aarch64/linux/sleep.asm new file mode 120000 index 0000000000..5949528ed8 --- /dev/null +++ b/pwnlib/shellcraft/templates/aarch64/linux/sleep.asm @@ -0,0 +1 @@ +../../common/linux/sleep.asm \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/amd64/linux/sleep.asm b/pwnlib/shellcraft/templates/amd64/linux/sleep.asm new file mode 120000 index 0000000000..5949528ed8 --- /dev/null +++ b/pwnlib/shellcraft/templates/amd64/linux/sleep.asm @@ -0,0 +1 @@ +../../common/linux/sleep.asm \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/arm/linux/sleep.asm b/pwnlib/shellcraft/templates/arm/linux/sleep.asm new file mode 120000 index 0000000000..5949528ed8 --- /dev/null +++ b/pwnlib/shellcraft/templates/arm/linux/sleep.asm @@ -0,0 +1 @@ +../../common/linux/sleep.asm \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/common/linux/sleep.asm b/pwnlib/shellcraft/templates/common/linux/sleep.asm new file mode 100644 index 0000000000..cc2fc09821 --- /dev/null +++ b/pwnlib/shellcraft/templates/common/linux/sleep.asm @@ -0,0 +1,28 @@ +<% + import pwnlib.abi + from pwnlib import shellcraft +%> +<%page args="seconds"/> +<%docstring> +Sleeps for the specified amount of seconds. + +Uses SYS_nanosleep under the hood. + +Args: + seconds (int,float): The time to sleep in seconds. + +<% + # struct timespec { + # time_t tv_sec; /* Seconds */ + # long tv_nsec; /* Nanoseconds */ + # }; + tv_sec = int(seconds) + tv_nsec = int((seconds % 1) * 1000000000) + + abi = pwnlib.abi.ABI.syscall() + stack = abi.stack +%> + /* sleep(${seconds}) */ + ${shellcraft.push(tv_nsec)} + ${shellcraft.push(tv_sec)} + ${shellcraft.syscall('SYS_nanosleep', stack, 0)} diff --git a/pwnlib/shellcraft/templates/i386/linux/sleep.asm b/pwnlib/shellcraft/templates/i386/linux/sleep.asm new file mode 120000 index 0000000000..5949528ed8 --- /dev/null +++ b/pwnlib/shellcraft/templates/i386/linux/sleep.asm @@ -0,0 +1 @@ +../../common/linux/sleep.asm \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/mips/linux/sleep.asm b/pwnlib/shellcraft/templates/mips/linux/sleep.asm new file mode 120000 index 0000000000..5949528ed8 --- /dev/null +++ b/pwnlib/shellcraft/templates/mips/linux/sleep.asm @@ -0,0 +1 @@ +../../common/linux/sleep.asm \ No newline at end of file diff --git a/pwnlib/shellcraft/templates/thumb/linux/sleep.asm b/pwnlib/shellcraft/templates/thumb/linux/sleep.asm new file mode 120000 index 0000000000..5949528ed8 --- /dev/null +++ b/pwnlib/shellcraft/templates/thumb/linux/sleep.asm @@ -0,0 +1 @@ +../../common/linux/sleep.asm \ No newline at end of file