예제 #1
0
        // the host enumeration block we're using to enumerate all servers
        private static IEnumerable <UserProcess> _Find_DomainProcess(string[] ComputerName, string[] ProcessName, string[] TargetUsers, System.Net.NetworkCredential Credential)
        {
            List <UserProcess> DomainProcesses = new List <UserProcess>();

            foreach (var TargetComputer in ComputerName)
            {
                var Up = TestConnection.Ping(TargetComputer, 1);
                if (Up)
                {
                    // try to enumerate all active processes on the remote host
                    // and search for a specific process name
                    IEnumerable <UserProcess> Processes;
                    if (Credential != null)
                    {
                        Processes = GetWMIProcess.Get_WMIProcess(new Args_Get_WMIProcess {
                            Credential = Credential, ComputerName = new[] { TargetComputer }
                        });
                    }
                    else
                    {
                        Processes = GetWMIProcess.Get_WMIProcess(new Args_Get_WMIProcess {
                            ComputerName = new[] { TargetComputer }
                        });
                    }
                    foreach (var Process in Processes)
                    {
                        // if we're hunting for a process name or comma-separated names
                        if (ProcessName != null)
                        {
                            if (ProcessName.Contains(Process.ProcessName))
                            {
                                DomainProcesses.Add(Process);
                            }
                        }
                        // if the session user is in the target list, display some output
                        else if (TargetUsers.Contains(Process.User))
                        {
                            DomainProcesses.Add(Process);
                        }
                    }
                }
            }

            return(DomainProcesses);
        }
예제 #2
0
 public static IEnumerable <UserProcess> Get_NetProcess(Args_Get_WMIProcess args = null)
 {
     return(GetWMIProcess.Get_WMIProcess(args));
 }