Skip to content

Commit 1d23b7b

Browse files
committed
Land rapid7#14853, Prefix Time with namespace resolution operator for lib/rex
2 parents 5576a2c + af33087 commit 1d23b7b

File tree

26 files changed

+55
-55
lines changed

26 files changed

+55
-55
lines changed

lib/rex/job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(container, jid, name, ctx, run_proc, clean_proc)
2727
# Otherwise, the job is run inline.
2828
#
2929
def start(async = false)
30-
self.start_time = Time.now
30+
self.start_time = ::Time.now
3131
if (async)
3232
self.job_thread = Rex::ThreadFactory.spawn("JobID(#{jid})-#{name}", false) {
3333
# Deschedule our thread momentarily

lib/rex/logging/log_sink.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def log(sev, src, level, msg)
3030
# This method returns the current timestamp in MM/DD/YYYY HH:Mi:SS format.
3131
#
3232
def get_current_timestamp
33-
return Time.now.strftime("%m/%d/%Y %H:%M:%S")
33+
return ::Time.now.strftime("%m/%d/%Y %H:%M:%S")
3434
end
3535

3636
end

lib/rex/parser/apple_backup_manifestdb.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def parse_mbdb
5050
info[:unknown3] = mbdb_read_int(4)
5151
info[:uid] = mbdb_read_int(4)
5252
info[:gid] = mbdb_read_int(4)
53-
info[:mtime] = Time.at(mbdb_read_int(4))
54-
info[:atime] = Time.at(mbdb_read_int(4))
55-
info[:ctime] = Time.at(mbdb_read_int(4))
53+
info[:mtime] = ::Time.at(mbdb_read_int(4))
54+
info[:atime] = ::Time.at(mbdb_read_int(4))
55+
info[:ctime] = ::Time.at(mbdb_read_int(4))
5656
info[:length] = mbdb_read_int(8)
5757
info[:flag] = mbdb_read_int(1)
5858
property_count = mbdb_read_int(1)

lib/rex/post/file_stat.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def blocks
6363
self.stathash['st_blocks']
6464
end
6565
def atime
66-
Time.at(self.stathash['st_atime'])
66+
::Time.at(self.stathash['st_atime'])
6767
end
6868
def mtime
69-
Time.at(self.stathash['st_mtime'])
69+
::Time.at(self.stathash['st_mtime'])
7070
end
7171
def ctime
72-
Time.at(self.stathash['st_ctime'])
72+
::Time.at(self.stathash['st_ctime'])
7373
end
7474

7575
def update(buf)

lib/rex/post/hwbridge/ui/console/command_dispatcher/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def cmd_status(*args)
220220
print_status("HW Version: #{status['hw_version']}") if status.key? 'hw_version'
221221
print_status("Uptime: #{stats['uptime']} seconds") if stats.key? 'uptime'
222222
print_status("Packets Sent: #{stats['packet_stats']}") if stats.key? 'packet_stats'
223-
print_status("Last packet Sent: #{Time.at(stats['last_request'])}") if stats.key? 'last_request'
223+
print_status("Last packet Sent: #{::Time.at(stats['last_request'])}") if stats.key? 'last_request'
224224
print_status("Voltage: #{stats['voltage']}") if stats.key? 'voltage' and not stats['voltage'] == 'not supported'
225225
end
226226

lib/rex/post/meterpreter/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def init_meterpreter(sock,opts={})
125125
self.target_id = opts[:target_id]
126126
self.capabilities = opts[:capabilities] || {}
127127
self.commands = []
128-
self.last_checkin = Time.now
128+
self.last_checkin = ::Time.now
129129

130130
self.conn_id = opts[:conn_id]
131131
self.url = opts[:url]

lib/rex/post/meterpreter/extensions/android/android.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def interval_collect(opts)
102102

103103
response.each(TLV_TYPE_COLLECT_RESULT_GROUP) do |g|
104104
timestamp = g.get_tlv_value(TLV_TYPE_COLLECT_RESULT_TIMESTAMP)
105-
timestamp = Time.at(timestamp).to_datetime.strftime('%Y-%m-%d %H:%M:%S')
105+
timestamp = ::Time.at(timestamp).to_datetime.strftime('%Y-%m-%d %H:%M:%S')
106106

107107
g.each(TLV_TYPE_COLLECT_RESULT_WIFI) do |w|
108108
bssid = w.get_tlv_value(TLV_TYPE_COLLECT_RESULT_WIFI_BSSID)
@@ -129,7 +129,7 @@ def interval_collect(opts)
129129

130130
response.each(TLV_TYPE_COLLECT_RESULT_GROUP) do |g|
131131
timestamp = g.get_tlv_value(TLV_TYPE_COLLECT_RESULT_TIMESTAMP)
132-
timestamp = Time.at(timestamp).to_datetime.strftime('%Y-%m-%d %H:%M:%S')
132+
timestamp = ::Time.at(timestamp).to_datetime.strftime('%Y-%m-%d %H:%M:%S')
133133

134134
g.each(TLV_TYPE_COLLECT_RESULT_GEO) do |w|
135135
lat = w.get_tlv_value(TLV_TYPE_GEO_LAT)
@@ -145,7 +145,7 @@ def interval_collect(opts)
145145

146146
response.each(TLV_TYPE_COLLECT_RESULT_GROUP) do |g|
147147
timestamp = g.get_tlv_value(TLV_TYPE_COLLECT_RESULT_TIMESTAMP)
148-
timestamp = Time.at(timestamp).to_datetime.strftime('%Y-%m-%d %H:%M:%S')
148+
timestamp = ::Time.at(timestamp).to_datetime.strftime('%Y-%m-%d %H:%M:%S')
149149

150150
g.each(TLV_TYPE_COLLECT_RESULT_CELL) do |cell|
151151

lib/rex/post/meterpreter/extensions/priv/fs.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ def get_file_mace(file_path)
3636
# Return the hash of times associated with the MACE values
3737
begin
3838
return {
39-
'Modified' => Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_MODIFIED)),
40-
'Accessed' => Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_ACCESSED)),
41-
'Created' => Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_CREATED)),
42-
'Entry Modified' => Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_EMODIFIED))
39+
'Modified' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_MODIFIED)),
40+
'Accessed' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_ACCESSED)),
41+
'Created' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_CREATED)),
42+
'Entry Modified' => ::Time.at(response.get_tlv_value(TLV_TYPE_FS_FILE_EMODIFIED))
4343
}
4444
rescue RangeError
4545
raise RangeError, 'Invalid MACE values'

lib/rex/post/meterpreter/extensions/stdapi/sys/event_log_subsystem/event_record.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class EventRecord
2727

2828
def initialize(recnum, timegen, timewri, id, type, cat, strs, data)
2929
self.num = recnum
30-
self.generated = Time.at(timegen)
31-
self.written = Time.at(timewri)
30+
self.generated = ::Time.at(timegen)
31+
self.written = ::Time.at(timewri)
3232
self.eventid = id
3333
self.type = type
3434
self.category = cat

lib/rex/post/meterpreter/packet.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def self.generate_command_id_map_c
481481
/*!
482482
* @file common_command_ids.h
483483
* @brief Declarations of command ID values
484-
* @description This file was generated #{Time.now.utc}. Do not modify directly.
484+
* @description This file was generated #{::Time.now.utc}. Do not modify directly.
485485
*/
486486
#ifndef _METERPRETER_SOURCE_COMMON_COMMAND_IDS_H
487487
#define _METERPRETER_SOURCE_COMMON_COMMAND_IDS_H
@@ -504,7 +504,7 @@ def self.generate_command_id_map_java
504504
/**
505505
* All supported Command Identifiers
506506
*
507-
* @author Genereated by a tool @ #{Time.now.utc}
507+
* @author Genereated by a tool @ #{::Time.now.utc}
508508
*/
509509
public interface CommandId {
510510
#{command_ids.join("\n")}
@@ -516,7 +516,7 @@ def self.generate_command_id_map_php_lib(lib, id_map)
516516
command_ids = id_map.map {|k, v| "define('COMMAND_ID_#{k.upcase}', #{v});"}
517517
%Q^
518518
# ---------------------------------------------------------------
519-
# --- THIS CONTENT WAS GENERATED BY A TOOL @ #{Time.now.utc}
519+
# --- THIS CONTENT WAS GENERATED BY A TOOL @ #{::Time.now.utc}
520520
# IDs for #{lib}
521521
#{command_ids.join("\n")}
522522
# ---------------------------------------------------------------
@@ -539,7 +539,7 @@ def self.generate_command_id_map_python
539539
command_ids = id_map.map {|k, v| " (#{v}, '#{k.downcase}'),"}
540540
%Q^
541541
# ---------------------------------------------------------------
542-
# --- THIS CONTENT WAS GENERATED BY A TOOL @ #{Time.now.utc}
542+
# --- THIS CONTENT WAS GENERATED BY A TOOL @ #{::Time.now.utc}
543543
COMMAND_IDS = (
544544
#{command_ids.join("\n")}
545545
)
@@ -568,7 +568,7 @@ def self.generate_command_id_map_python_extension
568568
command_ids = id_map.map {|k, v| "COMMAND_ID_#{k.upcase} = #{v}"}
569569
%Q^
570570
# ---------------------------------------------------------------
571-
# --- THIS CONTENT WAS GENERATED BY A TOOL @ #{Time.now.utc}
571+
# --- THIS CONTENT WAS GENERATED BY A TOOL @ #{::Time.now.utc}
572572
573573
#{command_ids.join("\n")}
574574
@@ -597,7 +597,7 @@ def self.generate_command_id_map_csharp
597597
command_ids = id_map.map {|k, v| "#{k.split('_').map(&:capitalize).join} = #{v},"}
598598
%Q^
599599
/// <summary>
600-
// This content was generated by a tool @ #{Time.now.utc}
600+
// This content was generated by a tool @ #{::Time.now.utc}
601601
/// </summary>
602602
namespace MSF.Powershell.Meterpreter
603603
{

lib/rex/post/meterpreter/packet_dispatcher.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def shutdown_passive_dispatcher
102102

103103
def on_passive_request(cli, req)
104104
begin
105-
self.last_checkin = Time.now
105+
self.last_checkin = ::Time.now
106106
resp = send_queue.shift
107107
cli.send_response(resp)
108108
rescue => e
@@ -252,7 +252,7 @@ def send_packet_wait_response(packet, timeout)
252252
# @return [void]
253253
def keepalive
254254
if @ping_sent
255-
if Time.now.to_i - last_checkin.to_i > PING_TIME*2
255+
if ::Time.now.to_i - last_checkin.to_i > PING_TIME*2
256256
dlog("No response to ping, session #{self.sid} is dead", LEV_3)
257257
self.alive = false
258258
end
@@ -577,7 +577,7 @@ def dispatch_inbound_packet(packet)
577577
#STDERR.puts("RECV: #{packet.inspect}\n")
578578

579579
# Update our last reply time
580-
self.last_checkin = Time.now
580+
self.last_checkin = ::Time.now
581581

582582
pivot_session = self.find_pivot_session(packet.session_guid)
583583
pivot_session.pivoted_session.last_checkin = self.last_checkin if pivot_session
@@ -671,7 +671,7 @@ def on_passive_request(cli, req)
671671
resp['Content-Type'] = 'application/octet-stream'
672672
resp['Connection'] = 'close'
673673

674-
self.last_checkin = Time.now
674+
self.last_checkin = ::Time.now
675675

676676
if req.method == 'GET'
677677
rpkt = send_queue.shift

lib/rex/post/meterpreter/ui/console/command_dispatcher/android.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def cmd_interval_collect(*args)
107107
header = "Captured #{opts[:type]} data"
108108

109109
if result[:timestamp]
110-
time = Time.at(result[:timestamp]).to_datetime
110+
time = ::Time.at(result[:timestamp]).to_datetime
111111
header << " at #{time.strftime('%Y-%m-%d %H:%M:%S')}"
112112
end
113113

@@ -188,7 +188,7 @@ def cmd_set_audio_mode(*args)
188188
end
189189

190190
def cmd_dump_sms(*args)
191-
path = "sms_dump_#{Time.new.strftime('%Y%m%d%H%M%S')}.txt"
191+
path = "sms_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
192192
dump_sms_opts = Rex::Parser::Arguments.new(
193193
'-h' => [ false, 'Help Banner' ],
194194
'-o' => [ true, 'Output path for sms list']
@@ -218,7 +218,7 @@ def cmd_dump_sms(*args)
218218
data << "[+] SMS messages dump\n"
219219
data << "=====================\n\n"
220220

221-
time = Time.new
221+
time = ::Time.new
222222
data << "Date: #{time.inspect}\n"
223223
data << "OS: #{info['OS']}\n"
224224
data << "Remote IP: #{client.sock.peerhost}\n"
@@ -252,7 +252,7 @@ def cmd_dump_sms(*args)
252252
data << "Type\t: #{type}\n"
253253

254254
time = a['date'].to_i / 1000
255-
time = Time.at(time)
255+
time = ::Time.at(time)
256256

257257
data << "Date\t: #{time.strftime('%Y-%m-%d %H:%M:%S')}\n"
258258
data << "Address\t: #{a['address']}\n"
@@ -275,7 +275,7 @@ def cmd_dump_sms(*args)
275275
end
276276

277277
def cmd_dump_contacts(*args)
278-
path = "contacts_dump_#{Time.new.strftime('%Y%m%d%H%M%S')}"
278+
path = "contacts_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}"
279279
format = :text
280280

281281
dump_contacts_opts = Rex::Parser::Arguments.new(
@@ -324,7 +324,7 @@ def cmd_dump_contacts(*args)
324324
data << "[+] Contacts list dump\n"
325325
data << "======================\n\n"
326326

327-
time = Time.new
327+
time = ::Time.new
328328
data << "Date: #{time.inspect}\n"
329329
data << "OS: #{info['OS']}\n"
330330
data << "Remote IP: #{client.sock.peerhost}\n"
@@ -421,7 +421,7 @@ def cmd_geolocate(*args)
421421
end
422422

423423
def cmd_dump_calllog(*args)
424-
path = "calllog_dump_#{Time.new.strftime('%Y%m%d%H%M%S')}.txt"
424+
path = "calllog_dump_#{::Time.new.strftime('%Y%m%d%H%M%S')}.txt"
425425
dump_calllog_opts = Rex::Parser::Arguments.new(
426426
'-h' => [ false, 'Help Banner' ],
427427
'-o' => [ true, 'Output path for call log']
@@ -451,7 +451,7 @@ def cmd_dump_calllog(*args)
451451
data << "[+] Call log dump\n"
452452
data << "=================\n\n"
453453

454-
time = Time.new
454+
time = ::Time.new
455455
data << "Date: #{time.inspect}\n"
456456
data << "OS: #{info['OS']}\n"
457457
data << "Remote IP: #{client.sock.peerhost}\n"

lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def cmd_get_timeouts(*args)
681681

682682
def print_timeouts(timeouts)
683683
if timeouts[:session_exp]
684-
print_line("Session Expiry : @ #{(Time.now + timeouts[:session_exp]).strftime('%Y-%m-%d %H:%M:%S')}")
684+
print_line("Session Expiry : @ #{(::Time.now + timeouts[:session_exp]).strftime('%Y-%m-%d %H:%M:%S')}")
685685
end
686686
if timeouts[:comm_timeout]
687687
print_line("Comm Timeout : #{timeouts[:comm_timeout]} seconds")

lib/rex/post/meterpreter/ui/console/command_dispatcher/priv/timestomp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def str_to_time(str) # :nodoc:
156156
raise ArgumentError, "Invalid date format, expected MM/DD/YYYY HH24:MI:SS (got #{str})"
157157
end
158158

159-
Time.mktime(year, mon, day, hour, min, sec, 0)
159+
::Time.mktime(year, mon, day, hour, min, sec, 0)
160160
end
161161
end
162162
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def cmd_download(*args)
459459
opts['tries'] = true
460460
opts['tries_no'] = tries_no
461461
when "-t"
462-
opts['timestamp'] = '_' + Time.now.iso8601
462+
opts['timestamp'] = '_' + ::Time.now.iso8601
463463
when nil
464464
src_items << last if (last)
465465
last = val

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def stream_html_template(name, host, stream_path)
4646
</noscript>
4747
<pre>
4848
Target IP : #{host}
49-
Start time : #{Time.now}
49+
Start time : #{::Time.now}
5050
Status : <span id="status"></span>
5151
</pre>
5252
<br>

lib/rex/proto/dns/server.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize
2929
# @return [Array] Records found
3030
def find(search, type = 'A')
3131
self.records.select do |record,expire|
32-
record.type == type and (expire < 1 or expire > Time.now.to_i) and
32+
record.type == type and (expire < 1 or expire > ::Time.now.to_i) and
3333
(
3434
record.name == '*' or
3535
record.name == search or record.name[0..-2] == search or
@@ -53,7 +53,7 @@ def cache_record(record)
5353
if record.is_a?(Dnsruby::RR) and
5454
(!record.respond_to?(:address) or Rex::Socket.is_ip_addr?(record.address.to_s)) and
5555
record.name.to_s.match(MATCH_HOSTNAME)
56-
add(record, Time.now.to_i + record.ttl)
56+
add(record, ::Time.now.to_i + record.ttl)
5757
else
5858
raise "Invalid record for cache entry - #{record.inspect}"
5959
end
@@ -81,7 +81,7 @@ def add_static(name, address, type = 'A', replace = false)
8181
# Prune cache entries
8282
#
8383
# @param before [Fixnum] Time in seconds before which records are evicted
84-
def prune(before = Time.now.to_i)
84+
def prune(before = ::Time.now.to_i)
8585
self.records.select do |rec, expire|
8686
expire > 0 and expire < before
8787
end.each {|rec, exp| delete(rec)}

lib/rex/proto/http/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def basic_auth_header(username,password)
311311

312312

313313
def make_cnonce
314-
Digest::MD5.hexdigest "%x" % (Time.now.to_i + rand(65535))
314+
Digest::MD5.hexdigest "%x" % (::Time.now.to_i + rand(65535))
315315
end
316316

317317
# Send a series of requests to complete Digest Authentication

lib/rex/proto/iax2/call.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def hangup
157157
end
158158

159159
def ring_time
160-
(self.ring_finish || Time.now).to_i - self.ring_start.to_i
160+
(self.ring_finish || ::Time.now).to_i - self.ring_start.to_i
161161
end
162162

163163
def timestamp

lib/rex/proto/iax2/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def allocate_call_id
114114

115115
def dprint(msg)
116116
return if not self.debugging
117-
$stderr.puts "[#{Time.now.to_s}] #{msg}"
117+
$stderr.puts "[#{::Time.now.to_s}] #{msg}"
118118
end
119119

120120
def send_data(call, data, inc_seq = true )

lib/rex/proto/ntlm/crypt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def self.ntlmv2_response(arg, opt = {})
184184
cc = opt[:client_challenge] || rand(CONST::MAX64)
185185
cc = BASE::pack_int64le(cc) if cc.is_a?(::Integer)
186186

187-
ts = opt[:timestamp] || Time.now.to_i
187+
ts = opt[:timestamp] || ::Time.now.to_i
188188

189189
# Convert the unix timestamp to windows format
190190
# epoch -> milsec from Jan 1, 1601

lib/rex/proto/ntlm/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def self.make_ntlmv2_clientchallenge(win_domain, win_name, dns_domain, dns_name,
432432
client_challenge ||= Rex::Text.rand_text(8)
433433
# We have to set the timestamps here to the one in the challenge message from server if present
434434
# If we don't do that, recent server like Seven/2008 will send a STATUS_INVALID_PARAMETER error packet
435-
timestamp = chall_MsvAvTimestamp != '' ? chall_MsvAvTimestamp : self.time_unix_to_smb(Time.now.to_i).reverse.pack("VV")
435+
timestamp = chall_MsvAvTimestamp != '' ? chall_MsvAvTimestamp : self.time_unix_to_smb(::Time.now.to_i).reverse.pack("VV")
436436
# Make those values unicode as requested
437437
win_domain = Rex::Text.to_unicode(win_domain)
438438
win_name = Rex::Text.to_unicode(win_name)

0 commit comments

Comments
 (0)