Modules: Resolve many Rubocop violations

This commit is contained in:
Brendan Coles
2022-01-22 12:46:42 +00:00
parent bbe805f017
commit a64480dfab
317 changed files with 3238 additions and 3965 deletions

View File

@@ -4,10 +4,9 @@
# See the file 'doc/COPYING' for copying permission
#
class F5_bigip_cookie_disclosure < BeEF::Core::Command
def post_execute
return if @datastore['results'].nil?
save({'BigIPCookie' => @datastore['results']})
end
save({ 'BigIPCookie' => @datastore['results'] })
end
end

View File

@@ -4,10 +4,9 @@
# See the file 'doc/COPYING' for copying permission
#
class F5_bigip_cookie_stealing < BeEF::Core::Command
def post_execute
return if @datastore['result'].nil?
save({'BigIPSessionCookies' => @datastore['BigIPSessionCookies']})
end
save({ 'BigIPSessionCookies' => @datastore['BigIPSessionCookies'] })
end
end

View File

@@ -4,23 +4,22 @@
# See the file 'doc/COPYING' for copying permission
#
class Doser < BeEF::Core::Command
def pre_send
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/DOSer/worker.js', '/worker', 'js')
end
def self.options
return [
{'name' => 'url', 'ui_label' => 'URL', 'value' => 'http://target/path'},
{'name'=>'delay', 'ui_label' =>'Delay between requests (ms)','value'=>'10'},
{'name'=>'method', 'ui_label' =>'HTTP Method','value'=>'POST'},
{'name'=>'post_data', 'ui_label' =>'POST data','value'=>'key=value&&Aa=Aa&BB'}
[
{ 'name' => 'url', 'ui_label' => 'URL', 'value' => 'http://target/path' },
{ 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '10' },
{ 'name' => 'method', 'ui_label' => 'HTTP Method', 'value' => 'POST' },
{ 'name' => 'post_data', 'ui_label' => 'POST data', 'value' => 'key=value&&Aa=Aa&BB' }
]
end
def post_execute
return if @datastore['result'].nil?
save({'result' => @datastore['result']})
save({ 'result' => @datastore['result'] })
end
end

View File

@@ -4,40 +4,34 @@
# See the file 'doc/COPYING' for copying permission
#
class Cross_origin_scanner_cors < BeEF::Core::Command
def post_execute
content = {}
content['result'] = @datastore['result']
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /^proto=(https?)&ip=(.+)&port=(\d+)&status/
session_id = @datastore['beefhook']
# log the network service
if @datastore['results'] =~ /^proto=(https?)&ip=(.+)&port=([\d]+)&status/
proto = $1
ip = $2
port = $3
type = 'HTTP Server (CORS)'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP server #{ip}:#{port}")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => type)
end
end
# log the network service
proto = Regexp.last_match(1)
ip = Regexp.last_match(2)
port = Regexp.last_match(3)
type = 'HTTP Server (CORS)'
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP server #{ip}:#{port}")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type)
end
end
def self.options
return [
{'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254'},
{'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080'},
{'name' => 'threads', 'ui_label' => 'Workers', 'value' => '2'},
{'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '2'},
{'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10'}
[
{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254' },
{ 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' },
{ 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '2' },
{ 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '2' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' }
]
end
end

View File

@@ -4,9 +4,8 @@
# See the file 'doc/COPYING' for copying permission
#
class Cross_origin_scanner_flash < BeEF::Core::Command
def pre_send
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_cached('/modules/network/cross_origin_scanner_flash/ContentHijacking.swf','/objects/ContentHijacking','swf')
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_cached('/modules/network/cross_origin_scanner_flash/ContentHijacking.swf', '/objects/ContentHijacking', 'swf')
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_cached('/modules/network/cross_origin_scanner_flash/swfobject.js', '/swfobject', 'js')
end
@@ -16,39 +15,37 @@ class Cross_origin_scanner_flash < BeEF::Core::Command
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
return unless configuration.get('beef.extension.network.enable') == true
session_id = @datastore['beefhook']
session_id = @datastore['beefhook']
# log discovered hosts
if @datastore['results'] =~ /^ip=(.+)&status=alive$/
ip = $1
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.create(:hooked_browser_id => session_id, :ip => ip)
end
# log discovered network services
elsif @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=([\d]+)&title/
proto = $1
ip = $2
port = $3
type = 'HTTP Server (Flash)'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP server #{ip}:#{port}")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => type)
end
# log discovered hosts
case @datastore['results']
when /^ip=(.+)&status=alive$/
ip = Regexp.last_match(1)
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip)
end
# log discovered network services
when /^proto=(.+)&ip=(.+)&port=(\d+)&title/
proto = Regexp.last_match(1)
ip = Regexp.last_match(2)
port = Regexp.last_match(3)
type = 'HTTP Server (Flash)'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP server #{ip}:#{port}")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type)
end
end
end
def self.options
return [
{'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254'},
{'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080'},
{'name' => 'threads', 'ui_label' => 'Workers', 'value' => '2'},
{'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '5'}
[
{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254' },
{ 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' },
{ 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '2' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '5' }
]
end
end

View File

@@ -4,23 +4,19 @@
# See the file 'doc/COPYING' for copying permission
#
class Detect_burp < BeEF::Core::Command
def post_execute
save({'result' => @datastore['result']})
save({ 'result' => @datastore['result'] })
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^has_burp=true&response=PROXY ([\d\.]+:[\d]+)/
ip = $1.split(':')[0]
port = $1.split(':')[1]
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => 'http', :ip => ip, :port => port, :type => 'Burp Proxy')
end
end
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /^has_burp=true&response=PROXY ([\d.]+:\d+)/
ip = Regexp.last_match(1).split(':')[0]
port = Regexp.last_match(1).split(':')[1]
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: 'http', ip: ip, port: port, type: 'Burp Proxy')
end
end
end

View File

@@ -4,19 +4,17 @@
# See the file 'doc/COPYING' for copying permission
#
class Detect_soc_nets < BeEF::Core::Command
def self.options
return [
{'name' => 'timeout', 'ui_label' => 'Detection Timeout','value' => '5000'}
[
{ 'name' => 'timeout', 'ui_label' => 'Detection Timeout', 'value' => '5000' }
]
end
def post_execute
content = {}
content['GMail'] = @datastore['gmail']
content['Facebook'] = @datastore['facebook']
content['Twitter']= @datastore['twitter']
content['Twitter'] = @datastore['twitter']
save content
end
end

View File

@@ -4,18 +4,16 @@
# See the file 'doc/COPYING' for copying permission
#
class Detect_tor < BeEF::Core::Command
def self.options
return [
{'name' => 'tor_resource', 'ui_label' => 'What Tor resource to request', 'value' => 'http://xycpusearchon2mc.onion/deeplogo.jpg'},
{'name'=>'timeout', 'ui_label' =>'Detection timeout','value'=>'10000'}
[
{ 'name' => 'tor_resource', 'ui_label' => 'What Tor resource to request', 'value' => 'http://xycpusearchon2mc.onion/deeplogo.jpg' },
{ 'name' => 'timeout', 'ui_label' => 'Detection timeout', 'value' => '10000' }
]
end
def post_execute
return if @datastore['result'].nil?
save({'result' => @datastore['result']})
save({ 'result' => @datastore['result'] })
end
end

View File

@@ -7,20 +7,17 @@
# DNS Enumeration
class Dns_enumeration < BeEF::Core::Command
def self.options
return [
{'name' => 'dns_list', 'ui_label' => 'DNS (comma separated)', 'value' => '%default%'},
{'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '4000'}
[
{ 'name' => 'dns_list', 'ui_label' => 'DNS (comma separated)', 'value' => '%default%' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '4000' }
]
end
def post_execute
content = {}
content['result'] =@datastore['result'] if not @datastore['result'].nil?
if content.empty?
content['fail'] = 'No DNS hosts have been discovered.'
end
content['result'] = @datastore['result'] unless @datastore['result'].nil?
content['fail'] = 'No DNS hosts have been discovered.' if content.empty?
save content
end
end

View File

@@ -1,50 +1,45 @@
class Dns_rebinding < BeEF::Core::Command
def self.options
domain = BeEF::Core::Configuration.instance.get('beef.module.dns_rebinding.domain')
dr_config = BeEF::Core::Configuration.instance.get('beef.extension.dns_rebinding')
url_callback = 'http://'+dr_config['address_proxy_external']+':'+dr_config['port_proxy'].to_s
return [{
'name'=>'target',
'value'=>'192.168.0.1'
},
{
'name'=>'domain',
'value'=>domain
},
{
'name'=>'url_callback',
'value'=>url_callback
}]
end
def self.options
domain = BeEF::Core::Configuration.instance.get('beef.module.dns_rebinding.domain')
dr_config = BeEF::Core::Configuration.instance.get('beef.extension.dns_rebinding')
url_callback = "http://#{dr_config['address_proxy_external']}:#{dr_config['port_proxy']}"
[{
'name' => 'target',
'value' => '192.168.0.1'
},
{
'name' => 'domain',
'value' => domain
},
{
'name' => 'url_callback',
'value' => url_callback
}]
end
def pre_send
dns = BeEF::Extension::Dns::Server.instance
dr_config = BeEF::Core::Configuration.instance.get('beef.extension.dns_rebinding')
def pre_send
dns = BeEF::Extension::Dns::Server.instance
dr_config = BeEF::Core::Configuration.instance.get('beef.extension.dns_rebinding')
addr = dr_config['address_http_external']
domain = BeEF::Core::Configuration.instance.get('beef.module.dns_rebinding.domain')
target_addr = "192.168.0.1"
addr = dr_config['address_http_external']
domain = BeEF::Core::Configuration.instance.get('beef.module.dns_rebinding.domain')
target_addr = '192.168.0.1'
if @datastore[0]
target_addr = @datastore[0]['value']
end
if @datastore[1]
domain = @datastore[1]['value']
end
id = dns.add_rule(
:pattern => domain,
:resource => Resolv::DNS::Resource::IN::A,
:response => [addr, target_addr]
)
target_addr = @datastore[0]['value'] if @datastore[0]
domain = @datastore[1]['value'] if @datastore[1]
dns.remove_rule!(id)
id = dns.add_rule(
:pattern => domain,
:resource => Resolv::DNS::Resource::IN::A,
:response => [addr, target_addr]
)
id = dns.add_rule(
pattern: domain,
resource: Resolv::DNS::Resource::IN::A,
response: [addr, target_addr]
)
end
dns.remove_rule!(id)
dns.add_rule(
pattern: domain,
resource: Resolv::DNS::Resource::IN::A,
response: [addr, target_addr]
)
end
end

View File

@@ -4,33 +4,26 @@
# See the file 'doc/COPYING' for copying permission
#
class Fetch_port_scanner < BeEF::Core::Command
# set and return all options for this module
def self.options
return [
{'name' => 'ipHost', 'ui_label' => 'Scan IP or Hostname', 'value' => '127.0.0.1'},
{'name' => 'ports' , 'ui_label' => 'Specific port(s) to scan', 'value' => 'top'}
]
end
def post_execute
content = {}
content['result'] = @datastore['result']
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
session_id = @datastore['beefhook']
# log the network service
# will need to once the datastore is confirmed.
# This should basically try and hook the browser
end
end
end
def self.options
[
{ 'name' => 'ipHost', 'ui_label' => 'Scan IP or Hostname', 'value' => '127.0.0.1' },
{ 'name' => 'ports', 'ui_label' => 'Specific port(s) to scan', 'value' => 'top' }
]
end
def post_execute
content = {}
content['result'] = @datastore['result']
save content
configuration = BeEF::Core::Configuration.instance
return unless configuration.get('beef.extension.network.enable') == true
session_id = @datastore['beefhook']
# @todo log the network service
# will need to once the datastore is confirmed.
# This should basically try and hook the browser
end
end

View File

@@ -5,40 +5,34 @@
#
class Get_http_servers < BeEF::Core::Command
def self.options
return [
{'name' => 'rhosts', 'ui_label' => 'Remote IP(s)', 'value' => 'common'},
{'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080'},
{'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3'},
{'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5'},
{'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10'}
[
{ 'name' => 'rhosts', 'ui_label' => 'Remote IP(s)', 'value' => 'common' },
{ 'name' => 'ports', 'ui_label' => 'Ports', 'value' => '80,8080' },
{ 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' },
{ 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' }
]
end
def post_execute
content = {}
content['url'] = @datastore['url'] if not @datastore['url'].nil?
if content.empty?
content['fail'] = 'No HTTP servers were discovered.'
end
content['url'] = @datastore['url'] unless @datastore['url'].nil?
content['fail'] = 'No HTTP servers were discovered.' if content.empty?
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=([\d]+)&url=(.+)/
proto = $1
ip = $2
port = $3
url = $4
session_id = @datastore['beefhook']
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP Server [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => "HTTP Server")
end
end
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=(\d+)&url=(.+)/
proto = Regexp.last_match(1)
ip = Regexp.last_match(2)
port = Regexp.last_match(3)
url = Regexp.last_match(4)
session_id = @datastore['beefhook']
if !ip.nil? && BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found HTTP Server [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: 'HTTP Server')
end
end
end

View File

@@ -4,39 +4,35 @@
# See the file 'doc/COPYING' for copying permission
#
class Get_ntop_network_hosts < BeEF::Core::Command
def self.options
return [
[
{ 'name' => 'rhost', 'ui_label' => 'Remote Host', 'value' => '127.0.0.1' },
{ 'name' => 'rport', 'ui_label' => 'Remote Port', 'value' => '3000' }
]
end
def post_execute
save({'result' => @datastore['result']})
save({ 'result' => @datastore['result'] })
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^proto=(https?)&ip=([\d\.]+)&port=([\d]+)&data=(.+)\z/
proto = $1
ip = $2
port = $3
data = $4
session_id = @datastore['beefhook']
type = 'ntop'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found 'ntop' [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => type)
end
data.to_s.scan(/"hostNumIpAddress":"([\d\.]+)"/).flatten.each do |ip|
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.create(:hooked_browser_id => session_id, :ip => ip, :port => port)
end
end
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /^proto=(https?)&ip=([\d.]+)&port=(\d+)&data=(.+)\z/
proto = Regexp.last_match(1)
ip = Regexp.last_match(2)
port = Regexp.last_match(3)
data = Regexp.last_match(4)
session_id = @datastore['beefhook']
type = 'ntop'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found 'ntop' [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: type)
end
data.to_s.scan(/"hostNumIpAddress":"([\d.]+)"/).flatten.each do |ip|
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, port: port)
end
end
end
end

View File

@@ -4,30 +4,27 @@
# See the file 'doc/COPYING' for copying permission
#
class Get_proxy_servers_wpad < BeEF::Core::Command
def post_execute
save({'result' => @datastore['result']})
save({ 'result' => @datastore['result'] })
configuration = BeEF::Core::Configuration.instance
return unless configuration.get("beef.extension.network.enable") == true
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /^proxies=(.+)$/
session_id = @datastore['beefhook']
if @datastore['results'] =~ /^proxies=(.+)$/
proxies = $1.to_s
proxies.split(',').uniq.each do |proxy|
if proxy =~ /^(SOCKS|PROXY)\s+([\d\.]+:[\d]{1,5})/
proxy_type = "#{$1}"
ip = $2.to_s.split(':')[0]
port = $2.to_s.split(':')[1]
proto = 'HTTP' if proxy_type =~ /PROXY/
proto = 'SOCKS' if proxy_type =~ /SOCKS/
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found #{proto} proxy [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto.downcase, :ip => ip, :port => port, :type => "#{proto} Proxy")
end
end
proxies = Regexp.last_match(1).to_s
proxies.split(',').uniq.each do |proxy|
next unless proxy =~ /^(SOCKS|PROXY)\s+([\d.]+:\d{1,5})/
proxy_type = Regexp.last_match(1).to_s
ip = Regexp.last_match(2).to_s.split(':')[0]
port = Regexp.last_match(2).to_s.split(':')[1]
proto = 'HTTP' if proxy_type =~ /PROXY/
proto = 'SOCKS' if proxy_type =~ /SOCKS/
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found #{proto} proxy [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto.downcase, ip: ip, port: port, type: "#{proto} Proxy")
end
end
end
end

View File

@@ -8,21 +8,17 @@
##
class Identify_lan_subnets < BeEF::Core::Command
def self.options
return [
{'name' => 'timeout', 'ui_label' => 'Timeout for each request (ms)', 'value' => '500'}
[
{ 'name' => 'timeout', 'ui_label' => 'Timeout for each request (ms)', 'value' => '500' }
]
end
def post_execute
content = {}
content['host'] = @datastore['host'] if not @datastore['host'].nil?
content['hosts'] = @datastore['hosts'] if not @datastore['hosts'].nil?
if content.empty?
content['fail'] = 'No active hosts have been discovered.'
end
content['host'] = @datastore['host'] unless @datastore['host'].nil?
content['hosts'] = @datastore['hosts'] unless @datastore['hosts'].nil?
content['fail'] = 'No active hosts have been discovered.' if content.empty?
save content
end
end

View File

@@ -5,42 +5,35 @@
#
class Internal_network_fingerprinting < BeEF::Core::Command
def self.options
return [
{'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254'},
{'name' => 'ports', 'ui_label' => 'Ports to test', 'value' => '80,8080'},
{'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3'},
{'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5'},
{'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10'}
[
{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class)', 'value' => '192.168.0.1-192.168.0.254' },
{ 'name' => 'ports', 'ui_label' => 'Ports to test', 'value' => '80,8080' },
{ 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' },
{ 'name' => 'wait', 'ui_label' => 'Wait (s) between each request for each worker', 'value' => '5' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout for each request (s)', 'value' => '10' }
]
end
def post_execute
content = {}
content['discovered'] = @datastore['discovered'] if not @datastore['discovered'].nil?
content['url'] = @datastore['url'] if not @datastore['url'].nil?
if content.empty?
content['fail'] = 'No devices/applications have been discovered.'
end
content['discovered'] = @datastore['discovered'] unless @datastore['discovered'].nil?
content['url'] = @datastore['url'] unless @datastore['url'].nil?
content['fail'] = 'No devices/applications have been discovered.' if content.empty?
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=([\d]+)&discovered=(.+)&url=(.+)/
proto = $1
ip = $2
port = $3
discovered = $4
url = $5
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found '#{discovered}' [ip: #{ip}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => discovered)
end
end
return unless configuration.get('beef.extension.network.enable') == true && (@datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=(\d+)&discovered=(.+)&url=(.+)/)
proto = Regexp.last_match(1)
ip = Regexp.last_match(2)
port = Regexp.last_match(3)
discovered = Regexp.last_match(4)
url = Regexp.last_match(5)
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found '#{discovered}' [ip: #{ip}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: discovered)
end
end
end

View File

@@ -5,39 +5,37 @@
#
class Fingerprint_routers < BeEF::Core::Command
def self.options
return [
]
[]
end
def post_execute
content = {}
content['results'] = @datastore['results'] if not @datastore['results'].nil?
content['results'] = @datastore['results'] unless @datastore['results'].nil?
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^proto=(.+)&ip=(.+)&port=([\d]+)&service=(.+)/
proto = $1
ip = $2
port = $3
service = $4
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service " + service + " [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :type => service)
end
elsif @datastore['results'] =~ /^ip=(.+)&device=(.+)/
ip = $1
device = $2
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network device " + device + " [ip: #{ip}]")
BeEF::Core::Models::NetworkHost.create(:hooked_browser_id => session_id, :ip => ip, :type => device)
end
return unless configuration.get('beef.extension.network.enable') == true
case @datastore['results']
when /^proto=(.+)&ip=(.+)&port=(\d+)&service=(.+)/
proto = Regexp.last_match(1)
ip = Regexp.last_match(2)
port = Regexp.last_match(3)
service = Regexp.last_match(4)
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service #{service} [proto: #{proto}, ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, type: service)
end
when /^ip=(.+)&device=(.+)/
ip = Regexp.last_match(1)
device = Regexp.last_match(2)
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network device #{device} [ip: #{ip}]")
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip, type: device)
end
end
end
end

View File

@@ -4,30 +4,28 @@
# See the file 'doc/COPYING' for copying permission
#
class Irc_nat_pinning < BeEF::Core::Command
def pre_send
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_socket("IRC", "0.0.0.0", 6667)
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind_socket('IRC', '0.0.0.0', 6667)
end
def self.options
@configuration = BeEF::Core::Configuration.instance
beef_host = @configuration.beef_host
return [
{'name'=>'connectto', 'ui_label' =>'Connect to','value'=>beef_host},
{'name'=>'privateip', 'ui_label' =>'Private IP','value'=>'192.168.0.100'},
{'name'=>'privateport', 'ui_label' =>'Private Port','value'=>'22'}
[
{ 'name' => 'connectto', 'ui_label' => 'Connect to', 'value' => beef_host },
{ 'name' => 'privateip', 'ui_label' => 'Private IP', 'value' => '192.168.0.100' },
{ 'name' => 'privateport', 'ui_label' => 'Private Port', 'value' => '22' }
]
end
def post_execute
return if @datastore['result'].nil?
save({'result' => @datastore['result']})
save({ 'result' => @datastore['result'] })
# wait 30 seconds before unbinding the socket. The HTTP connection will arrive sooner than that anyway.
sleep 30
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind_socket("IRC")
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind_socket('IRC')
end
end

View File

@@ -4,35 +4,30 @@
# See the file 'doc/COPYING' for copying permission
#
class Ping_sweep < BeEF::Core::Command
def post_execute
content = {}
content['result'] = @datastore['result']
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
return unless configuration.get('beef.extension.network.enable') == true
session_id = @datastore['beefhook']
# log the network service
return unless @datastore['results'] =~ /^ip=(.+)&ping=(\d+)ms$/
# log the network service
if @datastore['results'] =~ /^ip=(.+)&ping=(\d+)ms$/
ip = $1
ping = $2
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.create(:hooked_browser_id => session_id, :ip => ip)
end
end
ip = Regexp.last_match(1)
# ping = Regexp.last_match(2)
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found host #{ip}")
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip)
end
end
def self.options
return [
{'name' => 'rhosts', 'ui_label' => 'Scan IP range (C class)', 'value' => 'common' },
{'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3'}
[
{ 'name' => 'rhosts', 'ui_label' => 'Scan IP range (C class)', 'value' => 'common' },
{ 'name' => 'threads', 'ui_label' => 'Workers', 'value' => '3' }
]
end
end

View File

@@ -8,39 +8,31 @@
# Discover active hosts in the internal network of the hooked browser.
# It works calling a Java method from JavaScript and do not require user interaction.
class Ping_sweep_ff < BeEF::Core::Command
def self.options
return [
{'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254'},
{'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000'},
{'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '100'}
[
{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000' },
{ 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '100' }
]
end
def post_execute
content = {}
content['host'] =@datastore['host'] if not @datastore['host'].nil?
if content.empty?
content['fail'] = 'No active hosts have been discovered.'
end
content['host'] = @datastore['host'] unless @datastore['host'].nil?
content['fail'] = 'No active hosts have been discovered.' if content.empty?
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /host=([\d.]+) is alive/
session_id = @datastore['beefhook']
# save the network host
if @datastore['results'] =~ /host=([\d\.]+) is alive/
ip = $1
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser has network interface #{ip}")
BeEF::Core::Models::NetworkHost.create(:hooked_browser_id => session_id, :ip => ip)
end
end
# save the network host
ip = Regexp.last_match(1)
session_id = @datastore['beefhook']
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser has network interface #{ip}")
BeEF::Core::Models::NetworkHost.create(hooked_browser_id: session_id, ip: ip)
end
end
end

View File

@@ -8,26 +8,22 @@
# Discover active hosts in the internal network of the hooked browser.
# It works calling a Java method from JavaScript and do not require user interaction.
class Ping_sweep_java < BeEF::Core::Command
def pre_send
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/ping_sweep_java/pingSweep.class','/pingSweep','class')
end
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.bind('/modules/network/ping_sweep_java/pingSweep.class', '/pingSweep', 'class')
end
def self.options
return [
{'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254'},
{'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000'}
[
{ 'name' => 'ipRange', 'ui_label' => 'Scan IP range (C class or IP)', 'value' => '192.168.0.1-192.168.0.254' },
{ 'name' => 'timeout', 'ui_label' => 'Timeout (ms)', 'value' => '2000' }
]
end
def post_execute
content = {}
content['ps'] =@datastore['ps'] if not @datastore['ps'].nil?
if content.empty?
content['fail'] = 'No active hosts have been discovered.'
end
content['ps'] = @datastore['ps'] unless @datastore['ps'].nil?
content['fail'] = 'No active hosts have been discovered.' if content.empty?
BeEF::Core::NetworkStack::Handlers::AssetHandler.instance.unbind('/pingSweep.class')
save content
end

View File

@@ -5,46 +5,39 @@
#
#
# Port Scanner Module - javier.marcos
# Scan ports in a given hostname, using WebSockets CORS and HTTP with img tags.
# Scan ports in a given hostname, using WebSockets CORS and HTTP with img tags.
# It uses the three methods to avoid blocked ports or Same Origin Policy.
class Port_scanner < BeEF::Core::Command
def self.options
return [
{'name' => 'ipHost', 'ui_label' => 'Scan IP or Hostname', 'value' => '192.168.1.10'},
{'name' => 'ports' , 'ui_label' => 'Specific port(s) to scan', 'value' => 'top'},
{'name' => 'closetimeout' , 'ui_label' => 'Closed port timeout (ms)', 'value' => '1100'},
{'name' => 'opentimeout', 'ui_label' => 'Open port timeout (ms)', 'value' => '2500'},
{'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '600'},
{'name' => 'debug', 'ui_label' => 'Debug', 'value' => 'false'}
[
{ 'name' => 'ipHost', 'ui_label' => 'Scan IP or Hostname', 'value' => '192.168.1.10' },
{ 'name' => 'ports', 'ui_label' => 'Specific port(s) to scan', 'value' => 'top' },
{ 'name' => 'closetimeout', 'ui_label' => 'Closed port timeout (ms)', 'value' => '1100' },
{ 'name' => 'opentimeout', 'ui_label' => 'Open port timeout (ms)', 'value' => '2500' },
{ 'name' => 'delay', 'ui_label' => 'Delay between requests (ms)', 'value' => '600' },
{ 'name' => 'debug', 'ui_label' => 'Debug', 'value' => 'false' }
]
end
def post_execute
content = {}
content['port'] =@datastore['port'] if not @datastore['port'].nil?
if content.empty?
content['fail'] = 'No open ports have been found.'
end
content['port'] = @datastore['port'] unless @datastore['port'].nil?
content['fail'] = 'No open ports have been found.' if content.empty?
save content
configuration = BeEF::Core::Configuration.instance
if configuration.get("beef.extension.network.enable") == true
if @datastore['results'] =~ /^ip=([\d\.]+)&port=(CORS|WebSocket|HTTP): Port ([\d]+) is OPEN (.*)$/
ip = $1
port = $3
service = $4
session_id = @datastore['beefhook']
proto = 'http'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(:hooked_browser_id => session_id, :proto => proto, :ip => ip, :port => port, :ntype => service)
end
end
return unless configuration.get('beef.extension.network.enable') == true
return unless @datastore['results'] =~ /^ip=([\d.]+)&port=(CORS|WebSocket|HTTP): Port (\d+) is OPEN (.*)$/
ip = Regexp.last_match(1)
port = Regexp.last_match(3)
service = Regexp.last_match(4)
session_id = @datastore['beefhook']
proto = 'http'
if BeEF::Filters.is_valid_ip?(ip)
print_debug("Hooked browser found network service [ip: #{ip}, port: #{port}]")
BeEF::Core::Models::NetworkService.create(hooked_browser_id: session_id, proto: proto, ip: ip, port: port, ntype: service)
end
end
end