Skip to content

Commit f1a1e1a

Browse files
author
RageLtMan
committed
Implement specific dispatch extensions for tunnels
All meterpreter Clients are created equal, and as such they all include the PacketDispatcher mixin and call its init methods when a passive dispatcher is needed. However, since tunneling protocols have different requirements for implementation, the methods which provide protocol-specific functionality need to be mixed into the Client before it attempts to initialize the dispatcher. Provide a dispatch_ext option in the has passed to the client on init from the session handler which is an Array containing mixin references which are sent to :extend calls in the :init_meterpreter method just prior to calling :initialize_passive_dispatcher. Each handler implementation can thus push chains of mixins to the client in order to provide middleware specific to the tunnel. Down the road, this should permit stacking C2 encapsulations or tunnel protocols/permutators to create unique session transports on the fly.
1 parent d420bf1 commit f1a1e1a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/msf/core/handler/reverse_http.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ def on_request(cli, req)
384384

385385
create_session(cli, {
386386
:passive_dispatcher => self.service,
387+
:dispatch_ext => [Rex::Post::Meterpreter::HttpPacketDispatcher],
387388
:conn_id => conn_id,
388389
:url => url,
389390
:expiration => datastore['SessionExpirationTimeout'].to_i,

lib/rex/post/meterpreter/client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ def init_meterpreter(sock,opts={})
165165
end
166166
end
167167

168+
# Protocol specific dispatch mixins go here, this may be neader with explicit Client classes
169+
opts[:dispatch_ext].each {|dx| self.extend(dx)} if opts[:dispatch_ext]
168170
initialize_passive_dispatcher if opts[:passive_dispatcher]
169171

170172
register_extension_alias('core', ClientCore.new(self))

0 commit comments

Comments
 (0)