Class: Msf::Payload::MalleableC2::ParsedSection
- Inherits:
-
Object
- Object
- Msf::Payload::MalleableC2::ParsedSection
- Defined in:
- lib/msf/core/payload/malleable_c2.rb
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#name ⇒ Object
Returns the value of attribute name.
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
- #get_directive(type) ⇒ Object
- #get_section(name) ⇒ Object
- #get_set(key) ⇒ Object
- #has_directive(type) ⇒ Object
-
#initialize(name) ⇒ ParsedSection
constructor
A new instance of ParsedSection.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(name) ⇒ ParsedSection
Returns a new instance of ParsedSection.
395 396 397 398 399 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 395 def initialize(name) @name = name.downcase @entries = [] @sections = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
401 402 403 404 405 406 407 408 409 410 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 401 def method_missing(name, *args) name = name.to_s.gsub('_', '-') section = get_section(name) return section if section directive = get_directive(name) return directive if directive.any? get_set(name) end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
394 395 396 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 394 def entries @entries end |
#name ⇒ Object
Returns the value of attribute name.
394 395 396 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 394 def name @name end |
#sections ⇒ Object
Returns the value of attribute sections.
394 395 396 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 394 def sections @sections end |
Instance Method Details
#get_directive(type) ⇒ Object
420 421 422 423 424 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 420 def get_directive(type) # there can be multiple instances of the same directive type so we have # to return an array instead of a single instance @entries.find_all {|d| d.kind_of?(ParsedDirective) && d.type == type.downcase} end |
#get_section(name) ⇒ Object
430 431 432 433 434 435 436 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 430 def get_section(name) sec = @sections.find {|s| s.name == name.downcase} if block_given? && !sec.nil? yield(sec) end sec end |
#get_set(key) ⇒ Object
412 413 414 415 416 417 418 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 412 def get_set(key) val = @entries.find {|s| s.kind_of?(ParsedSet) && s.key == key.downcase}&.value if block_given? && !val.nil? yield(val) end val end |
#has_directive(type) ⇒ Object
426 427 428 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 426 def has_directive(type) @entries.any? {|d| d.kind_of?(ParsedDirective) && d.type == type.downcase} end |