1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-12-08 23:33:07 +01:00

Add localtime command support for POSIX

This commit is contained in:
OJ 2016-08-01 23:23:47 +10:00
parent 38fe6e1188
commit 5e6dc8ca85
No known key found for this signature in database
GPG Key ID: D5DC61FB93260597
2 changed files with 10 additions and 2 deletions

View File

@ -110,12 +110,12 @@ Command customCommands[] =
// Sys/config
COMMAND_REQ("stdapi_sys_config_getuid", request_sys_config_getuid),
COMMAND_REQ("stdapi_sys_config_localtime", request_sys_config_localtime),
COMMAND_REQ("stdapi_sys_config_sysinfo", request_sys_config_sysinfo),
COMMAND_REQ("stdapi_sys_config_rev2self", request_sys_config_rev2self),
COMMAND_REQ("stdapi_sys_config_getprivs", request_sys_config_getprivs),
COMMAND_REQ("stdapi_sys_config_getenv", request_sys_config_getenv),
#ifdef _WIN32
COMMAND_REQ("stdapi_sys_config_localtime", request_sys_config_localtime),
COMMAND_REQ("stdapi_sys_config_steal_token", request_sys_config_steal_token),
COMMAND_REQ("stdapi_sys_config_drop_token", request_sys_config_drop_token),
COMMAND_REQ("stdapi_sys_config_getsid", request_sys_config_getsid),

View File

@ -597,10 +597,18 @@ DWORD request_sys_config_localtime(Remote* remote, Packet* packet)
localTime.wHour, localTime.wMinute, localTime.wSecond, localTime.wMilliseconds,
tziResult == TIME_ZONE_ID_DAYLIGHT ? tzi.DaylightName : tzi.StandardName,
tzi.Bias > 0 ? "-" : "+", abs(tzi.Bias / 60));
#else
time_t t = time(NULL);
struct tm lt = { 0 };
localtime_r(&t, &lt);
// TODO: bug?
// For some reason I don't see the correct TZ name/offset coming through. Bionic issue?
// Or tied just to my setup (FC24)?
strftime(dateTime, sizeof(dateTime) - 1, "%Y-%m-%d %H:%M:%S %Z (UTC%z)", &lt);
#endif
dprintf("[SYSINFO] Local Date/Time: %s", dateTime);
packet_add_tlv_string(response, TLV_TYPE_LOCAL_DATETIME, dateTime);
#endif
// Transmit the response
packet_transmit_response(result, remote, response);