Skip to content

Instantly share code, notes, and snippets.

@dwendt
Created May 22, 2017 19:03
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 dwendt/994485bb377652df1b2eaf022b450da2 to your computer and use it in GitHub Desktop.
Save dwendt/994485bb377652df1b2eaf022b450da2 to your computer and use it in GitHub Desktop.
require 'openssl'
require 'base64'
require 'rexml/document'
include REXML
# pull this from seed.properties
SEED = 'EB3452127614E25A'
def decrypt(cpass)
blockSize = 16;
rawBinary = Base64.decode64(cpass);
# IV is always the first block
ivBytes = rawBinary[0...blockSize]#arraySlice(rawBinary, 1, blockSize);
# Remaining bytes are the encrypted value
dataBytes = rawBinary[blockSize..-1]#arraySlice(rawBinary, blockSize+1, arrayLen(rawBinary)-blockSize);
des = OpenSSL::Cipher.new('AES-128-CBC')
des.decrypt
des.key = SEED
des.iv = ivBytes
return des.update(dataBytes) + des.final
end
entries = []
bld = []
swap = false
doc = Document.new(IO.read("/opt/metasploit-framework/neo-datasource.xml"))
XPath.each(doc, "//var/struct/var[@name='url' or @name='password']/string") do |node|
node = "#{node}"
node.gsub!('<string>','')
node.gsub!('<string/>','')
node.gsub!('</string>','')
if swap
if node == "" then node = "NONE" end
#puts "pwd: #{node}"
bld << node
entries << bld
bld = []
else
#puts "url: #{node}"
bld << node
end
swap = !swap
end
entries.each do |url,pw|
if pw != 'NONE'
decrypted = decrypt(pw)
puts url
puts "#{decrypted}"
else
puts "no password: #{url}"
end
puts "========"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment