Skip to content

Commit 27876a9

Browse files
committed
Add prints and better checking to HTTP CmdStagers
Admittedly, this code is more convoluted than it needs to be.
1 parent ab63cae commit 27876a9

File tree

1 file changed

+17
-1
lines changed
  • lib/msf/core/exploit/cmdstager

1 file changed

+17
-1
lines changed

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)