Skip to content

Instantly share code, notes, and snippets.

View limhoff-r7's full-sized avatar

Luke Imhoff limhoff-r7

  • Rapid7, Inc.
  • Austin, TX
View GitHub Profile
@limhoff-r7
limhoff-r7 / i18n-fail.log
Last active August 29, 2015 14:01
Encoding::UndefinedConversionError when msf/sanity is required and sets encodings to binary and something explicitly sets the external encoding to utif-8
Encoding.default_external: UTF-8
Encoding.default_internal:
Encoding.default_external: ASCII-8BIT
Encoding.default_internal: ASCII-8BIT
Setting no encoding on file
f.external_encoding: ASCII-8BIT
f.internal_encoding:
Contents: امثلة
@limhoff-r7
limhoff-r7 / initializers.sh
Last active August 29, 2015 14:02
Rails initializer tsort, dot digraph and png generation
dot -o initializers.png -T png initializers.dot
@limhoff-r7
limhoff-r7 / connection_established.rb
Created May 30, 2014 20:06
ActiveRecord::Base.establish_connection doesn't actually test that your connection spec can connect to the database. You need to ask for a connection to test that explicitly.
ActiveRecord::Base.establish_connection
# Check if the spec passed to `ActiveRecord::Base.establish_connection` can connect to the database.
#
# @return [true] if an active connection can be made to the database using the current config.
# @return [false] if an active connection cannot be made to the database.
def connection_established?
begin
# use with_connection so the connection doesn't stay pinned to the thread.
ActiveRecord::Base.connection_pool.with_connection {
@limhoff-r7
limhoff-r7 / where.rb
Created July 15, 2014 14:29
Postgres INET contains (<<) operator search using MetasploitDataModels::IPAddress::CIDR
attribute = Mdm::Host.arel_table[:address]
value = MetasploitDataModels::IPAddress::V4::CIDR.new(value: '1.2.3.4/8')
formatted_value = "#{value.address}/#{value.prefix_length}"
cast_argument = Arel::Nodes::As.new(formatted_value, Arel::Nodes::SqlLiteral.new('INET'))
# @see https://gist.github.com/mrpunkin/1996454
value_as_inet = Arel::Nodes::NamedFunction.new('CAST', [cast_argument])
operation = Arel::Nodes::InfixOperation.new(
'<<',
@limhoff-r7
limhoff-r7 / en.yml
Created July 17, 2014 14:22
Getting help text for search operators
en:
metasploit:
model:
# help for an operator on a specific class/module (Metasploit::Model::Architecture) with a given name (abbreviation)
ancestors:
metasploit/model/architecture:
search:
operator:
names:
abbreviation:
@limhoff-r7
limhoff-r7 / rubocop-msfconsole-error
Created August 12, 2014 15:48
Error when trying to use rubocop in development machines
Uncaught exception: undefined method `syck_to_yaml' for class `Object'
/Users/luke.imhoff/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/yaml.rb:65:in `yamler='
/Users/luke.imhoff/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/yaml.rb:61:in `class_eval'
/Users/luke.imhoff/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/yaml.rb:61:in `yamler='
/Users/luke.imhoff/.rvm/gems/ruby-1.9.3-p545@metasploit-framework/gems/rubocop-0.23.0/lib/rubocop/config_loader.rb:10:in `<top (required)>'
/Users/luke.imhoff/git/limhoff-r7/metasploit-framework/lib/fastlib.rb:374:in `require'
/Users/luke.imhoff/git/limhoff-r7/metasploit-framework/lib/fastlib.rb:374:in `require'
/Users/luke.imhoff/.rvm/gems/ruby-1.9.3-p545@metasploit-framework/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:251:in `block in require'
/Users/luke.imhoff/.rvm/gems/ruby-1.9.3-p545@metasploit-framework/gems/activesupport-3.2.19/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/luke.imhoff/.rvm/gems/ruby-1.9.3-p545@metasploit-framewor
@limhoff-r7
limhoff-r7 / spec_helper.rb
Created September 11, 2014 02:32
RSpec 3 Metasploit spec/spec_helper.rb template
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'GEM_NAME'
RSpec.configure do |config|
config.expose_dsl_globally = false
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
@limhoff-r7
limhoff-r7 / version_spec.rb
Created September 11, 2014 02:39
Metasploit version_spec.rb for gem skeleton
require 'spec_helper'
RSpec.describe GEM_NAME do
context 'CONSTANTS' do
context 'VERSION' do
subject(:version) {
described_class::VERSION
}
it { is_expected.to be_a String }
@limhoff-r7
limhoff-r7 / Rakefile
Created September 12, 2014 14:56
Adding metasploit-yard to gem Rakfile
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
gem_specification = Gem::Specification.find_all_by_name('metasploit-yard').first
Dir[File.join(gem_specification.gem_dir, 'lib', 'tasks', '**', '*.rake')].each do |rake|
load rake
end
@limhoff-r7
limhoff-r7 / Rakefile
Created September 12, 2014 14:59
Adding rake spec to Rakefile
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec