From d95995627103c8a90d4c330896aa8847b1c32884 Mon Sep 17 00:00:00 2001 From: jcrew99 Date: Sun, 18 Jul 2021 13:05:15 +1000 Subject: [PATCH 1/4] added a check for the version added --- beef | 6 +++++- spec/beef/api/auth_rate_spec.rb | 6 +++++- spec/beef/core/main/autorun_engine/autorun_engine_spec.rb | 6 +++++- spec/beef/extensions/requester_spec.rb | 7 ++++++- spec/beef/extensions/websocket_hooked_browser_spec.rb | 5 +++++ spec/beef/modules/debug/test_beef_debugs_spec.rb | 6 +++++- spec/spec_helper.rb | 5 +++++ 7 files changed, 36 insertions(+), 5 deletions(-) diff --git a/beef b/beef index 3de664989..a0aede467 100755 --- a/beef +++ b/beef @@ -167,12 +167,16 @@ end ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:db_file) +# otr-activerecord require you to manually establish the connection with the following line +#Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. +if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! +end # Migrate (if required) context = ActiveRecord::Migration.new.migration_context if context.needs_migration? ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration).migrate end - # # @note Extensions may take a moment to load, thus we print out a please wait message # diff --git a/spec/beef/api/auth_rate_spec.rb b/spec/beef/api/auth_rate_spec.rb index 34b6e6a0c..7636292ef 100644 --- a/spec/beef/api/auth_rate_spec.rb +++ b/spec/beef/api/auth_rate_spec.rb @@ -43,7 +43,11 @@ RSpec.describe 'BeEF API Rate Limit' do ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database: db_file) - + # otr-activerecord require you to manually establish the connection with the following line + #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! + end context = ActiveRecord::Migration.new.migration_context if context.needs_migration? ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration).migrate diff --git a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb index 309ed9bda..164e74adc 100644 --- a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb +++ b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb @@ -48,7 +48,11 @@ RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) - + # otr-activerecord require you to manually establish the connection with the following line + #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! + end context = ActiveRecord::Migration.new.migration_context ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration).migrate if context.needs_migration? diff --git a/spec/beef/extensions/requester_spec.rb b/spec/beef/extensions/requester_spec.rb index 292cb9d3c..869941fba 100644 --- a/spec/beef/extensions/requester_spec.rb +++ b/spec/beef/extensions/requester_spec.rb @@ -34,7 +34,12 @@ RSpec.describe 'BeEF Extension Requester' do ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:'beef.db') - # Migrate (if required) + # otr-activerecord require you to manually establish the connection with the following line + #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! + end +# Migrate (if required) context = ActiveRecord::Migration.new.migration_context diff --git a/spec/beef/extensions/websocket_hooked_browser_spec.rb b/spec/beef/extensions/websocket_hooked_browser_spec.rb index ad219b7a2..52e76e3ab 100644 --- a/spec/beef/extensions/websocket_hooked_browser_spec.rb +++ b/spec/beef/extensions/websocket_hooked_browser_spec.rb @@ -48,6 +48,11 @@ RSpec.describe 'Browser hooking with Websockets', run_on_browserstack: true do ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) + # otr-activerecord require you to manually establish the connection with the following line + #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! + end context = ActiveRecord::Migration.new.migration_context ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration).migrate if context.needs_migration? sleep 2 diff --git a/spec/beef/modules/debug/test_beef_debugs_spec.rb b/spec/beef/modules/debug/test_beef_debugs_spec.rb index c4f0531a6..d26361d57 100644 --- a/spec/beef/modules/debug/test_beef_debugs_spec.rb +++ b/spec/beef/modules/debug/test_beef_debugs_spec.rb @@ -47,7 +47,11 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) - + # otr-activerecord require you to manually establish the connection with the following line + #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! + end context = ActiveRecord::Migration.new.migration_context ActiveRecord::Migrator.new(:up, context.migrations, context.schema_migration).migrate if context.needs_migration? diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 78c374796..365298859 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -47,6 +47,11 @@ CONFIG['key'] = ENV['BROWSERSTACK_ACCESS_KEY'] || '' ActiveRecord::Base.logger = nil OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations')] OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:':memory:') +# otr-activerecord require you to manually establish the connection with the following line +#Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. +if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + OTR::ActiveRecord.establish_connection! +end ActiveRecord::Schema.verbose = false context = ActiveRecord::Migration.new.migration_context if context.needs_migration? From 6d882b50163716fb3c28c90049ae65f87fd06990 Mon Sep 17 00:00:00 2001 From: jcrew99 Date: Sun, 18 Jul 2021 13:12:13 +1000 Subject: [PATCH 2/4] removed the lock on the activerecord gem --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 1da41ba1f..c27cb6873 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'rubyzip', '>= 1.2.2' gem 'espeak-ruby', '>= 1.0.4' # Text-to-Voice gem 'nokogiri', '>= 1.11.1' gem 'rake', '>= 12.3.3' -gem 'otr-activerecord', '~> 1.4.1' +gem 'otr-activerecord' gem 'sqlite3' gem 'rubocop', '~> 0.92.0', require: false From 588e32966a905ee579aadb8dad9c05827b0cccd0 Mon Sep 17 00:00:00 2001 From: jcrew99 Date: Sun, 18 Jul 2021 13:36:28 +1000 Subject: [PATCH 3/4] changed from 2.0 to 1.4.2 --- beef | 2 +- spec/beef/api/auth_rate_spec.rb | 2 +- spec/beef/core/main/autorun_engine/autorun_engine_spec.rb | 2 +- spec/beef/extensions/requester_spec.rb | 2 +- spec/beef/extensions/websocket_hooked_browser_spec.rb | 2 +- spec/beef/modules/debug/test_beef_debugs_spec.rb | 2 +- spec/spec_helper.rb | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/beef b/beef index a0aede467..ea723c015 100755 --- a/beef +++ b/beef @@ -169,7 +169,7 @@ OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations') OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. -if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') +if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end # Migrate (if required) diff --git a/spec/beef/api/auth_rate_spec.rb b/spec/beef/api/auth_rate_spec.rb index 7636292ef..cbc5958fc 100644 --- a/spec/beef/api/auth_rate_spec.rb +++ b/spec/beef/api/auth_rate_spec.rb @@ -45,7 +45,7 @@ RSpec.describe 'BeEF API Rate Limit' do OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. - if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end context = ActiveRecord::Migration.new.migration_context diff --git a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb index 164e74adc..c263d23a5 100644 --- a/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb +++ b/spec/beef/core/main/autorun_engine/autorun_engine_spec.rb @@ -50,7 +50,7 @@ RSpec.describe 'AutoRunEngine Test', run_on_browserstack: true do OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. - if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end context = ActiveRecord::Migration.new.migration_context diff --git a/spec/beef/extensions/requester_spec.rb b/spec/beef/extensions/requester_spec.rb index 869941fba..189695ade 100644 --- a/spec/beef/extensions/requester_spec.rb +++ b/spec/beef/extensions/requester_spec.rb @@ -36,7 +36,7 @@ RSpec.describe 'BeEF Extension Requester' do OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:'beef.db') # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. - if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end # Migrate (if required) diff --git a/spec/beef/extensions/websocket_hooked_browser_spec.rb b/spec/beef/extensions/websocket_hooked_browser_spec.rb index 52e76e3ab..9505e7853 100644 --- a/spec/beef/extensions/websocket_hooked_browser_spec.rb +++ b/spec/beef/extensions/websocket_hooked_browser_spec.rb @@ -50,7 +50,7 @@ RSpec.describe 'Browser hooking with Websockets', run_on_browserstack: true do OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. - if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end context = ActiveRecord::Migration.new.migration_context diff --git a/spec/beef/modules/debug/test_beef_debugs_spec.rb b/spec/beef/modules/debug/test_beef_debugs_spec.rb index d26361d57..43477e9ab 100644 --- a/spec/beef/modules/debug/test_beef_debugs_spec.rb +++ b/spec/beef/modules/debug/test_beef_debugs_spec.rb @@ -49,7 +49,7 @@ RSpec.describe 'BeEF Debug Command Modules:', run_on_browserstack: true do OTR::ActiveRecord.configure_from_hash!(adapter: 'sqlite3', database: db_file) # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. - if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') + if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end context = ActiveRecord::Migration.new.migration_context diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 365298859..bbefd4aae 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -49,7 +49,7 @@ OTR::ActiveRecord.migrations_paths = [File.join('core', 'main', 'ar-migrations') OTR::ActiveRecord.configure_from_hash!(adapter:'sqlite3', database:':memory:') # otr-activerecord require you to manually establish the connection with the following line #Also a check to confirm that the correct Gem version is installed to require it, likely easier for old systems. -if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('2.0') +if Gem.loaded_specs['otr-activerecord'].version > Gem::Version.create('1.4.2') OTR::ActiveRecord.establish_connection! end ActiveRecord::Schema.verbose = false From b4dae0f58bee3245f7cf2df0e7417bebc8b30096 Mon Sep 17 00:00:00 2001 From: jcrew99 Date: Tue, 20 Jul 2021 01:43:34 +1000 Subject: [PATCH 4/4] Updating Gemfile lock as suggested --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c27cb6873..759ba2d23 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ gem 'rubyzip', '>= 1.2.2' gem 'espeak-ruby', '>= 1.0.4' # Text-to-Voice gem 'nokogiri', '>= 1.11.1' gem 'rake', '>= 12.3.3' -gem 'otr-activerecord' +gem 'otr-activerecord', '>= 1.4.2' gem 'sqlite3' gem 'rubocop', '~> 0.92.0', require: false