Загрузка...

Anti-CIS in C# (plus a useful info parser)

Thread in C# created by InspectorCode Oct 4, 2019. 474 views

  1. InspectorCode
    InspectorCode Topic starter Oct 4, 2019 9 Mar 29, 2019
    Всем кискам хай! :cool_bun:

    Простой Анти-СНГ на C# + парсер полезной инфы, такой как:
    Страна, Город, IP, провайдер и тп.

    Code
    using System;
    using System;
    using System.Collections.Generic;
    using System.Net;
    using Newtonsoft.Json;

    namespace SystemIC
    {
    class Program
    {

    #region Общие переменные
    public static string country;
    public static bool bCIS = true; // true - значит АнтиСНГ включён.
    #endregion

    static void Main(string[] args)
    {
    if(bCIS)
    AntiCIS();
    Console.ReadLine();
    }

    #region АнтиСНГ
    public static void AntiCIS()
    {
    string server = GetStringWeb("http://ip-api.com/json/");
    var rootObject = JsonConvert.DeserializeObject<RootObject>(server);
    country = rootObject.Country;
    if (Country()) {
    // Ваш код, если прошёл проверку
    }
    else Environment.Exit(0); // Закрываем, если СНГ-страна
    Console.ReadKey();
    }

    // Лист для парса страны и пр.
    public class RootObject
    {
    public string As { get; set; }
    public string City { get; set; }
    public string Country { get; set; }
    public string CountryCode { get; set; }
    public string Isp { get; set; }
    public string Lat { get; set; }
    public string Lon { get; set; }
    public string Org { get; set; }
    public string Query { get; set; }
    public string Region { get; set; }
    public string RegionName { get; set; }
    public string Status { get; set; }
    public string Timezone { get; set; }
    public string Zip { get; set; }


    }

    // Парс страницы по ссылке
    public static string GetStringWeb(string link)
    {
    string linkString = "";
    try
    {
    using (var client = new WebClient())
    {
    client.Proxy = null;
    if (!client.IsBusy)
    {
    linkString = client.DownloadString(new Uri(link));
    }
    }
    }
    catch { }
    return linkString;
    }

    // Список СНГ стран
    private static List<string> countryList = new List<string>
    {
    "Russia",
    "Azerbaijan",
    "Armenia",
    "Belorus",
    "Kazakhstan",
    "Kyrgyzstan",
    "Moldova",
    "Tajikistan",
    "Turkmenistan",
    "Uzbekistan",
    "Ukraine",
    "Georgia",
    };

    // Проверка по списку
    public static bool Country()
    {
    foreach (string list in countryList)
    {
    if (country.Contains(list))
    {
    return false;
    }
    break;
    }
    return true;
    }
    #endregion
    }
    }
     
Top
Loading...