1
mirror of https://github.com/rapid7/metasploit-payloads synced 2024-11-20 14:39:22 +01:00

Fix runner to properly support multi-line scripts

This commit actually changes the PS runner code so that it's
base64-encoded before being sent to the interpreter. It's a bit of
a hack but it means that all multiline commands are properly supported.
IEX for the win!
This commit is contained in:
OJ 2016-03-25 10:28:14 +10:00
parent 6bbfd51ab4
commit cf6287e031
3 changed files with 2170 additions and 2126 deletions

View File

@ -6,7 +6,7 @@
#ifndef _METERPRETER_SOURCE_EXTENSION_POWERSHELL_RUNNER_H
#define _METERPRETER_SOURCE_EXTENSION_POWERSHELL_RUNNER_H
#define PSHRUNNER_DLL_LEN 38912
#define PSHRUNNER_DLL_LEN 39424
extern unsigned char PowerShellRunnerDll[PSHRUNNER_DLL_LEN];

View File

@ -65,7 +65,8 @@ namespace MSF.Powershell
public string Execute(string ps)
{
ps = string.Join("; ", ps.Trim().Split('\n'));
ps = "IEX ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(\"" + Convert.ToBase64String(Encoding.UTF8.GetBytes(ps), Base64FormattingOptions.None) + "\")))";
System.Diagnostics.Debug.Write(string.Format("[PSH RUNNER] Executing PS: {0}", ps));
using (Pipeline pipeline = _runspace.CreatePipeline())
{
pipeline.Commands.AddScript(ps);