From f329c7331a0446f3615e9c8e86e7f1a1710cf519 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Tue, 3 Feb 2015 19:07:26 +0000 Subject: [PATCH] Report identified service to network extension --- modules/host/detect_cups/command.js | 6 +++--- modules/host/detect_cups/module.rb | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/modules/host/detect_cups/command.js b/modules/host/detect_cups/command.js index b2d19317b..5974c9718 100644 --- a/modules/host/detect_cups/command.js +++ b/modules/host/detect_cups/command.js @@ -9,14 +9,14 @@ beef.execute(function() { var result = "Not Installed"; var dom = document.createElement('b'); var img = new Image; - img.src = "http://127.0.0.1:631/images/cups-icon.png"; + img.src = "http://<%= @ipHost %>:<%= @port %>/images/cups-icon.png"; img.onload = function() { if (this.width == 128 && this.height == 128) result="Installed"; - beef.net.send('<%= @command_url %>', <%= @command_id %>,'cups='+result); + beef.net.send('<%= @command_url %>', <%= @command_id %>,'proto=http&ip=<%= @ipHost %>&port=<%= @port %>&cups='+result); dom.removeChild(this); } img.onerror = function() { - beef.net.send('<%= @command_url %>', <%= @command_id %>,'cups='+result); + beef.net.send('<%= @command_url %>', <%= @command_id %>,'proto=http&ip=<%= @ipHost %>&port=<%= @port %>&cups='+result); dom.removeChild(this); } dom.appendChild(img); diff --git a/modules/host/detect_cups/module.rb b/modules/host/detect_cups/module.rb index 6a5d3116b..3a711366c 100644 --- a/modules/host/detect_cups/module.rb +++ b/modules/host/detect_cups/module.rb @@ -5,9 +5,30 @@ # class Detect_cups < BeEF::Core::Command + + def self.options + return [ + {'name' => 'ipHost', 'ui_label' => 'IP or Hostname', 'value' => '127.0.0.1'}, + {'name' => 'port' , 'ui_label' => 'Port', 'value' => '631'} + ] + end def post_execute save({'CUPS' => @datastore['cups']}) + + configuration = BeEF::Core::Configuration.instance + if configuration.get("beef.extension.network.enable") == true + if @datastore['results'] =~ /^proto=(https?)&ip=([\d\.]+)&port=([\d]+)&cups=Installed$/ + proto = $1 + ip = $2 + port = $3 + session_id = @datastore['beefhook'] + cid = @datastore['cid'].to_i + print_debug("Hooked browser found 'CUPS' [proto: #{proto}, ip: #{ip}, port: #{port}]") + r = BeEF::Core::Models::NetworkService.new(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => 'CUPS', :cid => cid) + r.save + end + end end end