Path: blob/master/tools/password/vxencrypt.rb
19758 views
#!/usr/bin/env ruby12#3# This script can be used to calculate hash values for VxWorks passwords.4#56def hashit(inp)7if inp.length < 8 or inp.length > 1208raise RuntimeError, "The password must be between 8 and 120 characters"9end10sum = 011bytes = inp.unpack("C*")12bytes.each_index {|i| sum += (bytes[i] * (i + 1)) ^ (i + 1) }13hackit(sum)14end1516def hackit(sum)17magic = 3169531718res = ((sum * magic) & 0xffffffff).to_s19res.unpack("C*").map{ |c|20c += 0x21 if c < 0x3321c += 0x2f if c < 0x3722c += 0x42 if c < 0x3923c24}.pack("C*")25end2627input = ARGV.shift || "flintstone"28$stderr.puts "[*] Hash for password '#{input}' is #{hashit(input)}"293031