Esempio n. 1
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
            this.serviceInstaller1        = new System.ServiceProcess.ServiceInstaller();
            //
            // serviceProcessInstaller1
            //
            this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.User;
            NetworkCredential credentials = FileDecrypter.Decrypt(@"C:\credZeus.xml");

            this.serviceProcessInstaller1.Password = credentials.Password;
            this.serviceProcessInstaller1.Username = "******" + credentials.UserName;
            //
            // serviceInstaller1
            //
            this.serviceInstaller1.ServiceName = "ZeusRunner";
            this.serviceInstaller1.StartType   = System.ServiceProcess.ServiceStartMode.Automatic;
            this.serviceInstaller1.Description = "This Application checks if Zeus is currently running on the computer";
            this.serviceInstaller1.DisplayName = "ZeusRunner";
            //
            // ProjectInstaller
            //
            this.Installers.AddRange(new System.Configuration.Install.Installer[] {
                this.serviceProcessInstaller1,
                this.serviceInstaller1
            });
        }
Esempio n. 2
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            t.Stop();
            //Process[] pjava = Process.GetProcessesByName("java");
            //Process[] pcmd = Process.GetProcessesByName("cmd");
            //List<Process> pjavaFiltered = new List<Process>();
            //List<Process> pcmdFiltered = new List<Process>();

            //foreach (Process proc in pjava) {
            //    IntPtr AnswerBytes, AnswerCount;
            //    string userName = String.Empty;
            //    if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE,
            //                                    proc.SessionId,
            //                                    WTS_UserName,
            //                                    out AnswerBytes,
            //                                    out AnswerCount))
            //    {
            //        userName = Marshal.PtrToStringUni(AnswerBytes);
            //        Console.WriteLine(userName);
            //        Console.WriteLine();
            //    }
            //    if (userName == "$rape001") {
            //        pjavaFiltered.Add(proc);
            //    }
            //}

            //foreach (Process proc in pcmd)
            //{
            //    IntPtr AnswerBytes, AnswerCount;
            //    string userName = String.Empty;
            //    if (WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE,
            //                                    proc.SessionId,
            //                                    WTS_UserName,
            //                                    out AnswerBytes,
            //                                    out AnswerCount))
            //    {
            //        userName = Marshal.PtrToStringUni(AnswerBytes);
            //        Console.WriteLine(userName);
            //        Console.WriteLine();
            //    }
            //    if (userName == "$rape001")
            //    {
            //        pcmdFiltered.Add(proc);
            //    }
            //}

            //if (pjavaFiltered.Count == 0 && pcmdFiltered.Count == 0) {
            /// to create the Xml with credentials, use the following command on powershell:
            /// Get-Credential | Export-Clixml -Path C:\Users\aguiledu\werw.xml
            try
            {
                NetworkCredential credentials = FileDecrypter.Decrypt(@"C:\credZeus.xml");
                ProcessStartInfo  info        = new ProcessStartInfo(@"E:\NetBeans Projects\ZeusExtractor\ZeusExtractor.bat");
                info.UseShellExecute  = false;
                info.UserName         = credentials.UserName;
                info.Password         = credentials.SecurePassword;
                info.WorkingDirectory = @"E:\NetBeans Projects\ZeusExtractor";
                info.Domain           = "AUTH";
                Process zeus = Process.Start(info);
            }
            catch (Exception ex)
            {
                ///to view the errors caused by this, you need to launch
                ///eventvwr > Windows Logs > Application, then filter by source,
                ///which is the first parameter of the statement below
                EventLog.WriteEntry("ZeusError", ex.ToString());
            }
            //}
            t.Start();
        }