From 1214ac17a7e78515813cb8ef4740237591930318 Mon Sep 17 00:00:00 2001 From: William Vu Date: Sun, 10 May 2020 04:12:45 -0500 Subject: [PATCH] Refactor Msf::Exploit::CmdStager::HTTP Minor updates to align with current style. --- lib/msf/core/exploit/cmdstager.rb | 2 +- lib/msf/core/exploit/cmdstager/http.rb | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/msf/core/exploit/cmdstager.rb b/lib/msf/core/exploit/cmdstager.rb index 8274044c05..9399a9809b 100644 --- a/lib/msf/core/exploit/cmdstager.rb +++ b/lib/msf/core/exploit/cmdstager.rb @@ -9,7 +9,7 @@ module Msf module Exploit::CmdStager include Msf::Exploit::EXE - include Msf::Exploit::CmdStager::Http + include Msf::Exploit::CmdStager::HTTP # Constant for stagers - used when creating an stager instance. STAGERS = { diff --git a/lib/msf/core/exploit/cmdstager/http.rb b/lib/msf/core/exploit/cmdstager/http.rb index 1944f3aac0..ee65d776ec 100644 --- a/lib/msf/core/exploit/cmdstager/http.rb +++ b/lib/msf/core/exploit/cmdstager/http.rb @@ -4,7 +4,7 @@ require 'msf/core/exploit/tcp_server' require 'msf/core/exploit/http/server' module Msf::Exploit::CmdStager -module Http +module HTTP include Msf::Exploit::Remote::HttpServer @@ -36,19 +36,20 @@ module Http print_status("Client #{client} requested #{request.uri}") + # NOTE: stager_instance is from Msf::Exploit::CmdStager if stager_instance.respond_to?(:user_agent) agent_regex = stager_instance.user_agent else agent_regex = /.*/ end - if user_agent =~ agent_regex - print_status("Sending payload to #{client}") - send_response(cli, self.exe) - else + unless user_agent =~ agent_regex print_status("Sending 404 to #{client}") send_not_found(cli) end + + print_status("Sending payload to #{client}") + send_response(cli, exe) # NOTE: exe is from Msf::Exploit::CmdStager end end