[python-win32] runas analog

Kuree Kafir kuree.offsec at gmail.com
Mon Mar 18 20:33:38 EDT 2019


Hello,

I am trying to implement something similar to the runas /netonly command in
python.

handle = win32security.LogonUser(userName, domain, password,
win32con.LOGON32_LOGON_NEW_CREDENTIALS, win32con.LOGON32_PROVIDER_DEFAULT)
win32security.ImpersonateLoggedOnUser(handle)

These two commands succeed, and I can see the credentials in memory, but
when I attempt to call something like os.system("cmd.exe") and attempt to
authenticate, the security context previous created is not presented, and
authentication fails.

How do I correctly call CreateProcess using the impersonation session that
I just created?

kuree
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20190318/0187610e/attachment.html>


More information about the python-win32 mailing list