Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified WMIUtility.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions wmiutility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ static string RunLocalQuery(SelectQuery query, string columns)
}
return sb.ToString();
}

static string RunLocalSecurityQuery(string query, string columns)
{
Console.WriteLine($"Querying: {query}");
string wmipathstr = @"\\" + Environment.MachineName + @"\root\SecurityCenter2";
StringBuilder sb = new StringBuilder();
foreach (ManagementBaseObject item in new ManagementObjectSearcher(wmipathstr,query).Get())
{
foreach (string column in columns.Split(','))
{
sb.Append(column + new string(' ', 25 - column.Length) + ": ");
sb.Append(item[column] + "\r\n");
}
sb.Append("\r\n");
}
return sb.ToString();
}

static void Main(string[] args)
{
if (args.Length >= 1)
Expand Down Expand Up @@ -177,6 +195,10 @@ static void Main(string[] args)
{
Console.WriteLine(RunRemoteQuery(new SelectQuery($"Select * from Win32_NTLogEvent Where Logfile='Security' and EventCode='4624' and Message Like '%{arg2}%'"), arg2, arg3, arg4, arg5));
}
else if(arg1 == "get-av")
{
Console.WriteLine(RunLocalSecurityQuery("Select * from AntivirusProduct", "displayName,pathToSignedProductExe,pathToSignedReportingExe"));
}
else if (arg1 == "remotequery")
{
Console.WriteLine(RunRemoteQuery(new SelectQuery(arg2), arg3, arg4, arg5, arg6));
Expand Down