Class: Forze_brute
- Inherits:
-
Object
- Object
- Forze_brute
- Defined in:
- lib/cobreak/force.rb
Instance Attribute Summary collapse
-
#charact ⇒ Object
Returns the value of attribute charact.
-
#crack ⇒ Object
Returns the value of attribute crack.
-
#crypt ⇒ Object
Returns the value of attribute crypt.
-
#hash_input ⇒ Object
Returns the value of attribute hash_input.
-
#max_chr ⇒ Object
Returns the value of attribute max_chr.
-
#min_chr ⇒ Object
Returns the value of attribute min_chr.
-
#out ⇒ Object
Returns the value of attribute out.
-
#result ⇒ Object
Returns the value of attribute result.
-
#type_hash ⇒ Object
Returns the value of attribute type_hash.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#word(dato, wordlist, type, out, verbose = false) ⇒ Object
Returns the value of attribute word.
-
#wordlist ⇒ Object
Returns the value of attribute wordlist.
Instance Method Summary collapse
- #chars(dato, range, char, type, out, verbose = false) ⇒ Object
-
#initialize(author = 'BreakerTW') ⇒ Forze_brute
constructor
A new instance of Forze_brute.
- #verify(dato, word = File.join(Gem.path[1], "gems", "cobreak-#{CoBreak.version}", 'lib', 'cobreak', 'hash', 'hash.db')) ⇒ Object
Constructor Details
#initialize(author = 'BreakerTW') ⇒ Forze_brute
Returns a new instance of Forze_brute.
5 6 7 8 9 10 11 12 |
# File 'lib/cobreak/force.rb', line 5 def initialize( = 'BreakerTW') @author = @result = nil @crack = nil @crypt = nil @dict = nil @word = nil end |
Instance Attribute Details
#charact ⇒ Object
Returns the value of attribute charact.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def charact @charact end |
#crack ⇒ Object
Returns the value of attribute crack.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def crack @crack end |
#crypt ⇒ Object
Returns the value of attribute crypt.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def crypt @crypt end |
#hash_input ⇒ Object
Returns the value of attribute hash_input.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def hash_input @hash_input end |
#max_chr ⇒ Object
Returns the value of attribute max_chr.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def max_chr @max_chr end |
#min_chr ⇒ Object
Returns the value of attribute min_chr.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def min_chr @min_chr end |
#out ⇒ Object
Returns the value of attribute out.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def out @out end |
#result ⇒ Object
Returns the value of attribute result.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def result @result end |
#type_hash ⇒ Object
Returns the value of attribute type_hash.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def type_hash @type_hash end |
#verbose ⇒ Object
Returns the value of attribute verbose.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def verbose @verbose end |
#word(dato, wordlist, type, out, verbose = false) ⇒ Object
Returns the value of attribute word.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def word @word end |
#wordlist ⇒ Object
Returns the value of attribute wordlist.
4 5 6 |
# File 'lib/cobreak/force.rb', line 4 def wordlist @wordlist end |
Instance Method Details
#chars(dato, range, char, type, out, verbose = false) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/cobreak/force.rb', line 142 def chars(dato, range, char, type, out, verbose = false) begin raise Errno::EACCES, "\e[1;31m[\e[1;37m✘\e[1;31m]\e[1;37m root privileges needed" if `whoami`.chomp != "root" rescue Errno::EACCES => e puts e. exit end bool = File.open(File.join(Gem.path[1], "gems","cobreak-#{CoBreak.version}" , "lib", "cobreak", "config", "database.db")) bool = bool.readlines[0].to_s.chomp if (bool.eql?('true')) verify(dato) end forzechars = OpenStruct.new forzechars.dato = dato forzechars.range = range forzechars.char = char.chars forzechars.type = type forzechars.out = out forzechars.verbose = verbose forzechars.cont = Array.new forzechars.result = nil if (forzechars.type.downcase.eql?('md4')) forzechars.crypt = OpenSSL::Digest::MD4.new elsif (forzechars.type.downcase.eql?('md5')) forzechars.crypt = OpenSSL::Digest::MD5.new elsif (forzechars.type.downcase.eql?('sha1')) forzechars.crypt = OpenSSL::Digest::SHA1.new elsif (forzechars.type.downcase.eql?('sha224')) forzechars.crypt = OpenSSL::Digest::SHA224.new elsif (forzechars.type.downcase.eql?('sha256')) forzechars.crypt = OpenSSL::Digest::SHA256.new elsif (forzechars.type.downcase.eql?('sha384')) forzechars.crypt = OpenSSL::Digest::SHA384.new elsif (forzechars.type.downcase.eql?('sha512')) forzechars.crypt = OpenSSL::Digest::SHA512.new elsif (forzechars.type.downcase.eql?('ripemd160')) forzechars.crypt = OpenSSL::Digest::RIPEMD160.new end lin = 0 begin forzechars.time = Time.now for range in (forzechars.range[0].to_i..forzechars.range[1].to_i).to_a for chars in forzechars.char.repeated_permutation(range).map(&:join) lin += 1 if (forzechars.verbose.eql?(true)) print "\r\e[1;32m[\e[1;37m+\e[1;32m]\e[1;37m Password Crack: #{chars}" end if (forzechars.crypt.hexdigest(chars).eql?(forzechars.dato)) forzechars.result = chars puts "\e[1;32m[\e[1;37m+\e[1;32m]\e[1;37m Password Crack: #{chars}" puts "\e[1;32m[\e[1;37m+\e[1;32m]\e[1;37m Number of Lines: #{lin}" puts "\e[1;32m[\e[1;37m+\e[1;32m]\e[1;37m Hash Cracking in #{Time.now - forzechars.time} seconds" if bool.eql?('true') forzechars.type = forzechars.type.downcase $datBas::database(forzechars.crypt.hexdigest(chars)) DB::database(chars, File.join(Gem.path[1], "gems", "cobreak-#{CoBreak.version}", 'lib', 'cobreak', 'show', "#{forzechars.type}.db")) end if !(forzechars.out.nil?) File.open(forzechars.out, mode: 'a'){|out| out.puts "==================================================" out.puts "software: CoBreak #{CoBreak.version}" out.puts "Type Hash: #{forzechars.type}\n" out.puts "#{chars}:#{forzechars.crypt.hexdigest(chars)}" out.puts "==================================================" } end return 0 end end end rescue Interrupt puts "\n\e[1;31m[\e[1;37m+\e[1;31m]\e[1;37m Interrupt mode" puts "\e[1;31m[\e[1;37m+\e[1;31m]\e[1;37m Password Not Cracked" puts "\e[1;31m[\e[1;37m+\e[1;31m]\e[1;37m Number of Lines: #{lin}" puts "\e[1;31m[\e[1;37m+\e[1;31m]\e[1;37m Wait Time: #{Time.now - forzechars.time} seconds\e[0m" exit end if (forzechars.result.nil?) puts "\e[1;31m[\e[1;37m+\e[1;31m]\e[1;37m Not Cracking Text: #{forzechars.dato}" puts "\e[1;31m[\e[1;37m+\e[1;31m]\e[1;37m Time: #{Time.now - forzechars.time}\e[0m" exit end end |
#verify(dato, word = File.join(Gem.path[1], "gems", "cobreak-#{CoBreak.version}", 'lib', 'cobreak', 'hash', 'hash.db')) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cobreak/force.rb', line 13 def verify(dato, word = File.join(Gem.path[1], "gems", "cobreak-#{CoBreak.version}", 'lib', 'cobreak', 'hash', 'hash.db')) hash_db = Sequel.sqlite hash_db.create_table? :datahash do String :ori String :hash end begin IO.foreach(word) {|lin| lin = lin.chomp hash_db[:datahash] << {ori:lin, hash:dato} } rescue Errno::ENOENT return end ha = hash_db[:datahash].filter(ori:dato).map(:hash) arr = Array.new arr << dato if (ha == arr) puts "\e[1;32m[\e[1;37m+\e[1;32m]\e[1;37m Hash already existing in the database: #{dato}" puts "\e[1;32m[\e[1;37m+\e[1;32m]\e[1;37m show the hash using --show, see the help parameter for more information\e[0m" exit end end |