Skip to content

Commit d2624ef

Browse files
author
Brent Cook
committed
Land rapid7#7758, Add HTTP CmdStagers - wget and curl
2 parents fae4751 + 36e0bad commit d2624ef

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ GEM
250250
metasm
251251
rex-arch
252252
rex-text
253-
rex-exploitation (0.1.4)
253+
rex-exploitation (0.1.7)
254254
jsobfu
255255
metasm
256256
rex-arch

lib/msf/core/exploit/cmdstager.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# -*- coding: binary -*-
22

33
require 'rex/exploitation/cmdstager'
4-
require 'msf/core/exploit/exe'
5-
require 'msf/base/config'
4+
require 'msf/core/exploit/cmdstager/http'
65

76
module Msf
87

98
# This mixin provides an interface to generating cmdstagers
109
module Exploit::CmdStager
1110

1211
include Msf::Exploit::EXE
12+
include Msf::Exploit::CmdStager::Http
1313

1414
# Constant for stagers - used when creating an stager instance.
1515
STAGERS = {
@@ -21,7 +21,9 @@ module Exploit::CmdStager
2121
:vbs => Rex::Exploitation::CmdStagerVBS,
2222
:vbs_adodb => Rex::Exploitation::CmdStagerVBS,
2323
:certutil => Rex::Exploitation::CmdStagerCertutil,
24-
:tftp => Rex::Exploitation::CmdStagerTFTP
24+
:tftp => Rex::Exploitation::CmdStagerTFTP,
25+
:wget => Rex::Exploitation::CmdStagerWget,
26+
:curl => Rex::Exploitation::CmdStagerCurl
2527
}
2628

2729
# Constant for decoders - used when checking the default flavor decoder.
@@ -124,6 +126,11 @@ def generate_cmdstager(opts = {}, pl = nil)
124126
end
125127

126128
self.stager_instance = create_stager
129+
130+
if stager_instance.respond_to?(:http?) && stager_instance.http?
131+
opts[:payload_uri] = start_service(opts)
132+
end
133+
127134
cmd_list = stager_instance.generate(opts_with_decoder(opts))
128135

129136
if cmd_list.nil? || cmd_list.length.zero?
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: binary -*-
2+
3+
require 'msf/core/exploit/tcp_server'
4+
require 'msf/core/exploit/http/server'
5+
6+
module Msf::Exploit::CmdStager
7+
module Http
8+
9+
include Msf::Exploit::Remote::HttpServer
10+
11+
def initialize(info = {})
12+
super(update_info(info,
13+
'Stance' => Msf::Exploit::Stance::Aggressive
14+
))
15+
end
16+
17+
def start_service(opts = {})
18+
datastore_ssl = datastore['SSL']
19+
datastore['SSL'] = !!opts[:ssl]
20+
21+
super
22+
23+
payload_uri = get_uri
24+
datastore['SSL'] = datastore_ssl
25+
26+
payload_uri
27+
end
28+
29+
def on_request_uri(cli, request)
30+
if request['User-Agent'] =~ /^(?:Wget|curl)/
31+
send_response(cli, exe)
32+
else
33+
send_not_found(cli)
34+
end
35+
end
36+
37+
end
38+
end

0 commit comments

Comments
 (0)