Module: Msf::Auxiliary::MimeTypes

Defined in:
lib/msf/core/auxiliary/mime_types.rb

Instance Method Summary collapse

Instance Method Details

#mime_load_extension_mapObject


25
26
27
28
# File 'lib/msf/core/auxiliary/mime_types.rb', line 25

def mime_load_extension_map
  path = File.join( Msf::Config.data_directory, "mime.yml")
  @extension_map = YAML.load_file(path)
end

#mime_lookup_by_extension(extension) ⇒ Object


8
9
10
11
12
13
14
15
16
17
# File 'lib/msf/core/auxiliary/mime_types.rb', line 8

def mime_lookup_by_extension(extension)
  return 'application/octet-stream' if extension.nil? or extension.empty?
  if extension.starts_with? '.'
    extension.gsub!('.','')
  end
  mtype = Mime::Type.lookup_by_extension(extension)
  mtype = mime_yaml_lookup(extension) if mtype.nil?
  mtype = "application/#{extension}" if mtype.nil?
  return mtype
end

#mime_yaml_lookup(extension) ⇒ Object


19
20
21
22
23
# File 'lib/msf/core/auxiliary/mime_types.rb', line 19

def mime_yaml_lookup(extension)
  mime_load_extension_map unless @extension_map
  return @extension_map[extension] if @extension_map[extension]
  return nil
end