mirror of
https://github.com/naksyn/PythonMemoryModule
synced 2026-06-06 16:24:25 +00:00
command line support (partial) via PEB stomping
This update include support to passing command line parameters to unmanaged exe via PEB stomping. This technique is not working with every executable since it depends on which functions are used to pass arguments. Generally, to get a universally working technique would be required to hook GetCommandlineA GetCommandlineW __getmainargs and __wgetmainargs since PEB stomping won't cover all cases, more details here: https://blog-30cm-tw.translate.goog/2020/08/windows-c-mainargc-argv.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=it&_x_tr_pto=wapp However, during my testing I found that mimikatz and several go binaries are working just by doing PEB stomping. On the other hand, cmdline passing via PEB stomping alone to mingw and VS compiled binaries won't likely work.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import ctypes
|
||||
import windows.generated_def as gdef
|
||||
|
||||
from ..apiproxy import ApiProxy, NeededParameter
|
||||
from ..error import fail_on_zero, succeed_on_zero
|
||||
|
||||
class Shell32Proxy(ApiProxy):
|
||||
APIDLL = "shell32"
|
||||
default_error_check = staticmethod(fail_on_zero)
|
||||
|
||||
@Shell32Proxy()
|
||||
def ShellExecuteA(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd):
|
||||
return ShellExecuteA.ctypes_function(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd)
|
||||
|
||||
@Shell32Proxy()
|
||||
def ShellExecuteW(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd):
|
||||
return ShellExecuteW.ctypes_function(hwnd, lpOperation, lpFile, lpParameters, lpDirectory, nShowCmd)
|
||||
|
||||
@Shell32Proxy()
|
||||
def SHGetPathFromIDListA(pidl, pszPath):
|
||||
return SHGetPathFromIDListA.ctypes_function(pidl, pszPath)
|
||||
|
||||
@Shell32Proxy()
|
||||
def SHGetPathFromIDListW(pidl, pszPath):
|
||||
return SHGetPathFromIDListW.ctypes_function(pidl, pszPath)
|
||||
|
||||
@Shell32Proxy(error_check=succeed_on_zero)
|
||||
def SHFileOperationA(lpFileOp):
|
||||
return SHFileOperationA.ctypes_function(lpFileOp)
|
||||
Reference in New Issue
Block a user