Загрузка...

Binding for iron for a while and protecting your project

Thread in C# created by Cacich Jun 29, 2018. 4746 views

  1. Cacich
    Cacich Topic starter Jun 29, 2018 Banned 106 May 6, 2018
    !!! ГАЙД ДЛЯ НОВИЧКОВ !!!

    Привет, уважаемый форумчанин. Сегодня я расскажу тебе, как сделать привязку по железу, через MySQL.

    Что нас с тобой понадобиться?
    1. Visual Studio
    2. База данных MySQL (можешь протестировать на локальной)
    3. Софт для защиты нашего проекта: Themida и т.п. (я буду использовать .NET Reactor)
    Шаг 1. Создание проекта и проектирование макета.

    1. Создаём новый проект WinForms или WPF (я использую WPF).
    2. Добавляем нужные нам контролы, в моём случае это выглядит так
      [IMG]
    Шаг 2. HWID пользователя.

    1. Создаём событие на загрузку формы
    2. Добавляем в него следующее
      Code
       
      Value();
      string hwid = fingerPrint;
      hwid = HashGo(hwid.ToString());
      txtHwid.Text = hwid; // название TextBox`a
    3. Добавляем кучу кода вне нашего события
      Code

      private bool status = false;
      private static string fingerPrint = string.Empty;
      public static string Value()
      {
      if (string.IsNullOrEmpty(fingerPrint))
      {
      fingerPrint = GetHash("CPU >> " + cpuId() + "\nBIOS >> " +
      biosId() + "\nBASE >> " + baseId() + videoId() + "\nMAC >> " + macId());
      }
      return fingerPrint;
      }
      private static string GetHash(string s)
      {
      MD5 sec = new MD5CryptoServiceProvider();
      ASCIIEncoding enc = new ASCIIEncoding();
      byte[] bt = enc.GetBytes(s);
      return GetHexString(sec.ComputeHash(bt));
      }
      private static string GetHexString(byte[] bt)
      {
      string s = string.Empty;
      for (int i = 0; i < bt.Length; i++)
      {
      byte b = bt[i];
      int n, n1, n2;
      n = (int)b;
      n1 = n & 15;
      n2 = (n >> 4) & 15;
      if (n2 > 9)
      s += ((char)(n2 - 10 + (int)'A')).ToString();
      else
      s += n2.ToString();
      if (n1 > 9)
      s += ((char)(n1 - 10 + (int)'A')).ToString();
      else
      s += n1.ToString();
      if ((i + 1) != bt.Length && (i + 1) % 2 == 0) s += "-";
      }
      return s;
      }
      private static string identifier (string wmiClass, string wmiProperty, string wmiMustBeTrue)
      {
      string result = "";
      System.Management.ManagementClass mc =
      new System.Management.ManagementClass(wmiClass);
      System.Management.ManagementObjectCollection moc = mc.GetInstances();
      foreach (System.Management.ManagementObject mo in moc)
      {
      if (mo[wmiMustBeTrue].ToString() == "True")
      {
      //Only get the first one
      if (result == "")
      {
      try
      {
      result = mo[wmiProperty].ToString();
      break;
      }
      catch
      {
      }
      }
      }
      }
      return result;
      }
      private static string identifier(string wmiClass, string wmiProperty)
      {
      string result = "";
      System.Management.ManagementClass mc =
      new System.Management.ManagementClass(wmiClass);
      System.Management.ManagementObjectCollection moc = mc.GetInstances();
      foreach (System.Management.ManagementObject mo in moc)
      {
      //Only get the first one
      if (result == "")
      {
      try
      {
      result = mo[wmiProperty].ToString();
      break;
      }
      catch
      {
      }
      }
      }
      return result;
      }
      private static string cpuId()
      {
      string retVal = identifier("Win32_Processor", "UniqueId");
      if (retVal == "")
      {
      retVal = identifier("Win32_Processor", "ProcessorId");
      if (retVal == "")
      {
      retVal = identifier("Win32_Processor", "Name");
      if (retVal == "")
      {
      retVal = identifier("Win32_Processor", "Manufacturer");
      }
      retVal += identifier("Win32_Processor", "MaxClockSpeed");
      }
      }
      return retVal;
      }
      private static string biosId()
      {
      return identifier("Win32_BIOS", "Manufacturer")
      + identifier("Win32_BIOS", "SMBIOSBIOSVersion")
      + identifier("Win32_BIOS", "IdentificationCode")
      + identifier("Win32_BIOS", "SerialNumber")
      + identifier("Win32_BIOS", "ReleaseDate")
      + identifier("Win32_BIOS", "Version");
      }
      private static string diskId()
      {
      return identifier("Win32_DiskDrive", "Model")
      + identifier("Win32_DiskDrive", "Manufacturer")
      + identifier("Win32_DiskDrive", "Signature")
      + identifier("Win32_DiskDrive", "TotalHeads");
      }
      private static string baseId()
      {
      return identifier("Win32_BaseBoard", "Model")
      + identifier("Win32_BaseBoard", "Manufacturer")
      + identifier("Win32_BaseBoard", "Name")
      + identifier("Win32_BaseBoard", "SerialNumber");
      }
      private static string videoId()
      {
      return identifier("Win32_VideoController", "DriverVersion")
      + identifier("Win32_VideoController", "Name");
      }
      private static string macId()
      {
      return identifier("Win32_NetworkAdapterConfiguration",
      "MACAddress", "IPEnabled");
      }
    4. И ещё вот это добавляем
      Code

      static string HashGo(string input)
      {
      MD5 md5 = System.Security.Cryptography.MD5.Create();
      byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
      byte[] hash = md5.ComputeHash(inputBytes);
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < hash.Length; i++)
      {
      sb.Append(hash[i].ToString("X2"));
      }
      return sb.ToString();
      }
    Шаг 3. MySQL и привязка.

    Кидаем в событие загрузки этот код
    Code

    string connStr = $"server=%host%;user=&username%;database=%database%;password=%password%;";
    MySqlConnection conn = new MySqlConnection(connStr);
    conn.Open();

    DateTime d1;
    try
    {
    string sql = $"SELECT subscribe FROM myusers WHERE hwid = '{hwid}'";
    MySqlCommand command = new MySqlCommand(sql, conn);
    string date = command.ExecuteScalar().ToString();

    var client = new TcpClient("time.nist.gov", 13);
    using (var streamReader = new StreamReader(client.GetStream()))
    {
    var response = streamReader.ReadToEnd();
    var utcDateTimeString = response.Substring(7, 17);
    d1 = DateTime.ParseExact(utcDateTimeString, "yy-MM-dd **:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
    }

    DateTime d2 = Convert.ToDateTime(date);
    TimeSpan time = d2 - d1;

    int days = time.Days;

    if(days > 0)
    {
    btnLic.Content = $"Осталось {days} дней подписки";
    btnLic.Background = clrGood.Background;
    btnLic.BorderBrush = clrGood.Background;
    btnBuyOrStart.Content = "Запустить";
    status = true;
    }
    }
    catch(Exception ex) {
    btnLic.Content = "Не удалось подключиться";
    }

    НЕ ЗАБУДЬТЕ ПОМЕНЯТЬ ЗНАЧЕНИЯ ДЛЯ ВАШЕЙ БАЗЫ ДАННЫХ.

    Шаг 4. Настройка базы данных.

    1. Создаём таблицу myusers
    2. Добавляем в неё id (int)
    3. hwid (char)
    4. subcribe (date)
    Всё готово, разбирайтесь, сурцы дам позже.
     
  2. Astra_inactive
    Astra_inactive Jun 29, 2018 Banned 3 Jan 2, 2017
    Ха-Ха, мне интересно, где тут защита? То что сделал шифрование в MD5 ничего не даст.
     
  3. swmf
    swmf Jun 29, 2018 101 Dec 8, 2017
    на сишурпе уже миллион примеров есть всего чего только можно придумать, было бы интересно посмотреть реализации на других языках
     
  4. Cacich
    Cacich Topic starter Jun 29, 2018 Banned 106 May 6, 2018
    1. Софт для защиты нашего проекта: Themida и т.п. (я буду использовать .NET Reactor) :thinking:
     
  5. Cacich
    Cacich Topic starter Jun 29, 2018 Banned 106 May 6, 2018
    Например?
     
  6. swmf
    swmf Jun 29, 2018 101 Dec 8, 2017
    Cacich, си, плюсы или на дельфине
     
  7. Cacich
    Cacich Topic starter Jun 30, 2018 Banned 106 May 6, 2018
    MahApp metro + Material Design Xaml ToolKit
    (WPF)
     
  8. VARVAR_inactive49861
    пфф, быдло кожу тока на dtlphi, на си шарпе вообще 0, =D
     
  9. Astra_inactive
    Astra_inactive Jun 30, 2018 Banned 3 Jan 2, 2017
    Cacich, бро, темида тебе не поможет, её реверсер нормальный снимет за пару минут, и панельку авторизации тоже снимут быстро
     
  10. Cacich
    Cacich Topic starter Jun 30, 2018 Banned 106 May 6, 2018
    боже, братан, я же нигде не писал, что никто и никогда не реверснет софт, это нереально..
    любой софт можно реверснуть, просто если он под протектом - это мало кому доставит удовольствия
    хорош тебе докапываться, я показал примитивный пример привязки .-.
     
Top
Loading...