Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'privileged' search #19120

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/msf/core/modules/metadata/obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class Obj
attr_reader :adapter_refname
# @return [String, nil] Name of the adapted payload if applicable
attr_reader :adapted_refname
# @return [Boolean] Whether or not we are privileged
attr_reader :privileged
# @return [Boolean] Whether or not the payload is staged
attr_reader :staged
# @return [String, nil] Name of the stage if applicable
Expand Down Expand Up @@ -136,6 +138,9 @@ def initialize(module_instance, obj_hash = nil)

@session_types = module_instance.respond_to?(:session_types) && module_instance.session_types

if module_instance.respond_to(:privileged)
nrathaus marked this conversation as resolved.
Show resolved Hide resolved
@privileged = module_instance.privileged
end
if module_instance.respond_to?(:payload_type)
@payload_type = module_instance.payload_type
@staged = module_instance.staged?
Expand Down Expand Up @@ -183,6 +188,7 @@ def to_json(*args)
'notes' => @notes,
'session_types' => @session_types,
'needs_cleanup' => @needs_cleanup,
'privileged' => @privileged,
}

data['actions'] = @actions if @actions
Expand Down Expand Up @@ -260,6 +266,7 @@ def init_from_hash(obj_hash)
@staged = obj_hash['staged']
@stage_refname = obj_hash['stage_refname']
@stager_refname = obj_hash['stager_refname']
@privileged = obj_hash['privileged']
end

def sort_platform_string
Expand Down
3 changes: 3 additions & 0 deletions lib/msf/core/modules/metadata/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ def is_match(params, module_metadata)
match = [keyword, search_term] if module_metadata.session_types && module_metadata.session_types.any? { |session_type| session_type =~ regex }
when 'port', 'rport'
match = [keyword, search_term] if module_metadata.rport.to_s =~ regex
when 'privileged'
# if it 'nil' it means the module don't have privileged property set
nrathaus marked this conversation as resolved.
Show resolved Hide resolved
match = [keyword, search_term] if module_metadata.privileged.nil? || module_metadata.privileged == search_term
when 'rank'
# Determine if param was prepended with gt, lt, gte, lte, or eq
# Ex: "lte300" should match all ranks <= 300
Expand Down
1 change: 1 addition & 0 deletions lib/msf/ui/console/command_dispatcher/modules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ def cmd_search_help
'target' => 'Modules affecting this target',
'type' => 'Modules of a specific type (exploit, payload, auxiliary, encoder, evasion, post, or nop)',
'action' => 'Modules with a matching action name or description',
'privileged' => 'Modules with a matching "privileged" value set'
}.each_pair do |keyword, description|
print_line " #{keyword.ljust 17}: #{description}"
end
Expand Down
Loading