Add the new generic tab completion functoin
parent
d815e42ccf
commit
68a43fef36
|
@ -2198,16 +2198,7 @@ class Core
|
|||
if rh and not rh.empty?
|
||||
res << Rex::Socket.source_address(rh)
|
||||
else
|
||||
res << Rex::Socket.source_address
|
||||
# getifaddrs was introduced in 2.1.2
|
||||
if Socket.respond_to?(:getifaddrs)
|
||||
ifaddrs = Socket.getifaddrs.find_all do |ifaddr|
|
||||
((ifaddr.flags & Socket::IFF_LOOPBACK) == 0) &&
|
||||
ifaddr.addr &&
|
||||
ifaddr.addr.ip?
|
||||
end
|
||||
res += ifaddrs.map { |ifaddr| ifaddr.addr.ip_address }
|
||||
end
|
||||
res += tab_complete_source_address
|
||||
end
|
||||
else
|
||||
end
|
||||
|
|
|
@ -167,25 +167,7 @@ module Msf
|
|||
'-x' => [ :file, ],
|
||||
'-i' => [ true, ]
|
||||
}
|
||||
tab_complete_spec(fmt, str, words)
|
||||
end
|
||||
|
||||
def tab_complete_spec(fmt, str, words)
|
||||
last_word = words[-1]
|
||||
fmt = fmt.select { |key, value| last_word == key || !words.include?(key) }
|
||||
|
||||
val = fmt[last_word]
|
||||
return fmt.keys if !val # the last word does not look like a fmtspec
|
||||
arg = val[0]
|
||||
return fmt.keys if !arg # the last word is a fmtspec that takes no argument
|
||||
|
||||
tabs = []
|
||||
if arg.to_s.to_sym == :file
|
||||
tabs = tab_complete_filenames(str, words)
|
||||
elsif arg.kind_of?(Array)
|
||||
tabs = arg.map {|a| a.to_s}
|
||||
end
|
||||
tabs
|
||||
tab_complete_generic(fmt, str, words)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -248,6 +248,41 @@ module DispatcherShell
|
|||
matches
|
||||
end
|
||||
|
||||
def tab_complete_generic(fmt, str, words)
|
||||
last_word = words[-1]
|
||||
fmt = fmt.select { |key, value| last_word == key || !words.include?(key) }
|
||||
|
||||
val = fmt[last_word]
|
||||
return fmt.keys if !val # the last word does not look like a fmtspec
|
||||
arg = val[0]
|
||||
return fmt.keys if !arg # the last word is a fmtspec that takes no argument
|
||||
|
||||
tabs = []
|
||||
if arg.to_s.to_sym == :address
|
||||
tabs = tab_complete_source_addresses
|
||||
elsif arg.to_s.to_sym == :bool
|
||||
tabs = ['true', 'false']
|
||||
elsif arg.to_s.to_sym == :file
|
||||
tabs = tab_complete_filenames(str, words)
|
||||
elsif arg.kind_of?(Array)
|
||||
tabs = arg.map {|a| a.to_s}
|
||||
end
|
||||
tabs
|
||||
end
|
||||
|
||||
def tab_complete_source_address
|
||||
addresses = [Rex::Socket.source_address]
|
||||
# getifaddrs was introduced in 2.1.2
|
||||
if Socket.respond_to?(:getifaddrs)
|
||||
ifaddrs = Socket.getifaddrs.find_all do |ifaddr|
|
||||
((ifaddr.flags & Socket::IFF_LOOPBACK) == 0) &&
|
||||
ifaddr.addr &&
|
||||
ifaddr.addr.ip?
|
||||
end
|
||||
addresses += ifaddrs.map { |ifaddr| ifaddr.addr.ip_address }
|
||||
end
|
||||
addresses
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue