Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mime_types.rb 806B

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: binary -*-
  2. require 'action_dispatch/http/mime_type'
  3. module Msf
  4. module Auxiliary::MimeTypes
  5. def mime_lookup_by_extension(extension)
  6. return 'application/octet-stream' if extension.nil? or extension.empty?
  7. if extension.starts_with? '.'
  8. extension.gsub!('.','')
  9. end
  10. mtype = Mime::Type.lookup_by_extension(extension)
  11. mtype = mime_yaml_lookup(extension) if mtype.nil?
  12. mtype = "application/#{extension}" if mtype.nil?
  13. return mtype
  14. end
  15. def mime_yaml_lookup(extension)
  16. mime_load_extension_map unless @extension_map
  17. return @extension_map[extension] if @extension_map[extension]
  18. return nil
  19. end
  20. def mime_load_extension_map
  21. path = File.join( Msf::Config.data_directory, "mime.yml")
  22. @extension_map = YAML.load_file(path)
  23. end
  24. end
  25. end