Skip to content

Instantly share code, notes, and snippets.

@picatz
Last active April 16, 2017 03:53
Show Gist options
  • Save picatz/94b0fd08a29a4526bcf7855fe77c8be3 to your computer and use it in GitHub Desktop.
Save picatz/94b0fd08a29a4526bcf7855fe77c8be3 to your computer and use it in GitHub Desktop.
Violent Ruby: Basic Unix Password Cracker
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
def test_pass(crypt_pass)
salt = crypt_pass[0, 2]
File.foreach('dictionary.txt').map(&:strip).each do |word|
return puts '[+] Found Password: ' + word if word.crypt(salt) == crypt_pass
end
puts '[-] Password Not Found'
end
File.foreach('passwords.txt').map(&:strip).each do |line|
next unless line.include?(':')
user = line.split(':')[0]
crypt_pass = line.split(':')[1].strip
puts '[*] Cracking Password For: ' + user
test_pass(crypt_pass)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment