- Katılım
- 11 Nis 2022
- Mesajlar
- 260
- Beğeniler
- 151
Her zaman görüyorum forumda (arkadaşlar loaderime keyauth nasıl eklerim login sistemi nasıl eklerim) yazıyolar boşu boşuna elin gavuruna authu teslim etmeyin kendi altyapınızı kullanın güvenlik önlemlerini açıklarını siz kapatırsınız diye en basit TCP auth vereceğim dilediğiniz gibi değiştirip yenileyip paylaşıp kullanabilirsiniz.
TCP SERVER SIDE ->
TCP CLIENT SIDE ->
0x58b tavsiyeni kullandım daha güzel gözüküyor artık
TCP SERVER SIDE ->
C#:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
class Program
{
const int port = 3131;
static Dictionary<string, string> validKeys = new Dictionary<string, string>();
static string keys = "keys.txt";
static bool run = true;
static void Main(string[] args)
{
Thread keyReloadThread = new Thread(ReloadKeys);
keyReloadThread.Start();
TcpListener server = null;
try
{
server = new TcpListener(IPAddress.Any, port);
server.Start();
Console.WriteLine("SERVER OPEN!");
while (run)
{
TcpClient client = server.AcceptTcpClient();
NetworkStream stream = client.GetStream();
byte[] buffer = new byte[256];
int bytesRead = stream.Read(buffer, 0, buffer.Length);
string receivedData = Encoding.ASCII.GetString(buffer, 0, bytesRead);
if (receivedData.Contains(":"))
{
string[] parts = receivedData.Split(':');
string receivedKey = parts[0];
string receivedHwid = parts[1];
if (string.IsNullOrWhiteSpace(receivedKey))
{
client.Close();
continue;
}
if (validKeys.ContainsKey(receivedKey))
{
if (validKeys[receivedKey] == receivedHwid)
{
byte[] response = Encoding.ASCII.GetBytes("AUTH_SUCCESS");
stream.Write(response, 0, response.Length);
Console.WriteLine("Başarılı");
}
else
{
byte[] response = Encoding.ASCII.GetBytes("AUTH_FAILED");
stream.Write(response, 0, response.Length);
Console.WriteLine("Başarısız");
}
}
else
{
hwidup(receivedKey, receivedHwid);
byte[] response = Encoding.ASCII.GetBytes("AUTH_SUCCESS_WITH_HWID_UPDATE");
stream.Write(response, 0, response.Length);
Console.WriteLine("Başarılı");
}
}
else
{
byte[] response = Encoding.ASCII.GetBytes("INVALID_FORMAT");
stream.Write(response, 0, response.Length);
Console.WriteLine("Başarısız");
}
client.Close();
}
}
catch (Exception e)
{
}
finally
{
server?.Stop();
run = false;
}
}
static void ReloadKeys()
{
while (run)
{
try
{
Dictionary<string, string> newKeys = new Dictionary<string, string>();
foreach (var line in File.ReadAllLines(keys))
{
if (line.Contains(":"))
{
var parts = line.Split(':');
newKeys[parts[0]] = parts[1]; // key:hwid
}
}
validKeys = newKeys;
}
catch (Exception e)
{
}
Thread.Sleep(2000);
}
}
static void hwidup(string key, string hwid)
{
try
{
List<string> lines = new List<string>(File.ReadAllLines(keys));
for (int i = 0; i < lines.Count; i++)
{
if (lines[i].Trim() == key)
{
lines[i] = $"{key}:{hwid}";
break;
}
}
File.WriteAllLines(keys, lines.ToArray());
}
catch (Exception e)
{
}
}
}
TCP CLIENT SIDE ->
C#:
using System;
using System.Net.Sockets;
using System.Text;
using System.Management;
class Program
{
const int port = 3131;
const string ip = "127.0.0.1";
const int retryDelay = 100;
static void Main(string[] args)
{
try
{
string hwid = hw();
Console.Write("key: ");
string authKey = Console.ReadLine();
TcpClient client = new TcpClient(ip, port);
NetworkStream stream = client.GetStream();
string authMessage = $"{authKey}:{hwid}";
byte[] authMessageBytes = Encoding.ASCII.GetBytes(authMessage);
stream.Write(authMessageBytes, 0, authMessageBytes.Length);
byte[] buffer = new byte[256];
int bytesRead = stream.Read(buffer, 0, buffer.Length);
string serverResponse = Encoding.ASCII.GetString(buffer, 0, bytesRead);
Console.WriteLine(serverResponse);
client.Close();
}
catch (SocketException)
{
Thread.Sleep(retryDelay);
}
catch (Exception e)
{
}
}
static string hw()
{
string hwid = "";
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT ProcessorId FROM Win32_Processor");
foreach (ManagementObject obj in searcher.Get())
{
hwid = obj["ProcessorId"].ToString();
break;
}
return hwid;
}
}
0x58b tavsiyeni kullandım daha güzel gözüküyor artık