Skip to content

Commit b27c9b9

Browse files
committed
Land rapid7#4838, reverse_http{,s} listening service fix
2 parents 7ab86be + c5d36ec commit b27c9b9

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

lib/msf/core/handler/reverse_http.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -157,26 +157,15 @@ def setup_handler
157157
print_status("Started #{scheme.upcase} reverse handler on #{listener_uri}")
158158
end
159159

160-
#
161-
# Simply calls stop handler to ensure that things are cool.
162-
#
163-
def cleanup_handler
164-
stop_handler
165-
end
166-
167-
#
168-
# Basically does nothing. The service is already started and listening
169-
# during set up.
170-
#
171-
def start_handler
172-
end
173-
174160
#
175161
# Removes the / handler, possibly stopping the service if no sessions are
176162
# active on sub-urls.
177163
#
178164
def stop_handler
179-
self.service.remove_resource("/") if self.service
165+
if self.service
166+
self.service.remove_resource("/")
167+
Rex::ServiceManager.stop_service(self.service) if self.pending_connections == 0
168+
end
180169
end
181170

182171
attr_accessor :service # :nodoc:
@@ -228,6 +217,7 @@ def on_request(cli, req, obj)
228217
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
229218
:ssl => ssl?,
230219
})
220+
self.pending_connections += 1
231221

232222
when /^\/INITJM/
233223
conn_id = generate_uri_checksum(URI_CHECKSUM_CONN) + "_" + Rex::Text.rand_text_alphanumeric(16)

0 commit comments

Comments
 (0)