Skip to content

Commit 8bd41a3

Browse files
committed
Land rapid7#5354 - transport config fallback in stager
2 parents 20ad2a8 + 8b2e5c8 commit 8bd41a3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/msf/core/payload/stager.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: binary -*-
22
require 'msf/core'
33
require 'msf/core/option_container'
4+
require 'msf/core/payload/transport_config'
45

56
###
67
#
@@ -9,6 +10,8 @@
910
###
1011
module Msf::Payload::Stager
1112

13+
include Msf::Payload::TransportConfig
14+
1215
def initialize(info={})
1316
super
1417

@@ -22,6 +25,28 @@ def initialize(info={})
2225

2326
end
2427

28+
#
29+
# Perform attempt at detecting the appropriate transport config.
30+
# Call the determined config with passed options.
31+
# Override this in stages/stagers to use specific transports
32+
#
33+
def transport_config(opts={})
34+
if self.refname =~ /reverse_/
35+
direction = 'reverse'
36+
else
37+
direction = 'bind'
38+
end
39+
40+
if self.refname =~ /_tcp/
41+
proto = 'tcp'
42+
elsif self.refname =~ /_https/
43+
proto = 'https'
44+
else
45+
proto = 'http'
46+
end
47+
send("transport_config_#{direction}_#{proto}", opts)
48+
end
49+
2550
#
2651
# Sets the payload type to a stager.
2752
#

0 commit comments

Comments
 (0)