Skip to content

Commit

Permalink
Support -1 in the --session argument
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroSteiner committed Feb 9, 2024
1 parent 1b2a2af commit 99b2bfe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/msf/ui/console/command_dispatcher/dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,12 @@ def add_dns(*args)
comm_obj = nil

unless comm.nil?
raise ::ArgumentError.new("Not a valid number: #{comm}") unless comm =~ /^\d+$/
comm_int = comm.to_i
raise ::ArgumentError.new("Session does not exist: #{comm}") unless driver.framework.sessions.include?(comm_int)
comm_obj = driver.framework.sessions[comm_int]
raise ::ArgumentError.new("Not a valid session: #{comm}") unless comm =~ /\A-?[0-9]+\Z/

comm_obj = driver.framework.sessions.get(comm.to_i)
raise ::ArgumentError.new("Session does not exist: #{comm}") unless comm_obj
raise ::ArgumentError.new("Socket Comm (Session #{comm}) does not implement Rex::Socket::Comm") unless comm_obj.is_a? ::Rex::Socket::Comm

if resolvers.any? { |resolver| SPECIAL_RESOLVERS.include?(resolver.downcase) }
print_warning("The session argument will be ignored for the system resolver")
end
Expand Down

0 comments on commit 99b2bfe

Please sign in to comment.