Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/tools/exploit/pattern_create.rb
Views: 11768
#!/usr/bin/env ruby12##3# This module requires Metasploit: https://metasploit.com/download4# Current source: https://github.com/rapid7/metasploit-framework5##6begin7msfbase = __FILE__8while File.symlink?(msfbase)9msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))10end1112$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))13$LOAD_PATH.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']1415gem 'rex-text'1617require 'optparse'1819module PatternCreate20class OptsConsole21def self.parse(args)22options = {}23parser = OptionParser.new do |opt|24opt.banner = "Usage: #{__FILE__} [options]\nExample: #{__FILE__} -l 50 -s ABC,def,123\nAd1Ad2Ad3Ae1Ae2Ae3Af1Af2Af3Bd1Bd2Bd3Be1Be2Be3Bf1Bf"25opt.separator ''26opt.separator 'Options:'27opt.on('-l', '--length <length>', Integer, "The length of the pattern") do |len|28options[:length] = len29end3031opt.on('-s', '--sets <ABC,def,123>', Array, "Custom Pattern Sets") do |sets|32options[:sets] = sets33end3435opt.on_tail('-h', '--help', 'Show this message') do36$stdout.puts opt37exit38end39end4041parser.parse!(args)4243if options.empty?44raise OptionParser::MissingArgument, 'No options set, try -h for usage'45elsif options[:length].nil? && options[:sets]46raise OptionParser::MissingArgument, '-l <length> is required'47end4849options[:sets] = nil unless options[:sets]5051options52end53end5455class Driver56def initialize57begin58@opts = OptsConsole.parse(ARGV)59rescue OptionParser::ParseError => e60$stderr.puts "[x] #{e.message}"61exit62end63end6465def run66require 'rex/text'6768puts Rex::Text.pattern_create(@opts[:length], @opts[:sets])69end70end71end7273if __FILE__ == $PROGRAM_NAME74driver = PatternCreate::Driver.new75begin76driver.run77rescue ::StandardError => e78$stderr.puts "[x] #{e.class}: #{e.message}"79$stderr.puts "[*] If necessary, please refer to framework.log for more details."80end81end82rescue SignalException => e83puts("Aborted! #{e}")84end858687