Refactored models to use ActiveRecord

This commit is contained in:
Ben Passmore
2019-10-08 16:15:55 +10:00
parent 4cecca4075
commit d588c56391
7 changed files with 14 additions and 101 deletions

View File

@@ -11,15 +11,8 @@ module Models
#
# For example, the type and version of browser the hooked browsers are using.
#
class BrowserDetails
class BrowserDetails < BeEF::Core::Model
include DataMapper::Resource
storage_names[:default] = 'core_browserdetails'
property :session_id, String, :length => 255, :key => true
property :detail_key, String, :length => 255, :lazy => false, :key => true
property :detail_value, Text, :lazy => false
#
# Returns the requested value from the data store
#

View File

@@ -9,19 +9,9 @@ module Core
module Models
# @note Table stores the commands that have been sent to the Hooked Browsers.
class Command
class Command < BeEF::Core::Model
include DataMapper::Resource
storage_names[:default] = 'commands'
property :id, Serial
property :data, Text
property :creationdate, String, :length => 15, :lazy => false
property :label, Text, :lazy => false
property :instructions_sent, Boolean, :default => false
has n, :results
has_many :results
#
# Save results and flag that the command has been run on the hooked browser

View File

@@ -7,22 +7,10 @@ module BeEF
module Core
module Models
class CommandModule
class CommandModule < BeEF::Core::Model
include DataMapper::Resource
has_many :commands
storage_names[:default] = 'core_commandmodules'
# @note command module ID
property :id, Serial
# @note command module name
property :name, Text, :lazy => false
# @note command module path
property :path, Text, :lazy => false
has n, :commands
end
end

View File

@@ -9,45 +9,11 @@ module Models
#
#
#
class HookedBrowser
class HookedBrowser < BeEF::Core::Model
include DataMapper::Resource
storage_names[:default] = 'core_hookedbrowsers'
# @note zombie ID
property :id, Serial
# @note hooked browser session ID
property :session, Text, :lazy => false
# @note IP address of the hooked browser
property :ip, Text, :lazy => false
# @note timestamp first time the browser communicated with BeEF
property :firstseen, String, :length => 15
# @note timestamp last time the browser communicated with BeEF
property :lastseen, String, :length => 15
# @note HTTP headers sent be the browser to the BeEF server upon first hook
property :httpheaders, Text, :lazy => false
# @note the domain originating the hook request
property :domain, Text, :lazy => false
# @note the port on the domain originating the hook request
property :port, Integer, :default => 80
# @note number of times the zombie has polled
property :count, Integer, :lazy => false
# @note if true the HB is used as a tunneling proxy
property :is_proxy, Boolean, :default => false
has n, :commands
has n, :results
has n, :logs
has_many :commands
has_many :results
has_many :logs
# @note Increases the count of a zombie
def count!

View File

@@ -7,17 +7,10 @@ module BeEF
module Core
module Models
class Log
class Log < BeEF::Core::Model
has_one :hooked_browser
include DataMapper::Resource
storage_names[:default] = 'core_logs'
property :id, Serial
property :type, Text, :lazy => false
property :event, Text, :lazy => false
property :date, DateTime, :lazy => false
property :hooked_browser_id, Text, :lazy => false
end
end

View File

@@ -7,15 +7,7 @@ module BeEF
module Core
module Models
class OptionCache
include DataMapper::Resource
storage_names[:default] = 'core_optioncache'
property :id, Serial
property :name, Text
property :value, Text
class OptionCache < BeEF::Core::Model
end

View File

@@ -7,16 +7,7 @@ module BeEF
module Core
module Models
class Result
include DataMapper::Resource
storage_names[:default] = 'core_results'
property :id, Serial
property :date, String, :length => 15, :lazy => false
property :status, Integer
property :data, Text
class Result < BeEF::Core::Model
end