#1# Copyright (c) 2006-2025 Wade Alcorn - [email protected]2# Browser Exploitation Framework (BeEF) - https://beefproject.com3# See the file 'doc/COPYING' for copying permission4#56module BeEF7module Core8# @note This class migrates and updates values in the database each time you restart BeEF.9# So for example, when you want to add a new command module, you stop BeEF,10# copy your command module into the framework and then restart BeEF.11# That class will take care of installing automatically the new command module in the db.12class Migration13include Singleton1415#16# Updates the database.17#18def update_db!19update_commands!20end2122#23# Checks for new command modules and updates the database.24#25def update_commands!26config = BeEF::Core::Configuration.instance2728db_modules = BeEF::Core::Models::CommandModule.all.pluck(:name)2930config.get('beef.module').each do |k, v|31BeEF::Core::Models::CommandModule.new(name: k, path: "#{v['path']}module.rb").save! unless db_modules.include? k32end3334BeEF::Core::Models::CommandModule.all.each do |mod|35unless config.get("beef.module.#{mod.name}").nil?36config.set "beef.module.#{mod.name}.db.id", mod.id37config.set "beef.module.#{mod.name}.db.path", mod.path38end39end4041# Call Migration method42BeEF::API::Registrar.instance.fire BeEF::API::Migration, 'migrate_commands'43end44end45end46end474849