From 05d8f9d1865ee7ad3f14512cd293432e31bb0673 Mon Sep 17 00:00:00 2001 From: James Lee Date: Mon, 4 Jan 2016 15:58:03 -0600 Subject: [PATCH 1/2] Make sure addr is not nil See http://ruby-doc.org/stdlib-2.2.2/libdoc/socket/rdoc/Socket/Ifaddr.html#method-i-addr Which says: Returns the address of *ifaddr*. nil is returned if address is not available in *ifaddr*. I ran into this with a teql interface, but who knows what else might trigger it. --- lib/msf/ui/console/command_dispatcher/core.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index 226714153b..57e6b3cd17 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -3090,7 +3090,9 @@ class Core # 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.ip? + ((ifaddr.flags & Socket::IFF_LOOPBACK) == 0) && + ifaddr.addr && + ifaddr.addr.ip? end res += ifaddrs.map { |ifaddr| ifaddr.addr.ip_address } end From 2dd59a932bfb57c39886a15e09f19b42a643db88 Mon Sep 17 00:00:00 2001 From: James Lee Date: Mon, 4 Jan 2016 16:02:43 -0600 Subject: [PATCH 2/2] Clean up some warnings --- lib/msf/ui/console/command_dispatcher/core.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index 57e6b3cd17..c76bd76923 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -1169,7 +1169,7 @@ class Core output += "\n" end - print(output +"\n") + print(output + "\n") else print_line("Invalid Thread ID") end @@ -1251,7 +1251,7 @@ class Core print_status("Successfully loaded plugin: #{inst.name}") end rescue ::Exception => e - elog("Error loading plugin #{path}: #{e}\n\n#{e.backtrace.join("\n")}", src = 'core', level = 0, from = caller) + elog("Error loading plugin #{path}: #{e}\n\n#{e.backtrace.join("\n")}", 'core', 0, caller) print_error("Failed to load plugin from #{path}: #{e}") end end @@ -2222,7 +2222,7 @@ class Core end mod.options.sorted.each { |e| - name, opt = e + name, _opt = e res << name } @@ -2244,7 +2244,7 @@ class Core p = framework.payloads.create(mod.datastore['PAYLOAD']) if (p) p.options.sorted.each { |e| - name, opt = e + name, _opt = e res << name } end @@ -2454,7 +2454,7 @@ class Core return tabs end - def cmd_get_help + def cmd_get_help print_line "Usage: get var1 [var2 ...]" print_line print_line "The get command is used to get the value of one or more variables."