From 505cc19662347c7eaf7403ec6d9a4caf6d0dfda3 Mon Sep 17 00:00:00 2001 From: OJ Date: Mon, 12 Dec 2016 15:56:26 +1000 Subject: [PATCH] Update reverse_tcp to show TCP listener information Also update the readable text to only output the listener information if it differs from the payload information. --- lib/msf/base/serializer/readable_text.rb | 11 +++++++++-- lib/msf/core/handler/reverse_tcp.rb | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/msf/base/serializer/readable_text.rb b/lib/msf/base/serializer/readable_text.rb index df9ef09953..b3a5df837b 100644 --- a/lib/msf/base/serializer/readable_text.rb +++ b/lib/msf/base/serializer/readable_text.rb @@ -674,6 +674,7 @@ class ReadableText row[1] = framework.jobs[job_id].name pinst = exploit_mod.respond_to?(:payload_instance) ? exploit_mod.payload_instance : nil + payload_uri = '' if pinst.nil? row[2] = "" @@ -682,7 +683,8 @@ class ReadableText row[2] = pinst.refname row[3] = "" if pinst.respond_to?(:payload_uri) - row[3] << pinst.payload_uri + payload_uri = pinst.payload_uri.strip + row[3] << payload_uri end if pinst.respond_to?(:luri) row[3] << pinst.luri @@ -694,7 +696,12 @@ class ReadableText uripath ||= exploit_mod.datastore['URIPATH'] row[4] = uripath row[5] = framework.jobs[job_id].start_time - row[6] = pinst.respond_to?(:listener_uri) ? pinst.listener_uri : "" + row[6] = '' + + if pinst.respond_to?(:listener_uri) + listener_uri = pinst.listener_uri.strip + row[6] = listener_uri unless listener_uri == payload_uri + end end tbl << row end diff --git a/lib/msf/core/handler/reverse_tcp.rb b/lib/msf/core/handler/reverse_tcp.rb index ce37dc2845..cffc92b7b3 100644 --- a/lib/msf/core/handler/reverse_tcp.rb +++ b/lib/msf/core/handler/reverse_tcp.rb @@ -77,10 +77,24 @@ module ReverseTcp "reverse TCP" end + # A URI describing what the payload is configured to use for transport def payload_uri - "tcp://#{datastore['LHOST']}:#{datastore['LPORT']}" + addr = datastore['LHOST'] + uri_host = Rex::Socket.is_ipv6?(addr) ? "[#{addr}]" : addr + "tcp://#{uri_host}:#{datastore['LPORT']}" end + # A URI describing where we are listening + # + # @param addr [String] the address that + # @return [String] A URI of the form +scheme://host:port/+ + def listener_uri(addr=datastore['ReverseListenerBindAddress']) + addr = datastore['LHOST'] if addr.nil? || addr.empty? + uri_host = Rex::Socket.is_ipv6?(addr) ? "[#{addr}]" : addr + "tcp://#{uri_host}:#{bind_port}" + end + + # # Starts monitoring for an inbound connection. #