Syntax changes

This commit is contained in:
Jess
2019-11-14 22:09:44 -08:00
parent 87b8093504
commit 9b5c8e39df
27 changed files with 164 additions and 217 deletions

View File

@@ -7,14 +7,10 @@ module BeEF
module Core
module Models
class Autoloading
include DataMapper::Resource
storage_names[:default] = 'autoloading'
property :id, Serial
property :in_use, Boolean
class Autoloading < ActiveRecord::Base
attribute :id, :Serial
attribute :in_use, :Boolean
belongs_to :command

View File

@@ -9,19 +9,14 @@ module BeEF
module Dns
# Represents an individual DNS rule.
class Rule
include DataMapper::Resource
storage_names[:default] = 'extension_dns_rules'
property :id, String, :key => true
property :pattern, Object, :required => true
property :resource, Object, :required => true
property :response, Object, :required => true
property :callback, Object, :required => true
class Rule < ActiveRecord::Base
attribute :id, :String, :key => true
attribute :pattern, :Object, :required => true
attribute :resource, :Object, :required => true
attribute :response, :Object, :required => true
attribute :callback, :Object, :required => true
# Hooks the model's "save" event. Validates pattern/response and generates a rule identifier.
before :save do |rule|
before_save do |rule|
begin
validate_pattern(rule.pattern)
rule.callback = format_callback(rule.resource, rule.response)

View File

@@ -6,19 +6,13 @@
module BeEF
module Core
module Models
class IpecExploits
class IpecExploits < ActiveRecord::Base
attribute :id, :Serial
attribute :name, :Text, :lazy => false
attribute :protocol, :String, :lazy => false
attribute :os, :String, :lazy => false
include DataMapper::Resource
#todo: use this table when we'll have a bigger IPEC exploits choice
storage_names[:default] = 'extension_ipec_exploits'
property :id, Serial
property :name, Text, :lazy => false
property :protocol, String, :lazy => false
property :os, String, :lazy => false
has n, :extension_ipec_exploits_run, 'IpecExploitsRun'
belongs_to :extension_ipec_exploits_run, 'IpecExploitsRun'
end

View File

@@ -6,16 +6,12 @@
module BeEF
module Core
module Models
class IpecExploitsRun
class IpecExploitsRun < ActiveRecord::Base
include DataMapper::Resource
#todo: use this table when we'll have a bigger IPEC exploits choice
storage_names[:default] = 'extension_ipec_exploits_run'
property :id, Serial
property :launched, Boolean, :lazy => false
property :http_headers, Text, :lazy => false
property :junk_size, String, :length => 3, :lazy => false
attribute :id, :Serial
attribute :launched, :Boolean, :lazy => false
attribute :http_headers, :Text, :lazy => false
attribute :junk_size, :String, :length => 3, :lazy => false
belongs_to :ipec_exploits

View File

@@ -9,20 +9,15 @@ module BeEF
#
# Table stores each host identified on the zombie browser's network(s)
#
class NetworkHost
include DataMapper::Resource
storage_names[:default] = 'network_host'
property :id, Serial
property :hooked_browser_id, Text, lazy: false
property :ip, Text, lazy: false
property :hostname, String, lazy: false
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
class NetworkHost < ActiveRecord::Base
attribute :id, :Serial
attribute :hooked_browser_id, :Text, lazy: false
attribute :ip, :Text, lazy: false
attribute :hostname, :String, lazy: false
attribute :type, :String, lazy: false # proxy, router, gateway, dns, etc
attribute :os, :String, lazy: false
attribute :mac, :String, lazy: false
attribute :lastseen, :String, length: 15
#
# Stores a network host in the data store
#

View File

@@ -9,19 +9,15 @@ module BeEF
#
# Table stores each open port identified on the zombie browser's network(s)
#
class NetworkService
include DataMapper::Resource
storage_names[:default] = 'network_service'
class NetworkService < ActiveRecord::Base
attribute :id, :Serial
attribute :hooked_browser_id, :Text, lazy: false
attribute :proto, :String, lazy: false
attribute :ip, :Text, lazy: false
attribute :port, :String, lazy: false
attribute :type, :String, lazy: false
property :id, Serial
property :hooked_browser_id, Text, lazy: false
property :proto, String, lazy: false
property :ip, Text, lazy: false
property :port, String, lazy: false
property :type, String, lazy: false
#
# Stores a network service in the data store
#
def self.add(service = {})

View File

@@ -9,67 +9,61 @@ module Models
#
# Table stores the http requests and responses from the requester.
#
class Http
include DataMapper::Resource
storage_names[:default] = 'extension_requester_http'
property :id, Serial
class Http < ActiveRecord::Base
attribute :id, :Serial
# The hooked browser id
property :hooked_browser_id, Text, :lazy => false
attribute :hooked_browser_id, :Text, :lazy => false
# The http request to perform. In clear text.
property :request, Text, :lazy => true
attribute :request, :Text, :lazy => true
# Boolean value as string to say whether cross-domain requests are allowed
property :allow_cross_domain, Text, :lazy => false, :default => "true"
attribute :allow_cross_domain, :Text, :lazy => false, :default => "true"
# The http response body received. In clear text.
property :response_data, Binary, :lazy => true, :length => 2097152
attribute :response_data, :Binary, :lazy => true, :length => 2097152
# The http response code. Useful to handle cases like 404, 500, 302, ...
property :response_status_code, Integer, :lazy => true
attribute :response_status_code, :Integer, :lazy => true
# The http response code. Human-readable code: success, error, ecc..
property :response_status_text, Text, :lazy => true
attribute :response_status_text, :Text, :lazy => true
# The port status. closed, open or not http
property :response_port_status, Text, :lazy => true
attribute :response_port_status, :Text, :lazy => true
# The XHR Http response raw headers
property :response_headers, Text, :lazy => true
attribute :response_headers, :Text, :lazy => true
# The http response method. GET or POST.
property :method, Text, :lazy => false
attribute :method, :Text, :lazy => false
# The content length for the request.
property :content_length, Text, :lazy => false, :default => 0
attribute :content_length, :Text, :lazy => false, :default => 0
# The request protocol/scheme (http/https)
property :proto, Text, :lazy => false
attribute :proto, :Text, :lazy => false
# The domain on which perform the request.
property :domain, Text, :lazy => false
attribute :domain, :Text, :lazy => false
# The port on which perform the request.
property :port, Text, :lazy => false
attribute :port, :Text, :lazy => false
# Boolean value to say if the request was cross-domain
property :has_ran, Text, :lazy => false, :default => "waiting"
attribute :has_ran, :Text, :lazy => false, :default => "waiting"
# The path of the request.
# Example: /secret.html
property :path, Text, :lazy => false
attribute :path, :Text, :lazy => false
# The date at which the http response has been saved.
property :response_date, DateTime, :lazy => false
attribute :response_date, :DateTime, :lazy => false
# The date at which the http request has been saved.
property :request_date, DateTime, :lazy => false
attribute :request_date, :DateTime, :lazy => false
#
# Removes a request/response from the data store
#
def self.delete(id)

View File

@@ -6,15 +6,10 @@
module BeEF
module Core
module Models
class Interceptor
include DataMapper::Resource
storage_names[:default] = 'extension_seng_interceptor'
property :id, Serial
property :ip, Text, :lazy => false
property :post_data, Text, :lazy => false
class Interceptor < ActiveRecord::Base
attribute :id, :Serial
attribute :ip, :Text, :lazy => false
attribute :post_data, :Text, :lazy => false
belongs_to :webcloner

View File

@@ -7,13 +7,9 @@ module BeEF
module Core
module Models
class Massmailer
class Massmailer < ActiveRecord::Base
include DataMapper::Resource
storage_names[:default] = 'extension_seng_massmailer'
property :id, Serial
attribute :id, Serial
#todo fields
end

View File

@@ -6,19 +6,13 @@
module BeEF
module Core
module Models
class Webcloner
class Webcloner < ActiveRecord::Base
attribute :id, :Serial
include DataMapper::Resource
storage_names[:default] = 'extension_seng_webcloner'
property :id, Serial
property :uri, Text, :lazy => false
property :mount, Text, :lazy => false
has n, :extension_seng_interceptor, 'Interceptor'
attribute :uri, :Text, :lazy => false
attribute :mount, :Text, :lazy => false
belongs_tos :extension_seng_interceptor, 'Interceptor'
end
end

View File

@@ -9,23 +9,18 @@ module Models
#
# Table stores the queued up JS commands for managing the client-side webrtc logic.
#
class Rtcmanage
include DataMapper::Resource
storage_names[:default] = 'extension_webrtc_rtcmanage'
property :id, Serial
class Rtcmanage < ActiveRecord::Base
attribute :id, :Serial
# The hooked browser id
property :hooked_browser_id, Text, :lazy => false
attribute :hooked_browser_id, :Text, :lazy => false
# The message
property :message, Text, :lazy => true
attribute :message, :Text, :lazy => true
# Boolean value to say if the signal has been sent to the target peer
property :has_sent, Text, :lazy => false, :default => "waiting"
attribute :has_sent, :Text, :lazy => false, :default => "waiting"
# Starts the RTCPeerConnection process, establishing a WebRTC connection between the caller and the receiver
def self.initiate(caller, receiver, verbosity = false)
stunservers = BeEF::Core::Configuration.instance.get("beef.extension.webrtc.stunservers")

View File

@@ -13,32 +13,28 @@ module Models
#
class Rtcmodulestatus
include DataMapper::Resource
storage_names[:default] = 'extension_webrtc_rtcmodulestatus'
property :id, Serial
class Rtcmodulestatus < ActiveRecord::Base
attribute :id, :Serial
# The hooked browser id
property :hooked_browser_id, Text, :lazy => false
attribute :hooked_browser_id, :Text, :lazy => false
# The hooked browser's IP
# property :hooked_browser_ip, Text, :lazy => false
attribute :hooked_browser_ip, :Text, :lazy => false
# The target hooked browser id
property :target_hooked_browser_id, Text, :lazy => false
attribute :target_hooked_browser_id, :Text, :lazy => false
# The command module ID
property :command_module_id, Text, :lazy => false
attribute :command_module_id, :Text, :lazy => false
# The status field
property :status, Text, :lazy => true
attribute :status, :Text, :lazy => true
# Timestamps
property :created_at, DateTime
property :updated_at, DateTime
attribute :created_at, DateTime
attribute :updated_at, DateTime
end

View File

@@ -9,25 +9,21 @@ module Models
#
# Table stores the webrtc signals from a hooked_browser, directed to a target_hooked_browser
#
class Rtcsignal
include DataMapper::Resource
storage_names[:default] = 'extension_webrtc_rtcsignals'
property :id, Serial
class Rtcsignal < ActiveRecord::Base
attribute :id, :Serial
# The hooked browser id
property :hooked_browser_id, Text, :lazy => false
attribute :hooked_browser_id, :Text, :lazy => false
# The target hooked browser id
property :target_hooked_browser_id, Text, :lazy => false
attribute :target_hooked_browser_id, :Text, :lazy => false
# The WebRTC signal to submit. In clear text.
property :signal , Text, :lazy => true
attribute :signal , :Text, :lazy => true
# Boolean value to say if the signal has been sent to the target peer
property :has_sent, Text, :lazy => false, :default => "waiting"
attribute :has_sent, :Text, :lazy => false, :default => "waiting"
end

View File

@@ -13,32 +13,28 @@ module Models
#
class Rtcstatus
include DataMapper::Resource
storage_names[:default] = 'extension_webrtc_rtcstatus'
property :id, Serial
class Rtcstatus < ActiveRecord::Base
attribute :id, :Serial
# The hooked browser id
property :hooked_browser_id, Text, :lazy => false
attribute :hooked_browser_id, :Text, :lazy => false
# The hooked browser's IP
# property :hooked_browser_ip, Text, :lazy => false
# The target hooked browser id
property :target_hooked_browser_id, Text, :lazy => false
attribute :target_hooked_browser_id, :Text, :lazy => false
# The target hooked browser's IP
# property :target_hooked_browser_ip, Text, :lazy => false
# The status field
property :status, Text, :lazy => true
attribute :status, :Text, :lazy => true
# Timestamps
property :created_at, DateTime
property :updated_at, DateTime
attribute :created_at, DateTime
attribute :updated_at, DateTime
end

View File

@@ -9,25 +9,20 @@ module Models
#
# Store the rays details, basically verified XSS vulnerabilities
#
class Xssraysdetail
include DataMapper::Resource
storage_names[:default] = 'extension_xssrays_details'
property :id, Serial
class Xssraysdetail < ActiveRecord::Base
attribute :id, :Serial
# The hooked browser id
property :hooked_browser_id, Text, :lazy => false
attribute :hooked_browser_id, :Text, :lazy => false
# The XssRays vector name for the vulnerability
property :vector_name, Text, :lazy => true
attribute :vector_name, :Text, :lazy => true
# The XssRays vector method (GET or POST) for the vulnerability
property :vector_method, Text, :lazy => true
attribute :vector_method, :Text, :lazy => true
# The XssRays Proof of Concept for the vulnerability
property :vector_poc, Text, :lazy => true
attribute :vector_poc, :Text, :lazy => true
belongs_to :xssraysscan
end

View File

@@ -9,28 +9,23 @@ module Models
#
# Store the XssRays scans started and finished, with relative ID
#
class Xssraysscan
class Xssraysscan < ActiveRecord::Base
include DataMapper::Resource
attribute :id, :Serial
storage_names[:default] = 'extension_xssrays_scans'
attribute :hooked_browser_id, :Text, :lazy => false
property :id, Serial
attribute :scan_start, :DateTime, :lazy => true
attribute :scan_finish, :DateTime, :lazy => true
property :hooked_browser_id, Text, :lazy => false
attribute :domain, :Text, :lazy => true
attribute :cross_domain, :Text, :lazy => true
attribute :clean_timeout, :Integer, :lazy => false
property :scan_start, DateTime, :lazy => true
property :scan_finish, DateTime, :lazy => true
property :domain, Text, :lazy => true
property :cross_domain, Text, :lazy => true
property :clean_timeout, Integer, :lazy => false
property :is_started, Boolean, :lazy => false, :default => false
property :is_finished, Boolean, :lazy => false, :default => false
has n, :extension_xssrays_details, 'Xssraysdetail'
attribute :is_started, :Boolean, :lazy => false, :default => false
attribute :is_finished, :Boolean, :lazy => false, :default => false
belongs_to :extension_xssrays_details
end
end

View File

@@ -9,8 +9,10 @@ RSpec.describe 'BeEF API Rate Limit' do
before(:all) do
# Note: rake spec passes --patterns which causes BeEF to pickup this argument via optparse. I can't see a better way at the moment to filter this out. Therefore ARGV=[] for this test.
ARGV = []
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
http_hook_server = BeEF::Core::Server.instance
http_hook_server.prepare

View File

@@ -2,8 +2,10 @@ RSpec.describe 'BeEF BrowserDetails' do
before(:all) do
@session = (0...10).map { ('a'..'z').to_a[rand(26)] }.join
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
end
it 'set nil value' do

View File

@@ -1,13 +1,16 @@
require 'resolv'
require 'extensions/dns/extension.rb'
require 'extensions/dns/extension'
RSpec.describe 'BeEF Extension DNS' do
IN = Resolv::DNS::Resource::IN
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config
@dns = BeEF::Extension::Dns::Server.instance

View File

@@ -3,8 +3,10 @@ require 'extensions/ipec/extension'
RSpec.describe 'BeEF Extension IPEC' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config
end

View File

@@ -4,8 +4,10 @@ require 'extensions/network/models/network_host'
RSpec.describe 'BeEF Extension Network' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
end
it 'add good host' do

View File

@@ -3,8 +3,10 @@ require 'extensions/proxy/extension'
RSpec.describe 'BeEF Extension Proxy' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config
end

View File

@@ -3,8 +3,10 @@ require 'extensions/qrcode/extension'
RSpec.describe 'BeEF Extension QRCode' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config
end

View File

@@ -3,8 +3,10 @@ require 'extensions/requester/extension'
RSpec.describe 'BeEF Extension Requester' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config
end

View File

@@ -3,8 +3,10 @@ require 'rest-client'
RSpec.describe 'BeEF Extension WebRTC' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config

View File

@@ -3,8 +3,10 @@ require 'extensions/xssrays/extension'
RSpec.describe 'BeEF Extension XSSRays' do
before(:all) do
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
ActiveRecord::Base.establish_connection(
database: "beef.db",
adapter: "sqlite3"
)
@config = BeEF::Core::Configuration.instance
@config.load_extensions_config
end

View File

@@ -25,9 +25,11 @@ class TC_Proxy < Test::Unit::TestCase
@@proxy_config = config.get('beef.extension.proxy')
@@proxy = "#{@@proxy_config['address']}:#{@@proxy_config['port']}"
# set up datamapper
DataMapper.setup(:default, 'sqlite3::memory:')
DataMapper.auto_migrate!
# set up active record
ActiveRecord::Base.establish_connection(
database: "beef.db"
adapter: "sqlite3"
)
# set headers for rest requests
@@headers = { :content_type => :json, :accept => :json }