Skip to content

Commit 84fe084

Browse files
committed
Land rapid7#9074, Add prints and error checking to HTTP CmdStagers
2 parents df1f7df + 569b68b commit 84fe084

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ GEM
237237
metasm
238238
rex-arch
239239
rex-text
240-
rex-exploitation (0.1.14)
240+
rex-exploitation (0.1.15)
241241
jsobfu
242242
metasm
243243
rex-arch

LICENSE_GEMS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ rex-arch, 0.1.9, "New BSD"
8484
rex-bin_tools, 0.1.4, "New BSD"
8585
rex-core, 0.1.11, "New BSD"
8686
rex-encoder, 0.1.4, "New BSD"
87-
rex-exploitation, 0.1.14, "New BSD"
87+
rex-exploitation, 0.1.15, "New BSD"
8888
rex-java, 0.1.5, "New BSD"
8989
rex-mime, 0.1.5, "New BSD"
9090
rex-nop, 0.1.1, "New BSD"

lib/msf/core/exploit/cmdstager/http.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,25 @@ def start_service(opts = {})
2727
end
2828

2929
def on_request_uri(cli, request)
30-
if request['User-Agent'] =~ /^(?:Wget|curl)/
30+
client = cli.peerhost
31+
32+
if (user_agent = request.headers['User-Agent'])
33+
client << " (#{user_agent})"
34+
end
35+
36+
print_status("Client #{client} requested #{request.raw_uri}")
37+
38+
if stager_instance.respond_to?(:user_agent)
39+
agent_regex = stager_instance.user_agent
40+
else
41+
agent_regex = /.*/
42+
end
43+
44+
if user_agent =~ agent_regex
45+
print_status("Sending payload to #{client}")
3146
send_response(cli, exe)
3247
else
48+
print_status("Sending 404 to #{client}")
3349
send_not_found(cli)
3450
end
3551
end

0 commit comments

Comments
 (0)