Add :lastseen property to NetworkHost model
This commit is contained in:
@@ -46,7 +46,7 @@ ZombieTab_Network = function(zombie) {
|
||||
autoDestroy: true,
|
||||
autoLoad: false,
|
||||
root: 'hosts',
|
||||
fields: ['id', 'ip', 'hostname', 'type', 'os', 'mac'],
|
||||
fields: ['id', 'ip', 'hostname', 'type', 'os', 'mac', 'lastseen'],
|
||||
sortInfo: {field: 'ip', direction: 'ASC'}
|
||||
});
|
||||
|
||||
@@ -81,9 +81,10 @@ ZombieTab_Network = function(zombie) {
|
||||
{header: 'Id', width: 5, sortable: true, dataIndex: 'id', hidden:true},
|
||||
{header: 'IP Address', width: 10, sortable: true, dataIndex: 'ip', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}},
|
||||
{header: 'Host Name', width: 10, sortable: true, dataIndex: 'hostname', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}},
|
||||
{header: 'Type', width: 20, sortable: true, dataIndex: 'type', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}},
|
||||
{header: 'Type', width: 15, sortable: true, dataIndex: 'type', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}},
|
||||
{header: 'Operating System', width: 10, sortable: true, dataIndex: 'os', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}},
|
||||
{header: 'MAC Address', width: 10, sortable: true, dataIndex: 'mac', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}}
|
||||
{header: 'MAC Address', width: 10, sortable: true, dataIndex: 'mac', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}},
|
||||
{header: 'Last Seen', width: 15, sortable: true, dataIndex: 'lastseen', renderer: function(value){return $jEncoder.encoder.encodeForHTML(value)}}
|
||||
],
|
||||
|
||||
listeners: {
|
||||
|
||||
@@ -22,6 +22,7 @@ module BeEF
|
||||
property :type, String, :lazy => false # proxy, router, gateway, dns, etc
|
||||
property :os, String, :lazy => false
|
||||
property :mac, String, :lazy => false
|
||||
property :lastseen, String, :length => 15
|
||||
|
||||
#
|
||||
# Stores a network host in the data store
|
||||
@@ -30,6 +31,11 @@ module BeEF
|
||||
(print_error "Invalid hooked browser session"; return) unless BeEF::Filters.is_valid_hook_session_id?(host[:hooked_browser_id])
|
||||
(print_error "Invalid IP address"; return) unless BeEF::Filters.is_valid_ip?(host[:ip])
|
||||
|
||||
# update lastseen
|
||||
BeEF::Core::Models::NetworkHost.all(
|
||||
:hooked_browser_id => host[:hooked_browser_id],
|
||||
:ip => host[:ip]).update( :lastseen => Time.now )
|
||||
|
||||
# prevent duplicates
|
||||
return unless BeEF::Core::Models::NetworkHost.all(
|
||||
:hooked_browser_id => host[:hooked_browser_id],
|
||||
@@ -39,12 +45,6 @@ module BeEF
|
||||
:os => host[:os],
|
||||
:mac => host[:mac]).empty?
|
||||
|
||||
if host[:hostname].nil? && host[:type].nil? && host[:os].nil? && host[:mac].nil?
|
||||
return unless BeEF::Core::Models::NetworkHost.all(
|
||||
:hooked_browser_id => host[:hooked_browser_id],
|
||||
:ip => host[:ip]).empty?
|
||||
end
|
||||
|
||||
# store the returned network host details
|
||||
network_host = BeEF::Core::Models::NetworkHost.new(
|
||||
:hooked_browser_id => host[:hooked_browser_id],
|
||||
@@ -52,7 +52,8 @@ module BeEF
|
||||
:hostname => host[:hostname],
|
||||
:type => host[:type],
|
||||
:os => host[:os],
|
||||
:mac => host[:mac])
|
||||
:mac => host[:mac],
|
||||
:lastseen => Time.now)
|
||||
result = network_host.save
|
||||
(print_error "Failed to save network host"; return) if result.nil?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user