Skip to content

Instantly share code, notes, and snippets.

@mubix
Created November 4, 2014 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mubix/5e3de0abb3e7e2cf8f3b to your computer and use it in GitHub Desktop.
Save mubix/5e3de0abb3e7e2cf8f3b to your computer and use it in GitHub Desktop.
7zip Cracking on the cheap
#!/usr/bin/env ruby
# Need some help with this cracking script.
# Problems:
# 1) Slow, going through a large list like Rockyou takes forever
# 2) If there is no header encryption, 7z extracts to the target location
# then tries to decrypt, so threading would be painful
# 3) I need to know when the correct password is used and due to #2
# with threading that would be very difficult.
require 'shellwords'
wordlist = File.open('/usr/share/wordlists/rockyou.txt','r')
wordlist.each_line do |line|
puts "Testing #{line.strip.inspect}"
result = %x[7z e -p#{Shellwords.escape(line.chomp!)} -w/tmp/zip/temp/ -o/tmp/zip/ -y Secret.7z]
if result =~ /CRC\ Failed/
puts result
elsif result =~ /Wrong\ password/
puts result
else
puts "Success with #{line}"
exit
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment