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.
390 391 392 393 394 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 390 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
396 397 398 399 400 401 402 403 404 405 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 396 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.
389 390 391 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 389 def entries @entries end |
#name ⇒ Object
Returns the value of attribute name.
389 390 391 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 389 def name @name end |
#sections ⇒ Object
Returns the value of attribute sections.
389 390 391 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 389 def sections @sections end |
Instance Method Details
#get_directive(type) ⇒ Object
415 416 417 418 419 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 415 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
425 426 427 428 429 430 431 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 425 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
407 408 409 410 411 412 413 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 407 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
421 422 423 |
# File 'lib/msf/core/payload/malleable_c2.rb', line 421 def has_directive(type) @entries.any? {|d| d.kind_of?(ParsedDirective) && d.type == type.downcase} end |