Skip to content

Commit

Permalink
Revert "fixing issue #1852"
Browse files Browse the repository at this point in the history
This reverts commit 375c0d9.
  • Loading branch information
h4sh5 committed Jan 16, 2020
1 parent 375c0d9 commit 7d9a235
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
17 changes: 9 additions & 8 deletions core/main/ar-migrations/013_create_network_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ class CreateNetworkHost < ActiveRecord::Migration[6.0]
def change

create_table :network_hosts do |t|
t.references :hooked_browser
t.text :ip
t.text :hostname
t.text :ntype
t.text :os
t.text :mac
t.text :lastseen
end
t.references :hooked_browser
t.text :ip
t.text :hostname
t.text :ntype
t.text :os
t.text :mac
t.text :lastseen
end

end

end
15 changes: 0 additions & 15 deletions core/main/handlers/browserdetails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def setup()

# validate hook session value
session_id = get_param(@data, 'beefhook')
print_debug "[INIT] Processing Browser Details for session #{session_id}"
(self.err_msg "session id is invalid"; return) if not BeEF::Filters.is_valid_hook_session_id?(session_id)
hooked_browser = HB.where(:session => session_id).first
return if not hooked_browser.nil? # browser is already registered with framework
Expand Down Expand Up @@ -405,20 +404,6 @@ def setup()
self.err_msg "Invalid value for 'browser.window.size.width' returned from the hook browser's initial connection."
end

# store and log IP details of host
print_debug("Hooked browser [id:#{zombie.id}] has IP [ip: #{zombie.ip}]")

if os_name != nil and os_version != nil
BeEF::Core::Models::NetworkHost.create(:hooked_browser => zombie, :ip => zombie.ip, :ntype => 'Host', :os => os_name + "-" + os_version)

elsif os_name != nil
BeEF::Core::Models::NetworkHost.create(:hooked_browser => zombie, :ip => zombie.ip, :ntype => 'Host', :os => os_name)

else
BeEF::Core::Models::NetworkHost.create(:hooked_browser => zombie, :ip => zombie.ip, :ntype => 'Host')

end

# get and store the yes|no value for browser capabilities
capabilities = [
'browser.capabilities.vbscript',
Expand Down
7 changes: 2 additions & 5 deletions extensions/network/rest/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class NetworkRest < BeEF::Core::Router::Router
config = BeEF::Core::Configuration.instance
@nh = BeEF::Core::Models::NetworkHost
@ns = BeEF::Core::Models::NetworkService
@hb = BeEF::Core::Models::HookedBrowser

# Require a valid API token from a valid IP address
halt 401 unless params[:token] == config.get('beef.api_token')
Expand Down Expand Up @@ -70,9 +69,7 @@ class NetworkRest < BeEF::Core::Router::Router
begin
id = params[:id]

hooked_browser = @hb.where(session: id).distinct

hosts = @nh.where(hooked_browser: hooked_browser).distinct.order(:hooked_browser)
hosts = @nh.where(hooked_browser_id: id).distinct.order(:id)
count = hosts.length

result = {}
Expand Down Expand Up @@ -124,7 +121,7 @@ class NetworkRest < BeEF::Core::Router::Router

host = @nh.find(id)
raise InvalidParamError, 'id' if host.nil?
halt 404 if host == nil?
halt 404 if host.empty?

host.to_h.to_json
rescue InvalidParamError => e
Expand Down

0 comments on commit 7d9a235

Please sign in to comment.