vxdigger.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env ruby
  2. #
  3. # This script scans a memory dump or firmware image for any password hashes that
  4. # happen to match the "master password" list generated by vxmaster. This is a
  5. # simple way to determine whether a device has a hardcoded password.
  6. #
  7. # (C) 2010 Rapid7
  8. #
  9. def usage
  10. $stderr.puts "usage: #{$0} [dump-file] <master password list>"
  11. exit
  12. end
  13. # Force binary encoding for Ruby versions that support it
  14. if(Object.const_defined?('Encoding') and ::Encoding.respond_to?('default_external='))
  15. ::Encoding.default_external = ::Encoding.default_internal = "binary"
  16. end
  17. dump = ARGV.shift || usage()
  18. list = ARGV.shift || File.join(File.dirname(__FILE__), "..", "data", "wordlists", "vxworks_collide_20.txt")
  19. $stderr.puts "[*] Loading master password list..."
  20. ohashes = []
  21. hashes = []
  22. File.read(list).split("\n").each do |x|
  23. xid,enc,raw = x.split("|", 3)
  24. xid = xid.to_i
  25. next if raw =~ /invalid/
  26. raw,tmp = raw.split("\x00")
  27. ohashes << [xid, enc, raw]
  28. end
  29. $stderr.puts "[*] Loading memory dump..."
  30. data = File.read(dump)
  31. $stderr.puts "[*] Digging through memory dump..."
  32. hashes = ohashes
  33. tot = hashes.length
  34. cur = 0
  35. hashes.each do |r|
  36. x,k,h = r
  37. cur += 1
  38. pct = cur/tot.to_f
  39. pct = (pct * 100).to_i
  40. $stdout.write(" \r[*] Progress: #{pct}% (#{cur}/#{tot})")
  41. $stdout.flush
  42. next if not data.index(k)
  43. $stdout.write("\n")
  44. $stdout.flush
  45. puts "[+]"
  46. puts "[+] Password hash '#{k}' (##{x}) can be accessed with #{h.unpack("C*").map{|i| "\\x%.2x" % i}} [ '#{h}' ]"
  47. puts "[+]"
  48. end