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:
parent
6bbfd51ab4
commit
cf6287e031
File diff suppressed because it is too large
Load Diff
@ -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];
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user