Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/core/main/migration.rb
1154 views
1
#
2
# Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
7
module BeEF
8
module Core
9
# @note This class migrates and updates values in the database each time you restart BeEF.
10
# So for example, when you want to add a new command module, you stop BeEF,
11
# copy your command module into the framework and then restart BeEF.
12
# That class will take care of installing automatically the new command module in the db.
13
class Migration
14
include Singleton
15
16
#
17
# Updates the database.
18
#
19
def update_db!
20
update_commands!
21
end
22
23
#
24
# Checks for new command modules and updates the database.
25
#
26
def update_commands!
27
config = BeEF::Core::Configuration.instance
28
29
db_modules = BeEF::Core::Models::CommandModule.all.pluck(:name)
30
31
config.get('beef.module').each do |k, v|
32
BeEF::Core::Models::CommandModule.new(name: k, path: "#{v['path']}module.rb").save! unless db_modules.include? k
33
end
34
35
BeEF::Core::Models::CommandModule.all.each do |mod|
36
unless config.get("beef.module.#{mod.name}").nil?
37
config.set "beef.module.#{mod.name}.db.id", mod.id
38
config.set "beef.module.#{mod.name}.db.path", mod.path
39
end
40
end
41
42
# Call Migration method
43
BeEF::API::Registrar.instance.fire BeEF::API::Migration, 'migrate_commands'
44
end
45
end
46
end
47
end
48
49