-
Notifications
You must be signed in to change notification settings - Fork 0
/
powershellBypass.cs
35 lines (31 loc) · 1.12 KB
/
powershellBypass.cs
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
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Management.Automation;
class powershellBypass
{
static void Main(string[] args)
{
string command = "continue";
string cmdPath = string.Format("PS C:\\Users\\{0}>", System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split('\\')[1]);
while (command != "exit")
{
Console.Write(cmdPath);
command = Console.ReadLine();
PowerShell ps = PowerShell.Create();
Collection<PSObject> PSOutput;
PSOutput = ps.AddScript(command).Invoke();
if (command != "")
{
if (PSOutput.Count == 0)
{
Console.WriteLine(string.Format("'{0}' is not recognized as an internal or external command, \noperable program or batch file.", command));
}
for (int i = 0; i < PSOutput.Count; i++)
{
Console.WriteLine(PSOutput[i].ToString());
}
}
}
}
}