Skip to content

Commit 3808eeb

Browse files
author
Brent Cook
committed
Land rapid7#7704, Update jobs output to show TCP listener information
2 parents d9be9f3 + 505cc19 commit 3808eeb

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

lib/msf/base/serializer/readable_text.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ def self.dump_jobs(framework, verbose = false, indent = DefaultIndent, col = Def
674674
row[1] = framework.jobs[job_id].name
675675

676676
pinst = exploit_mod.respond_to?(:payload_instance) ? exploit_mod.payload_instance : nil
677+
payload_uri = ''
677678

678679
if pinst.nil?
679680
row[2] = ""
@@ -682,7 +683,8 @@ def self.dump_jobs(framework, verbose = false, indent = DefaultIndent, col = Def
682683
row[2] = pinst.refname
683684
row[3] = ""
684685
if pinst.respond_to?(:payload_uri)
685-
row[3] << pinst.payload_uri
686+
payload_uri = pinst.payload_uri.strip
687+
row[3] << payload_uri
686688
end
687689
if pinst.respond_to?(:luri)
688690
row[3] << pinst.luri
@@ -694,7 +696,12 @@ def self.dump_jobs(framework, verbose = false, indent = DefaultIndent, col = Def
694696
uripath ||= exploit_mod.datastore['URIPATH']
695697
row[4] = uripath
696698
row[5] = framework.jobs[job_id].start_time
697-
row[6] = pinst.respond_to?(:listener_uri) ? pinst.listener_uri : ""
699+
row[6] = ''
700+
701+
if pinst.respond_to?(:listener_uri)
702+
listener_uri = pinst.listener_uri.strip
703+
row[6] = listener_uri unless listener_uri == payload_uri
704+
end
698705
end
699706
tbl << row
700707
end

lib/msf/core/handler/reverse_tcp.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,24 @@ def human_name
7777
"reverse TCP"
7878
end
7979

80+
# A URI describing what the payload is configured to use for transport
8081
def payload_uri
81-
"tcp://#{datastore['LHOST']}:#{datastore['LPORT']}"
82+
addr = datastore['LHOST']
83+
uri_host = Rex::Socket.is_ipv6?(addr) ? "[#{addr}]" : addr
84+
"tcp://#{uri_host}:#{datastore['LPORT']}"
8285
end
8386

87+
# A URI describing where we are listening
88+
#
89+
# @param addr [String] the address that
90+
# @return [String] A URI of the form +scheme://host:port/+
91+
def listener_uri(addr=datastore['ReverseListenerBindAddress'])
92+
addr = datastore['LHOST'] if addr.nil? || addr.empty?
93+
uri_host = Rex::Socket.is_ipv6?(addr) ? "[#{addr}]" : addr
94+
"tcp://#{uri_host}:#{bind_port}"
95+
end
96+
97+
8498
#
8599
# Starts monitoring for an inbound connection.
86100
#

0 commit comments

Comments
 (0)