This did not seem to interest anyone on LNO, so since you guys are much more friendly, you will probably have something to say.
Python:
Code:
#!/usr/bin/env python
import sys, crypt
if len(sys.argv) < 3:
print "Usage: %s <encrypted string> <dict file>" % sys.argv[0]
sys.exit(1)
secret = sys.argv[1]
saltstring = secret[:2]
f = open(sys.argv[2])
guess = None
word = None
while word != "":
word = f.readline()
guess = crypt.crypt(word, saltstring)
if guess == secret:
print "The password is:", word
sys.exit(0)
print "Could not find password in file", sys.argv[2]
Ruby:
Code:
#!/usr/bin/env ruby
if ARGV.size < 2
puts "Usage: #{$0} <crypted string> <dict file>"
exit 1
end
secret = ARGV[0]
saltstring = secret[0,2]
f = File.open(ARGV[1])
f.each_line do |x|
if x.crypt(saltstring) == secret
puts "The password is: #{x}"
exit
end
end
puts "No password found in #{ARGV[1]}"
This is a very basic implementation. I am planning to implement things like playing with the case of the word.
Hint: These two programs could prove to be extremely useful if you are taking part of the www.hackerslab.org contest.
Bookmarks