From 16ecb32e4615bc5660c1f49bb655827a71fafd89 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Fri, 30 Jan 2015 06:57:01 +0000 Subject: [PATCH] Report identified hosts to network extension --- modules/host/get_internal_ip/module.rb | 16 ++++++++++++++++ modules/network/ping_sweep/module.rb | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/host/get_internal_ip/module.rb b/modules/host/get_internal_ip/module.rb index d0c436292..79439b23a 100755 --- a/modules/host/get_internal_ip/module.rb +++ b/modules/host/get_internal_ip/module.rb @@ -20,6 +20,22 @@ class Get_internal_ip < BeEF::Core::Command content['Result'] = @datastore['result'] save content BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/get_internal_ip.class') + + configuration = BeEF::Core::Configuration.instance + if configuration.get("beef.extension.network.enable") == true + + session_id = @datastore['beefhook'] + cid = @datastore['cid'].to_i + + # save the network host + if @datastore['results'] =~ /^([\d\.]+)$/ + ip = $1 + print_debug("Hooked browser has network interface #{ip}") + r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :cid => cid) + r.save + end + end + end end diff --git a/modules/network/ping_sweep/module.rb b/modules/network/ping_sweep/module.rb index 0eea04f61..4081ff2f8 100644 --- a/modules/network/ping_sweep/module.rb +++ b/modules/network/ping_sweep/module.rb @@ -26,5 +26,21 @@ class Ping_sweep < BeEF::Core::Command content['fail'] = 'No active hosts have been discovered.' end save content + + configuration = BeEF::Core::Configuration.instance + if configuration.get("beef.extension.network.enable") == true + + session_id = @datastore['beefhook'] + cid = @datastore['cid'].to_i + + # save the network host + if @datastore['results'] =~ /host=([\d\.]+) is alive/ + ip = $1 + print_debug("Hooked browser has network interface #{ip}") + r = BeEF::Core::Models::NetworkHost.new(:hooked_browser_id => session_id, :ip => ip, :cid => cid) + r.save + end + end + end end