Ejemplo n.º 1
0
        public static string DecryptPacketToXmlFile(string dttPath, string namePacket, string tempFolder, string nameOutPutFile)
        {
            var dttSource = Path.Combine(Path.Combine(Path.Combine(dttPath, AT.GetDate()), @"PACKETS"), namePacket);

            //var tempDest = Path.Combine(tempFolder, namePacket);
            //Console.WriteLine("tempDest : " + tempDest.ToString());

            string pathToCurrentDll = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Substring(6);

            Console.WriteLine("Path To Current DLL: " + pathToCurrentDll);

            //File.Copy(dttSource, tempDest, true);

            //Decript packets
            var outPutFile = Path.Combine(tempFolder, nameOutPutFile);

            Console.WriteLine("outPutFile : " + outPutFile.ToString());
            var fileTobeDecrypt = Path.Combine(tempFolder, namePacket);

            Console.WriteLine("fileTobeDecrypt : " + fileTobeDecrypt.ToString());
            var key = "";

            if (File.Exists(outPutFile))
            {
                key = "--i";
            }
            var commandDecrypt = "type \"" + pathToCurrentDll + "\\pass.txt\" | \"" + pathToCurrentDll + "\\gpg.exe\"  " + key + " --passphrase-fd 0 --output \"" + outPutFile + "\" --secret-keyring \"" + pathToCurrentDll + "\\secring.gpg\" --keyring \"" + pathToCurrentDll + "\\pubring.gpg\" -d " + dttSource;

            Console.WriteLine("commandDecrypt : " + commandDecrypt.ToString());

            Program.ExecuteCommandCmd(commandDecrypt);
            //TODO: Sleep must be removed. gpg application must be called synchronously
            Thread.Sleep(3000);
            return(outPutFile);
        }
Ejemplo n.º 2
0
        //TODO: One of the two following functions must be removed. At least one of them should use another
        public static string DecryptPacket(string dttPath, string namePacket, string tempFolder, string pathToDecriptFile)
        {
            var dttSource = Path.Combine(Path.Combine(Path.Combine(dttPath, AT.GetDate()), @"PACKETS"), namePacket);
            var tempDest  = Path.Combine(tempFolder, namePacket);

            File.Copy(dttSource, tempDest, true);
            string packetBackupFolder = Path.Combine(tempFolder, @"PacketsBackup");

            if (!Directory.Exists(packetBackupFolder))
            {
                Directory.CreateDirectory(packetBackupFolder);
            }
            File.Copy(dttSource, Path.Combine(packetBackupFolder, namePacket), true);
            //Decript packets
            var outPutFile      = Path.Combine(tempFolder, NameOutPutFile);
            var fileTobeDecrypt = Path.Combine(tempFolder, namePacket);
            var key             = "";

            if (File.Exists(outPutFile))
            {
                key = "--i";
            }
            var commandDecrypt = "type \"" + pathToDecriptFile + "\\pass.txt\" | \"" + pathToDecriptFile + "\\gpg.exe\"  " + key + " --passphrase-fd 0 --output \"" + outPutFile + "\" --secret-keyring \"" + pathToDecriptFile + "\\secring.gpg\" --keyring \"" + pathToDecriptFile + "\\pubring.gpg\" -d " + fileTobeDecrypt;

            Program.ExecuteCommandCmd(commandDecrypt);

            return(outPutFile);
        }
Ejemplo n.º 3
0
        public static void CheckOpenSpanStopStart(string pathToDecryptedPacket, string tempFolder)
        {
            var          openSpanStartStop = new List <OpenSpan>();
            const string nameTag           = "event-dump";
            const string nameOpenSpanStart = "OpenSpan:start";
            const string nameOpenSpanStop  = "OpenSpan:stop";
            //TODO: assuming single packet? - bad idea
            var content  = SystemSettings.GetContentOfXml(Path.Combine(tempFolder, NameOutPutFile));
            var listTags = content.GetElementsByTagName(nameTag);

            foreach (XmlElement tag in listTags)
            {
                if (tag.GetAttribute("category") == nameOpenSpanStart | tag.GetAttribute("category") == nameOpenSpanStop)
                {
                    var tempStore = new OpenSpan();
                    tempStore.TimeStamp = tag.GetAttribute("time");
                    openSpanStartStop.Add(tempStore);
                }
            }
            //Check open span start open span stop
            Assert.IsTrue(openSpanStartStop.Count == 2);
            foreach (var eventHotKey in openSpanStartStop)
            {
                Assert.IsTrue(eventHotKey.TimeStamp.Contains(AT.GetDate()));
            }

            var dateOpenSpanStart = DateTime.Parse(openSpanStartStop[0].TimeStamp);
            var dataOpenSpanStop  = DateTime.Parse(openSpanStartStop[1].TimeStamp);

            if (DateTime.Compare(dataOpenSpanStop, dateOpenSpanStart) < 0 | DateTime.Compare(dataOpenSpanStop, dateOpenSpanStart) == 0)
            {
                Console.WriteLine("dataOpenSpanStop=" + dataOpenSpanStop + ".dateOpenSpanStart=" + dateOpenSpanStart);
                Assert.Fail("Event Idle stop and Idle start has incorrect time stamp!");
            }

            //Check time stamp idle time and openSpanStart
            CheckIdleTimeAndTime(pathToDecryptedPacket, tempFolder);
            foreach (var openSpan in _idleTimeStore)
            {
                if (!(DateTime.Compare(dateOpenSpanStart, DateTime.Parse(openSpan.TimeStamp)) < 0))
                {
                    Console.WriteLine("dateOpenSpanStart=" + dateOpenSpanStart + ". openSpan.TimeStamp=" + openSpan.TimeStamp);
                    Assert.Fail("Event Idle time is earlier than OpenSpanStart!");
                }

                if (!(DateTime.Compare(dataOpenSpanStop, DateTime.Parse(openSpan.TimeStamp)) > 0))
                {
                    if (DateTime.Compare(DateTime.Parse(openSpan.TimeStamp), DateTime.Parse(_idleTimeStore[_idleTimeStore.Count - 1].TimeStamp)) != 0)
                    {
                        Assert.Fail("Event Idle time is later than OpenSpanStop!");
                    }
                }
            }
            //TODO: What are these indexes: 0 and 2?
            if (DateTime.Compare(DateTime.Parse(_idleTimeStore[0].TimeStamp), DateTime.Parse(_idleTimeStore[2].TimeStamp)) == 0)
            {
                Assert.Fail("All Idle time has the same time!");
            }
        }
Ejemplo n.º 4
0
        public static List <FileInfo> GetPackets(string dttPath, string tempFolder)
        {
            Directory.CreateDirectory(tempFolder);
            //Copy packets to temp folder from dttoutput.
            var packetsFolderPath = Path.Combine(Path.Combine(dttPath, AT.GetDate()), @"PACKETS");

            return(AT.GetContentOfFolder(packetsFolderPath, "*.packet"));
        }
Ejemplo n.º 5
0
        public static void CheckHotKeyBehaviourAndTime(string pathToDecryptedPacket, string tempFolder)
        {
            var          hotKeyStore   = new List <OpenSpan>();
            const string nameTag       = "event-dump";
            const string nameBehaviour = "Behavior:hotkey";
            var          content       = SystemSettings.GetContentOfXml(Path.Combine(tempFolder, NameOutPutFile));
            var          listTags      = content.GetElementsByTagName(nameTag);

            foreach (XmlElement tag in listTags)
            {
                if (tag.GetAttribute("category") == nameBehaviour)
                {
                    var tempStore = new OpenSpan();
                    tempStore.TimeStamp = tag.GetAttribute("time");
                    //TODO: Looks suspicious, XPath would be better solution
                    if (tag.ChildNodes[0] != null)
                    {
                        tempStore.Name1  = tag.ChildNodes[0].Attributes[0].Value;
                        tempStore.Value1 = tag.ChildNodes[0].Attributes[1].Value;
                    }
                    if (tag.ChildNodes[1] != null)
                    {
                        tempStore.Name2  = tag.ChildNodes[1].Attributes[0].Value;
                        tempStore.Value2 = tag.ChildNodes[1].Attributes[1].Value;
                    }
                    hotKeyStore.Add(tempStore);
                }
            }

            var countFocusIn = 0;

            foreach (var eventHotKey in hotKeyStore)
            {
                if (eventHotKey.Value1 == "F1")
                {
                    Assert.IsTrue(eventHotKey.TimeStamp.Contains(AT.GetDate()));
                    countFocusIn = countFocusIn + 1;
                }
                if (eventHotKey.Value1 == "Alt")
                {
                    if (eventHotKey.Value2 == "S" | eventHotKey.Value2 == "F4")
                    {
                        Assert.IsTrue(eventHotKey.TimeStamp.Contains(AT.GetDate()));
                        countFocusIn = countFocusIn + 1;
                    }
                }
            }
            Assert.IsTrue(countFocusIn == 3);
        }
Ejemplo n.º 6
0
        public static void CheckOsRunTimeLogFileExistCorrectInformation(string pathToWdLogFile)
        {
            var pathToLog = Path.Combine(Path.Combine(pathToWdLogFile, AT.GetDate()), "LOGS");
            var listFiles = AT.GetContentOfFolder(pathToLog, "*.log");
            var logfile   = "";

            foreach (var listFile in listFiles)
            {
                if (listFile.Name.Contains("os_runtime"))
                {
                    logfile = listFile.Name;
                }
            }
            var text = File.ReadAllText(Path.Combine(pathToLog, logfile));

            Assert.IsTrue(!text.Contains("terminate"), "'terminate' appears in the OSRunTime.log");
            Assert.IsTrue(!text.Contains("Fatal"), "'Fatal' appears in the OSRunTime.log");
            Assert.IsTrue(!text.Contains("ERROR"), "ERROR appears in the OSRunTime.log");
        }
Ejemplo n.º 7
0
        public static void CheckWdLogFileNoError(string pathToWdLogFile)
        {
            var pathToLog = Path.Combine(Path.Combine(pathToWdLogFile, AT.GetDate()), "LOGS");
            var listFiles = AT.GetContentOfFolder(pathToLog, "*.log");
            var logfile   = "";

            foreach (var listFile in listFiles)
            {
                if (listFile.Name.Contains("Watchdog"))
                {
                    logfile = listFile.Name;
                }
            }
            var text = File.ReadAllText(Path.Combine(pathToLog, logfile));

            Assert.IsTrue(!text.Contains("terminate"), "'terminate' appears in the WatchDog.log");
            Assert.IsTrue(!text.Contains("Fatal"), "'Fatal' appears in the WatchDog.log");
            Assert.IsTrue(!text.Contains("ERROR"), "ERROR appears in the WatchDog.log");
        }
Ejemplo n.º 8
0
        public static void CheckFocusInBehaviourAndTime(string pathToDecryptedPacket, string tempFolder)
        {
            //Check count FocusIn event
            var          focusInStore  = new List <FocusInStruct>();
            const string nameTag       = "event-dump";
            const string nameBehaviour = "Behavior:FocusIn";
            var          content       = SystemSettings.GetContentOfXml(Path.Combine(tempFolder, NameOutPutFile));
            var          listTags      = content.GetElementsByTagName(nameTag);

            foreach (XmlElement tag in listTags)
            {
                if (tag.GetAttribute("category") == nameBehaviour)
                {
                    var tempStore = new FocusInStruct();
                    tempStore.TimeStamp = tag.GetAttribute("time");
                    if (tag.FirstChild.Attributes != null)
                    {
                        var appId = tag.FirstChild.Attributes[1].Value;
                        tempStore.ApplicationId = appId;
                    }
                    focusInStore.Add(tempStore);
                }
            }

            var countFocusIn = 0;

            foreach (var eventFocusIn in focusInStore)
            {
                if (eventFocusIn.ApplicationId.ToLower().Contains((@"Enkata Technologies Inc\Activity Tracker\OS Runtime\Enkata.Analytics.VideoRecordingHost.exe").ToLower()) | eventFocusIn.ApplicationId.ToLower().Contains((@"Calc.exe").ToLower()))
                {
                    eventFocusIn.TimeStamp.Contains(AT.GetDate());
                    countFocusIn = countFocusIn + 1;
                }
            }
            if (Program.ScreenRecording == "ON")
            {
                Assert.IsTrue(countFocusIn >= 2);
            }
            else
            {
                Assert.IsTrue(countFocusIn >= 1);
            }
        }
Ejemplo n.º 9
0
 public static void CleanMachine()
 {
     try
     {
         AT.DeleteFolder(Path.Combine(Path.Combine(NunitSettings.DttPath.ToString(), AT.GetDate()), "PACKETS"));
         Directory.CreateDirectory(Path.Combine(Path.Combine(NunitSettings.DttPath.ToString(), AT.GetDate()), "PACKETS"));
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
     try
     {
         AT.DeleteFolder(NunitSettings.TempFolder);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 10
0
        public static void CheckIdleTimeAndTime(string pathToDecryptedPacket, string tempFolder)
        {
            _idleTimeStore = new List <OpenSpan>();
            const string nameTag        = "event-dump";
            const string nameBehaviour1 = "Behavior:idle-start";
            const string nameBehaviour2 = "Behavior:idle-stop";
            var          content        = SystemSettings.GetContentOfXml(Path.Combine(tempFolder, NameOutPutFile));
            var          listTags       = content.GetElementsByTagName(nameTag);

            foreach (XmlElement tag in listTags)
            {
                if (tag.GetAttribute("category") == nameBehaviour1 | tag.GetAttribute("category") == nameBehaviour2)
                {
                    var tempStore = new OpenSpan();
                    tempStore.TimeStamp = tag.GetAttribute("time");
                    //TODO: Looks suspicious, XPath would be better solution
                    if (tag.ChildNodes[0] != null)
                    {
                        tempStore.Name1  = tag.ChildNodes[0].Attributes[0].Value;
                        tempStore.Value1 = tag.ChildNodes[0].Attributes[1].Value;
                    }
                    _idleTimeStore.Add(tempStore);
                }
            }
            //Check event idle start and idle stop contains in packet
            Assert.IsTrue(_idleTimeStore.Count >= 2);
            //Check that event Idle stop contains idle start
            var countIdelTime = 0;

            foreach (var eventHotKey in _idleTimeStore)
            {
                Assert.IsTrue(eventHotKey.TimeStamp.Contains(AT.GetDate()));
                if (eventHotKey.Name1 == "idle_start")
                {
                    countIdelTime = countIdelTime + 1;
                }
            }
            Assert.IsTrue(countIdelTime >= 1);
        }
Ejemplo n.º 11
0
        public static void CheckPacketEnkataEvent1(string pathToDecryptedPacket, string tempFolder, string nameEvent)
        {
            var          eventPacketStore = new List <OpenSpan>();
            const string nameTag          = "event-dump";
            string       nameBehaviour1   = nameEvent;
            var          content          = SystemSettings.GetContentOfXml(Path.Combine(tempFolder, NameOutPutFile));
            var          listTags         = content.GetElementsByTagName(nameTag);

            foreach (XmlElement tag in listTags)
            {
                if (tag.GetAttribute("trigger") == nameBehaviour1)
                {
                    var tempStore = new OpenSpan();
                    tempStore.TimeStamp = tag.GetAttribute("time");
                    //TODO: Looks suspicious, XPath would be better solution
                    if (tag.ChildNodes[0] != null)
                    {
                        tempStore.Name1  = tag.ChildNodes[0].Attributes[0].Value;
                        tempStore.Value1 = tag.ChildNodes[0].Attributes[1].Value;
                    }
                    eventPacketStore.Add(tempStore);
                }
            }
            //Check EnkataEvent1 contains in packet
            Assert.IsTrue(eventPacketStore.Count >= 1, "Enkata event = " + eventPacketStore.Count);
            //Check that event EnkataEvent1 contains correct value
            var countFocusIn = 0;

            foreach (var eventHotKey in eventPacketStore)
            {
                Assert.IsTrue(eventHotKey.TimeStamp.Contains(AT.GetDate()));
                if (eventHotKey.Value1 == "31." || eventHotKey.Name1 == "Field1")
                {
                    countFocusIn = countFocusIn + 1;
                }
            }
            Assert.IsTrue(countFocusIn == 1);
        }
Ejemplo n.º 12
0
 public static void CheckProcess()
 {
     Assert.IsTrue(AT.WatchdogExists(), "Watch Dog service isn't started.");
     Assert.IsTrue(AT.DttExists(), "DTT service isn't started.");
     Assert.IsTrue(AT.OsrExists(), "OSR process isn't started.");
 }