Ejemplo n.º 1
0
        static void Main()
        {
            string currentPath = System.Environment.CurrentDirectory;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            iosSyslogger LoggerWindow = new iosSyslogger();
            loggerTool tool = new loggerTool();

            WqlEventQuery insertQuery = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2"); //Checking USB device insertion
            ManagementEventWatcher insertWatcher = new ManagementEventWatcher(insertQuery);

            WqlEventQuery removeQuery = new WqlEventQuery("SELECT * FROM __InstanceDeletionEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_USBHub'"); //Checking USB removal
            ManagementEventWatcher removeWatcher = new ManagementEventWatcher(removeQuery);

            insertWatcher.EventArrived += new EventArrivedEventHandler((source, e) => DeviceInsertedEvent(source, e, LoggerWindow, tool));
            insertWatcher.Start();

            removeWatcher.EventArrived += new EventArrivedEventHandler((source, e) => DeviceRemovedEvent(source, e, LoggerWindow, tool));
            removeWatcher.Start();

            Thread loggerParentThread = new Thread(() => tool.readDeviceUUID(LoggerWindow, tool)); //Parent thread for Syslogger
            loggerParentThread.Start();

            Application.Run(LoggerWindow);

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
        }
Ejemplo n.º 2
0
        public void readLog(iosSyslogger form, string uuid)
        {
            string  currentPath = System.Environment.CurrentDirectory;
            Process process     = new Process();

            process.StartInfo.FileName               = currentPath + @"\cmdLogger.exe";
            process.StartInfo.Arguments              = "-u" + " " + uuid;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;

            if (uuid != null || process != null || crProcess != null)
            {
                try
                {
                    crProcess.Add(uuid, process);
                }
                catch (Exception ex)
                {
                    return;
                }//Keep gettign null point exception here
            }
            //* Set output and error (asynchronous) handlers
            process.OutputDataReceived += new DataReceivedEventHandler((source, e) => logOutputHandler(source, e, form, uuid));
            process.ErrorDataReceived  += new DataReceivedEventHandler((source, e) => logOutputHandler(source, e, form, uuid));
            //* Start process and handlers
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            process.WaitForExit();
        }
Ejemplo n.º 3
0
        public void LoggingThread(iosSyslogger form, loggerTool tool, string uuid) //Creating thread for Logger
        {
            Thread loggingThread = new Thread(() => tool.readLog(form, uuid));

            loggingThread.IsBackground = true;
            lstThreads.Add(loggingThread);
        }
Ejemplo n.º 4
0
        public void deviceInfoThread(iosSyslogger form, loggerTool tool, string uuid) //Create thread for Device info reader
        {
            Thread deviceInfoThread = new Thread(() => tool.readDeviceinfo(form, uuid));

            deviceInfoThread.IsBackground = true;
            lstThreads.Add(deviceInfoThread);
        }
Ejemplo n.º 5
0
        static void Main()
        {
            string currentPath = System.Environment.CurrentDirectory;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            iosSyslogger LoggerWindow = new iosSyslogger();
            loggerTool   tool         = new loggerTool();

            WqlEventQuery          insertQuery   = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2"); //Checking USB device insertion
            ManagementEventWatcher insertWatcher = new ManagementEventWatcher(insertQuery);

            WqlEventQuery          removeQuery   = new WqlEventQuery("SELECT * FROM __InstanceDeletionEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_USBHub'"); //Checking USB removal
            ManagementEventWatcher removeWatcher = new ManagementEventWatcher(removeQuery);

            insertWatcher.EventArrived += new EventArrivedEventHandler((source, e) => DeviceInsertedEvent(source, e, LoggerWindow, tool));
            insertWatcher.Start();

            removeWatcher.EventArrived += new EventArrivedEventHandler((source, e) => DeviceRemovedEvent(source, e, LoggerWindow, tool));
            removeWatcher.Start();

            Thread loggerParentThread = new Thread(() => tool.readDeviceUUID(LoggerWindow, tool)); //Parent thread for Syslogger

            loggerParentThread.Start();

            Application.Run(LoggerWindow);

            AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
        }
Ejemplo n.º 6
0
 static void DeviceRemovedEvent(object sender, EventArrivedEventArgs e, iosSyslogger window, loggerTool tool)
 {
     GlobalData.usbInserted = false;
     if (GlobalData.usbRemoved == true)
         return;
     else
     {
         GlobalData.usbRemoved = true;
         tool.readDeviceUUID(window, tool);
     }
 }
Ejemplo n.º 7
0
 static void DeviceInsertedEvent(object sender, EventArgs e, iosSyslogger window, loggerTool tool)
 {
     if (GlobalData.usbInserted == true) //If this is true, new iOS Device has already been processed
     {
         return;
     }
     else
     {
         GlobalData.usbInserted = true;
         tool.readDeviceUUID(window, tool);
     }
 }
Ejemplo n.º 8
0
 static void DeviceInsertedEvent(object sender, EventArgs e,iosSyslogger window, loggerTool tool)
 {
     if (GlobalData.usbInserted == true) //If this is true, new iOS Device has already been processed
     {
         return;
     }
     else
     {
         GlobalData.usbInserted = true;
         tool.readDeviceUUID(window, tool);
     }
 }
Ejemplo n.º 9
0
 static void DeviceRemovedEvent(object sender, EventArrivedEventArgs e, iosSyslogger window, loggerTool tool)
 {
     GlobalData.usbInserted = false;
     if (GlobalData.usbRemoved == true)
     {
         return;
     }
     else
     {
         GlobalData.usbRemoved = true;
         tool.readDeviceUUID(window, tool);
     }
 }
Ejemplo n.º 10
0
        public void readDeviceinfo(iosSyslogger form, string uuid)
        {
            string currentPath = System.Environment.CurrentDirectory;
            Process process = new Process();
            process.StartInfo.FileName = currentPath + @"\iOSdeviceinfo.exe";
            process.StartInfo.Arguments = "-u" + " "+uuid;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
            process.OutputDataReceived += new DataReceivedEventHandler((source, e) => deviceInfoHandler(source, e, form,uuid));

            //* Start process and handlers
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            process.WaitForExit();
        }
Ejemplo n.º 11
0
        public void readDeviceinfo(iosSyslogger form, string uuid)
        {
            string  currentPath = System.Environment.CurrentDirectory;
            Process process     = new Process();

            process.StartInfo.FileName               = currentPath + @"\iOSdeviceinfo.exe";
            process.StartInfo.Arguments              = "-u" + " " + uuid;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
            process.OutputDataReceived              += new DataReceivedEventHandler((source, e) => deviceInfoHandler(source, e, form, uuid));

            //* Start process and handlers
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            process.WaitForExit();
        }
Ejemplo n.º 12
0
        //Log output hander
        public void logOutputHandler(object sendingProcess, DataReceivedEventArgs outLine, iosSyslogger form, string uuid)
        {
            string currentPath = System.Environment.CurrentDirectory;
            bool exit = false;
            if (exit == true) return;
            try
            {
                form.BeginInvoke(new Action(() =>
                {
                    if (uuidToName.ContainsKey(uuid)==false) return;
                    form.insertToDataSource(outLine.Data,uuidToName[uuid]);
                }));

               using (System.IO.StreamWriter file = new System.IO.StreamWriter(currentPath + @"\syslog" + uuid + ".txt", true))
               {
                 file.WriteLine(outLine.Data);
               }
            }
            catch
            {
                return ;
            }
            //*Most of the logic for outputing the log should be dealt from this output Handler
        }
Ejemplo n.º 13
0
        public void logOutputHandler(object sendingProcess, DataReceivedEventArgs outLine, iosSyslogger form, string uuid) //Log output hander
        {
            string currentPath = System.Environment.CurrentDirectory;
            bool   exit        = false;

            if (exit == true)
            {
                return;
            }
            try
            {
                form.BeginInvoke(new Action(() =>
                {
                    if (uuidToName.ContainsKey(uuid) == false)
                    {
                        return;
                    }
                    form.insertToDataSource(outLine.Data, uuidToName[uuid]);
                }));

                using (System.IO.StreamWriter file = new System.IO.StreamWriter(currentPath + @"\syslog" + uuid + ".txt", true))
                {
                    file.WriteLine(outLine.Data);
                }
            }
            catch
            {
                return;
            }
            //*Most of the logic for outputing the log should be dealt from this output Handler
        }
Ejemplo n.º 14
0
 private void deviceInfoHandler(object sendingProcess, DataReceivedEventArgs outLine, iosSyslogger form, string uuid)
 {
     form.BeginInvoke(new Action(() =>
     {
         if (outLine.Data == null)
         {
             return;
         }
         if (outLine.Data.Contains("DeviceName:"))
         {
             string[] words    = outLine.Data.Split(' ');
             words             = words.Where(w => w != words[0]).ToArray();
             string deviceName = "";
             for (int i = 0; i < words.Length; i++)
             {
                 if (i < words.Length - 1)
                 {
                     deviceName += words[i] + "-";
                 }
                 else
                 {
                     deviceName += words[i];
                 }
             }
             try
             {
                 uuidToName.Add(uuid, deviceName);
             }
             catch (Exception)
             {
                 return;
             }
         }
         form.insertDeviceName = outLine.Data;
     }));
 }
Ejemplo n.º 15
0
 private void uuidinfoHandler(object sendingProcess, DataReceivedEventArgs outLine, iosSyslogger form)
 {
     if (outLine.Data == null)
     {
         return;
     }
     if (Program.GlobalData.usbRemoved == true)
     {
         int index = Program.GlobalData.uuid.FindIndex(x => x.Contains(outLine.Data));
         Program.GlobalData.tempuuid.Add(Program.GlobalData.uuid[index]);
         Program.GlobalData.uuid.RemoveAt(index);
     }
     else
     {
         if (outLine.Data == null)
         {
             return;
         }
         else if (Program.GlobalData.uuid.Contains(outLine.Data))
         {
             return;
         }
         else if (!Program.GlobalData.uuid.Contains(outLine.Data))
         {
             Program.GlobalData.uuid.Add(outLine.Data);
         }
     }
 }
Ejemplo n.º 16
0
 //Create thread for Device info reader
 public void deviceInfoThread(iosSyslogger form, loggerTool tool, string uuid)
 {
     Thread deviceInfoThread = new Thread(() => tool.readDeviceinfo(form,uuid));
     deviceInfoThread.IsBackground = true;
     lstThreads.Add(deviceInfoThread);
 }
Ejemplo n.º 17
0
 private void uuidinfoHandler(object sendingProcess, DataReceivedEventArgs outLine, iosSyslogger form)
 {
     if (outLine.Data == null) return;
     if (Program.GlobalData.usbRemoved == true)
     {
         int index = Program.GlobalData.uuid.FindIndex(x => x.Contains(outLine.Data));
         Program.GlobalData.tempuuid.Add(Program.GlobalData.uuid[index]);
         Program.GlobalData.uuid.RemoveAt(index);
     }
     else
     {
         if (outLine.Data == null) return;
         else if (Program.GlobalData.uuid.Contains(outLine.Data)) return;
         else if (!Program.GlobalData.uuid.Contains(outLine.Data))
         {
             Program.GlobalData.uuid.Add(outLine.Data);
         }
     }
 }
Ejemplo n.º 18
0
 //Creating thread for Logger
 public void LoggingThread(iosSyslogger form, loggerTool tool,string uuid)
 {
     Thread loggingThread = new Thread(() => tool.readLog(form,uuid));
     loggingThread.IsBackground = true;
     lstThreads.Add(loggingThread);
 }
Ejemplo n.º 19
0
 private void deviceInfoHandler(object sendingProcess, DataReceivedEventArgs outLine, iosSyslogger form,string uuid)
 {
     form.BeginInvoke(new Action(() =>
     {
         if(outLine.Data==null) return;
         if (outLine.Data.Contains("DeviceName:"))
         {
             string[] words = outLine.Data.Split(' ');
             words = words.Where(w => w != words[0]).ToArray();
             string deviceName = "";
             for (int i = 0; i < words.Length; i++)
             {
                 if (i < words.Length - 1)
                     deviceName += words[i] + "-";
                 else
                     deviceName += words[i];
             }
             try
             {
                 uuidToName.Add(uuid, deviceName);
             }
             catch (Exception)
             {
                 return;
             }
         }
         form.insertDeviceName = outLine.Data;
     }));
 }
Ejemplo n.º 20
0
        public void readDeviceUUID(iosSyslogger form, loggerTool tool)
        {
            string currentPath = System.Environment.CurrentDirectory;

            Process process = new Process();
            process.StartInfo.FileName = currentPath + @"\deviceid.exe";
            process.StartInfo.Arguments = "-l";
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;

            process.OutputDataReceived += new DataReceivedEventHandler((source, e) => uuidinfoHandler(source, e, form));

            //* Start process and handlers
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            process.WaitForExit();

            if (Program.GlobalData.usbRemoved == true) //Called after usb waas removed
            {

                foreach (string uuidt in Program.GlobalData.uuid)
                {
                    Process test = new Process();
                    if (!(crProcess.TryGetValue(uuidt, out test)))
                    {
                        continue;
                    }
                    if (!Program.GlobalData.tempuuid.Contains(uuidt) && uuidt != null && crProcess[uuidt] != null)
                    {
                        crProcess[uuidt].Kill();
                        crProcess.Remove(uuidt);
                    }
                }
                Program.GlobalData.uuid.Clear();
                Program.GlobalData.uuid.AddRange(Program.GlobalData.tempuuid);

                foreach (string uuidstring in Program.GlobalData.uuid)
                {
                    Thread loggingThread = new Thread(() => tool.readDeviceinfo(form, uuidstring));
                    loggingThread.IsBackground = true;
                    loggingThread.Start();
                }
                Program.GlobalData.usbRemoved = false;
                return;
            }

            else if (Program.GlobalData.usbInserted == true) //Called after usb was inserted
            {
                if (Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1] == null)
                    return;
                else
                {
                    deviceInfoThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]);
                    LoggingThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]);
                    lstThreads[lstThreads.Count - 2].Start();
                    lstThreads[lstThreads.Count - 1].Start();
                    Program.GlobalData.notInit = true;
                    return;

                }

            }
            else if (Program.GlobalData.usbInserted!=true) //First time initiated
            {
                if (Program.GlobalData.usbInserted == true) return;
                foreach (string uuid in Program.GlobalData.uuid)
                {
                    deviceInfoThread(form, tool, uuid);
                    LoggingThread(form, tool, uuid);
                }

                foreach (Thread th in lstThreads)
                {
                    th.Start();
                }
                return;
            }
            else
                return;
        }
Ejemplo n.º 21
0
        public void readDeviceUUID(iosSyslogger form, loggerTool tool)
        {
            string currentPath = System.Environment.CurrentDirectory;

            Process process = new Process();

            process.StartInfo.FileName               = currentPath + @"\deviceid.exe";
            process.StartInfo.Arguments              = "-l";
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;

            process.OutputDataReceived += new DataReceivedEventHandler((source, e) => uuidinfoHandler(source, e, form));

            //* Start process and handlers
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            process.WaitForExit();


            if (Program.GlobalData.usbRemoved == true) //Called after usb waas removed
            {
                foreach (string uuidt in Program.GlobalData.uuid)
                {
                    Process test = new Process();
                    if (!(crProcess.TryGetValue(uuidt, out test)))
                    {
                        continue;
                    }
                    if (!Program.GlobalData.tempuuid.Contains(uuidt) && uuidt != null && crProcess[uuidt] != null)
                    {
                        crProcess[uuidt].Kill();
                        crProcess.Remove(uuidt);
                    }
                }
                Program.GlobalData.uuid.Clear();
                Program.GlobalData.uuid.AddRange(Program.GlobalData.tempuuid);

                foreach (string uuidstring in Program.GlobalData.uuid)
                {
                    Thread loggingThread = new Thread(() => tool.readDeviceinfo(form, uuidstring));
                    loggingThread.IsBackground = true;
                    loggingThread.Start();
                }
                Program.GlobalData.usbRemoved = false;
                return;
            }

            else if (Program.GlobalData.usbInserted == true) //Called after usb was inserted
            {
                if (Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1] == null)
                {
                    return;
                }
                else
                {
                    deviceInfoThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]);
                    LoggingThread(form, tool, Program.GlobalData.uuid[Program.GlobalData.uuid.Count - 1]);
                    lstThreads[lstThreads.Count - 2].Start();
                    lstThreads[lstThreads.Count - 1].Start();
                    Program.GlobalData.notInit = true;
                    return;
                }
            }
            else if (Program.GlobalData.usbInserted != true) //First time initiated
            {
                if (Program.GlobalData.usbInserted == true)
                {
                    return;
                }
                foreach (string uuid in Program.GlobalData.uuid)
                {
                    deviceInfoThread(form, tool, uuid);
                    LoggingThread(form, tool, uuid);
                }

                foreach (Thread th in lstThreads)
                {
                    th.Start();
                }
                return;
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 22
0
        public void readLog(iosSyslogger form,string uuid)
        {
            string currentPath = System.Environment.CurrentDirectory;
            Process process = new Process();

            process.StartInfo.FileName = currentPath+ @"\cmdLogger.exe";
            process.StartInfo.Arguments = "-u"+" "+uuid;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;

            if (uuid != null || process != null || crProcess != null)
            {
                try
                {
                    crProcess.Add(uuid, process);
                }
                catch (Exception ex)
                {
                    return;
                }//Keep gettign null point exception here
            }
            //* Set output and error (asynchronous) handlers
            process.OutputDataReceived += new DataReceivedEventHandler((source, e)=> logOutputHandler(source,e,form,uuid));
            process.ErrorDataReceived += new DataReceivedEventHandler((source, e) => logOutputHandler(source, e, form,uuid));
            //* Start process and handlers
            process.Start();
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            process.WaitForExit();
        }