Skip to content

Commit 3469104

Browse files
committed
Add localtime command support
1 parent 039357a commit 3469104

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

lib/rex/post/meterpreter/extensions/stdapi/sys/config.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ def getenv(var_name)
8282
value
8383
end
8484

85+
#
86+
# Returns the target's local system date and time.
87+
#
88+
def localtime
89+
request = Packet.create_request('stdapi_sys_config_localtime')
90+
response = client.send_request(request)
91+
(response.get_tlv_value(TLV_TYPE_LOCAL_DATETIME) || "").strip
92+
end
93+
8594
#
8695
# Returns a hash of information about the remote computer.
8796
#

lib/rex/post/meterpreter/extensions/stdapi/tlv.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ module Stdapi
129129
TLV_TYPE_SID = TLV_META_TYPE_STRING | 1045
130130
TLV_TYPE_DOMAIN = TLV_META_TYPE_STRING | 1046
131131
TLV_TYPE_LOGGED_ON_USER_COUNT = TLV_META_TYPE_UINT | 1047
132+
TLV_TYPE_LOCAL_DATETIME = TLV_META_TYPE_STRING | 1048
132133

133134
# Environment
134135
TLV_TYPE_ENV_VARIABLE = TLV_META_TYPE_STRING | 1100

lib/rex/post/meterpreter/ui/console/command_dispatcher/stdapi/sys.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,14 @@ def commands
9494
"kill" => "Terminate a process",
9595
"ps" => "List running processes",
9696
"reboot" => "Reboots the remote computer",
97-
"reg" => "Modify and interact with the remote registry",
97+
"reg" => "Modify and interact with the remote registry",
9898
"rev2self" => "Calls RevertToSelf() on the remote machine",
9999
"shell" => "Drop into a system command shell",
100100
"shutdown" => "Shuts down the remote computer",
101101
"steal_token" => "Attempts to steal an impersonation token from the target process",
102102
"suspend" => "Suspends or resumes a list of processes",
103103
"sysinfo" => "Gets information about the remote system, such as OS",
104+
"localtime" => "Displays the target system's local date and time",
104105
}
105106
reqs = {
106107
"clearev" => [ "stdapi_sys_eventlog_open", "stdapi_sys_eventlog_clear" ],
@@ -135,6 +136,7 @@ def commands
135136
"steal_token" => [ "stdapi_sys_config_steal_token" ],
136137
"suspend" => [ "stdapi_sys_process_attach"],
137138
"sysinfo" => [ "stdapi_sys_config_sysinfo" ],
139+
"localtime" => [ "stdapi_sys_config_localtime" ],
138140
}
139141

140142
all.delete_if do |cmd, desc|
@@ -820,6 +822,14 @@ def cmd_sysinfo(*args)
820822
return true
821823
end
822824

825+
#
826+
# Displays the local date and time at the remote system location.
827+
#
828+
def cmd_localtime(*args)
829+
print_line("Local Date/Time: " + client.sys.config.localtime);
830+
return true
831+
end
832+
823833
#
824834
# Shuts down the remote computer.
825835
#

0 commit comments

Comments
 (0)