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.

opt_string.rb 593B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: binary -*-
  2. module Msf
  3. ###
  4. #
  5. # Mult-byte character string option.
  6. #
  7. ###
  8. class OptString < OptBase
  9. def type
  10. return 'string'
  11. end
  12. def validate_on_assignment?
  13. false
  14. end
  15. def normalize(value)
  16. if (value.to_s =~ /^file:(.*)/)
  17. path = $1
  18. begin
  19. value = File.read(path)
  20. rescue ::Errno::ENOENT, ::Errno::EISDIR
  21. value = nil
  22. end
  23. end
  24. value
  25. end
  26. def valid?(value=self.value, check_empty: true)
  27. value = normalize(value)
  28. return false if check_empty && empty_required_value?(value)
  29. return super
  30. end
  31. end
  32. end