示例#1
0
        public void Perform()
        {
            var strtInfo = new ProcessStartInfo
            {
                FileName  = _fileName,
                Arguments = String.Join(" ", _args)
            };

            if (AsUser)
            {
                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(30));
                ProcessAsUser.Launch(String.Format("{0} {1}", _fileName, strtInfo.Arguments));
                return;
            }

            if (HideWindow)
            {
                strtInfo.CreateNoWindow = true;
                strtInfo.WindowStyle    = ProcessWindowStyle.Hidden;
            }

            if (AsAdmin)
            {
                strtInfo.UseShellExecute        = true;
                strtInfo.RedirectStandardOutput = false;
                strtInfo.Verb = @"runas";
            }
            else if (_waitForExit)
            {
                strtInfo.UseShellExecute        = false;
                strtInfo.RedirectStandardOutput = true;
            }

            if (!String.IsNullOrEmpty(WorkingFolder))
            {
                strtInfo.WorkingDirectory = WorkingFolder;
            }

            var pr = Process.Start(strtInfo);

            if (pr != null)
            {
                if (_waitForExit)
                {
                    string output = pr.StandardOutput.ReadToEnd();
                    Trace.WriteLine(output);
                    pr.WaitForExit();
                }
            }
            else
            {
                throw new ExecuteCommandException {
                          Step = this
                };
            }
        }
示例#2
0
 public void NCFRingDown(string id, Dictionary <string, object> parameters, SystemState state)
 {
     if (state.SessionStatus != SessionState.Active)
     {
         // only active sessions can be locked
         return;
     }
     if (state.CredentialData.ProviderActive)
     {
         return;
     }
     try
     {
         ProcessAsUser.Launch(@"C:\WINDOWS\system32\rundll32.exe user32.dll,LockWorkStation");
     }
     catch (Exception ex)
     {
         NFCRing.Service.Core.ServiceCore.Log("LockWorkstationPlugin: Exception thrown: " + ex.Message);
     }
 }
示例#3
0
            public void Start()
            {
                System.Diagnostics.Process[] aExplorers = System.Diagnostics.Process.GetProcessesByName("explorer");
                ProcessOwner cProcessOwner = null;

                foreach (System.Diagnostics.Process cExplorer in aExplorers)
                {
                    cProcessOwner = GetProcessOwner(cExplorer.Id);
                    (new helpers.Logger()).WriteDebug2(cExplorer.Id + ":" + cProcessOwner.sUsername);
                    if (sOwner == cProcessOwner.sUsername)
                    {
                        ReplaceConfigs();
                        (new helpers.Logger()).WriteNotice("запуск целевого процесса");
                        System.Threading.Thread.Sleep(500);
                        nID = ProcessAsUser.Launch("\"" + sName + ".exe\" " + sArguments, cExplorer.Id, bHideConsole);
                        System.Threading.Thread.Sleep(500);
                        PlaceConfigBack();
                        break;
                    }
                }
            }
示例#4
0
        public void NCFRingDown(string id, Dictionary <string, object> parameters, SystemState state)
        {
            if (state.SessionStatus != SessionState.Active)
            {
                // only active sessions can be locked
                return;
            }
            try
            {
                // check that this ID is registered for the credential provider
                RegistryKey key = OpenKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{8EB4E5F7-9DFB-4674-897C-2A584934CDBE}");

                // i guess the credential provider isn't installed or we're not running as admin
                if (key == null)
                {
                    return;
                }

                SHA1Managed sm = new SHA1Managed();
                // add salt. this is dumb
                byte[] hash       = sm.ComputeHash(System.Text.Encoding.ASCII.GetBytes(id + "02164873"));
                string hash1      = HashToHex(hash);
                string newKeyName = HashToHex(sm.ComputeHash(System.Text.Encoding.ASCII.GetBytes(hash1)));

                if (key.OpenSubKey(newKeyName) == null)
                {
                    NFCRing.Service.Core.ServiceCore.Log("LockWorkstationPlugin: Unknown token");
                    return;
                }
                NFCRing.Service.Core.ServiceCore.Log("LockWorkstationPlugin: Found token");
                ProcessAsUser.Launch(@"C:\WINDOWS\system32\rundll32.exe user32.dll,LockWorkStation");
            }
            catch (Exception ex)
            {
                NFCRing.Service.Core.ServiceCore.Log("LockWorkstationPlugin: Exception thrown: " + ex.Message);
            }
        }