Files
naksyn-PythonMemoryModule/pythonmemorymodule/windows/pycompat.py
T
naksyn db1893910c 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.
2023-07-27 06:44:29 -07:00

39 lines
764 B
Python

import sys
is_py3 = (sys.version_info.major >= 3)
if is_py3:
def str_from_ascii_function(s):
return s.decode("ascii")
int_types = int
basestring = str
anybuff = (str, bytes)
def raw_encode(s):
if isinstance(s, str):
return s.encode("latin1")
return s
def raw_decode(s):
if isinstance(s, bytes):
return s.decode("latin1")
return s
else: # py2.7
def str_from_ascii_function(s):
return s
int_types = (int, long)
basestring = basestring
anybuff = basestring
def raw_encode(s):
if isinstance(s, unicode):
return s.encode("latin1")
return s
def raw_decode(s):
# No unicode for now on py2
return s