require 'optparse' require 'cobreak/cobreak' require 'cobreak/force_brute' require 'cobreak/version' require 'cobreak/list_all' module CoBreak class ParseOPT def self.optparse(options) begin OptionParser.new do|param| param.banner = "Usage: CoBreak.rb [--options] [text or file]" param.separator '' param.separator "Mode Cipher:" param.on('--encoding=[TYPE]', String, 'encoding parameter'){|en_co| options.enc = en_co} param.on('--decoding=[TYPE]', String, 'decoding parameter'){|de_co| options.dec = de_co} param.separator "Mode Cryptography" param.on('--encrypt=[FORMAT]', String, 'encrypt parameter'){|en_en| options.encrypt = en_en} param.on('--decrypt=[FORMAT]', String, 'decrypt parameter'){|de_en| options.decrypt = de_en} param.separator "Mode BruteForce" param.on('--bruteforce=[FORMAT]', String, 'brute force mode to crack a hash'){|modeforce| options.bruteforce = modeforce} param.separator "" param.separator "Options:" param.on('-l', '--list=TYPE or FORMAT', String, 'list cipher types of hash formats'){|lin| options.list = lin} param.on('-r', '--range MIN MAX', Integer, "word chars length"){|min| options.min = min} param.on('-c', '--chars CHARACTERS', 'character input to generate word lists'){|chars| options.chars = chars} param.on('-w', '--wordlist=WORDLIST', 'Wordlist mode, read words from FILE or stadin (default: diccionario.txt)'){|wordlist| options.wordlist = wordlist} param.on('-i', '--input FILE or TEXT', String, 'take file or text to carry out the process'){|alg| options.algo = alg} param.on_tail('-v', '--version', 'show version'){puts "CoBreak version #{CoBreak.version}"; exit} param.on_tail('-h', '--help', 'command to view help parameters'){puts param; exit} param.separator '' end.parse! rescue OptionParser::MissingArgument => missing if missing.to_s.include?("--wordlist") options.wordlist = File.join(Gem.path[1], 'gems', "cobreak-#{CoBreak.version}", 'diccionario.txt') elsif missing.to_s.include?("--chars") options.chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" else puts missing.message end ensure if (options.wordlist == "diccionario.txt") unless (File.exists?(options.wordlist)) options.wordlist = File.join(Gem.path[1], 'gems', "cobreak-#{CoBreak.version}", 'diccionario.txt') end end end CoBreak::Box.var(options) CoBreak::Box::Cipher.coding() CoBreak::Box::Cryptgraphy.crypt() CoBreak::List.new(options) unless (options.wordlist.nil?) or (options.wordlist.empty?) bruteforce = CoBreak::BruteForze.new(options) bruteforce.banner_wordlist() bruteforce.wordlist end end end end