Skip to content

Commit 3987c2c

Browse files
busterbBrent Cook
authored andcommitted
cache sysinfo (we use it a lot, it will not change)
1 parent 9cb4880 commit 3987c2c

File tree

1 file changed

+13
-10
lines changed
  • lib/rex/post/meterpreter/extensions/stdapi/sys

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,19 @@ def getenv(var_name)
8787
#
8888
def sysinfo
8989
request = Packet.create_request('stdapi_sys_config_sysinfo')
90-
response = client.send_request(request)
91-
92-
{
93-
'Computer' => response.get_tlv_value(TLV_TYPE_COMPUTER_NAME),
94-
'OS' => response.get_tlv_value(TLV_TYPE_OS_NAME),
95-
'Architecture' => response.get_tlv_value(TLV_TYPE_ARCHITECTURE),
96-
'System Language' => response.get_tlv_value(TLV_TYPE_LANG_SYSTEM),
97-
'Domain' => response.get_tlv_value(TLV_TYPE_DOMAIN),
98-
'Logged On Users' => response.get_tlv_value(TLV_TYPE_LOGGED_ON_USER_COUNT)
99-
}
90+
if @sysinfo.nil?
91+
response = client.send_request(request)
92+
93+
@sysinfo = {
94+
'Computer' => response.get_tlv_value(TLV_TYPE_COMPUTER_NAME),
95+
'OS' => response.get_tlv_value(TLV_TYPE_OS_NAME),
96+
'Architecture' => response.get_tlv_value(TLV_TYPE_ARCHITECTURE),
97+
'System Language' => response.get_tlv_value(TLV_TYPE_LANG_SYSTEM),
98+
'Domain' => response.get_tlv_value(TLV_TYPE_DOMAIN),
99+
'Logged On Users' => response.get_tlv_value(TLV_TYPE_LOGGED_ON_USER_COUNT)
100+
}
101+
end
102+
@sysinfo
100103
end
101104

102105
#

0 commit comments

Comments
 (0)