From f4bd471ee4abe2bc9b0d3f9599a60c77c10ff007 Mon Sep 17 00:00:00 2001 From: Spencer McIntyre Date: Tue, 2 Dec 2014 14:20:11 -0500 Subject: [PATCH] Prefer the pwd module for getuid when available --- python/meterpreter/ext_server_stdapi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/meterpreter/ext_server_stdapi.py b/python/meterpreter/ext_server_stdapi.py index b1ff544a..f8cf747f 100644 --- a/python/meterpreter/ext_server_stdapi.py +++ b/python/meterpreter/ext_server_stdapi.py @@ -698,7 +698,9 @@ def stdapi_sys_config_getsid(request, response): @meterpreter.register_function def stdapi_sys_config_getuid(request, response): - if has_windll: + if has_pwd: + username = pwd.getpwuid(os.getuid()).pw_name + elif has_windll: token = get_token_user(ctypes.windll.kernel32.GetCurrentProcess()) if not token: return ERROR_FAILURE, response