Advertisement
BaSs_HaXoR

(C#) XenonKerbAuthenticator Source Code

Jan 28th, 2017
1,678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 23.28 KB | None | 0 0
  1. //[IMG] http://prntscr.com/e1d56t
  2. //credits: '"Tool made by CamxxCore  Credit to the creator of the original KV Checker tool for the KV checking code"'.
  3.  
  4. using System;
  5. using System.Diagnostics;
  6. using System.Reflection;
  7. using System.Runtime.CompilerServices;
  8. using System.Runtime.InteropServices;
  9. using System.Runtime.Versioning;
  10.  
  11. /*
  12. [assembly: AssemblyVersion("1.0.0.0")]
  13. [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
  14. [assembly: AssemblyCompany("")]
  15. [assembly: AssemblyConfiguration("")]
  16. [assembly: AssemblyCopyright("Copyright ©  2014")]
  17. [assembly: AssemblyDescription("")]
  18. [assembly: AssemblyFileVersion("1.0.0.0")]
  19. [assembly: AssemblyProduct("WindowsFormsApplication2")]
  20. [assembly: AssemblyTitle("WindowsFormsApplication2")]
  21. [assembly: AssemblyTrademark("")]
  22. [assembly: CompilationRelaxations(8)]
  23. [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
  24. [assembly: ComVisible(false)]
  25. [assembly: Guid("c05ce401-3196-482b-803e-c6cef4b1a9a7")]
  26. [assembly: TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4")]
  27. */
  28. // Entry point: XenonKerbAuthenticator.Program.Main
  29. // Architecture: x86
  30. // Runtime: .NET 4.0
  31.  
  32. using Core;
  33. using System;
  34. using System.IO;
  35. using System.Net;
  36. using System.Net.Sockets;
  37. using System.Security.Cryptography;
  38. using System.Text;
  39. using System.Threading;
  40. using System.Windows.Forms;
  41. namespace XenonKerbAuthenticator
  42. {
  43.     internal class Program
  44.     {
  45.             private bool banned;
  46.             ////////////////////////////////////////////////////////////////////////////
  47.            
  48.        
  49.             private static string[] pwnd;
  50.             private static void addtoArray(string[] array, string input)
  51.             {
  52.                 Array.Resize(ref array, array.Length + 1);
  53.                 array[array.Length - 1] = input;
  54.             }
  55.             private static string convByteArrToStr(byte[] array)
  56.             {
  57.                 string tmp = Encoding.UTF8.GetString(array);
  58.                 return tmp;
  59.             }
  60.  
  61.             public static string ToHex(this byte[] bytes, bool upperCase)
  62.             {
  63.                 StringBuilder result = new StringBuilder(bytes.Length*2);
  64.  
  65.                 for (int i = 0; i < bytes.Length; i++)
  66.                     result.Append(bytes[i].ToString(upperCase ? "X2" : "x2"));
  67.  
  68.                 return result.ToString();
  69.             }
  70.  
  71.         private static string path = AppDomain.CurrentDomain.BaseDirectory + "KVs\\";
  72.         public TextWriter textWriter = new StreamWriter(Program.path + "log.txt");
  73.         private static void LogonFromTicketCache()
  74.         {
  75.             ///////////////////////////////////////////////////////////////////////////
  76.             addtoArray(pwnd, "pwnd.strt");
  77.            
  78.             ///////////////////////////////////////////////////////////////////////////
  79.             AppDomain.CurrentDomain.BaseDirectory + "KVs\\";
  80.             string str = AppDomain.CurrentDomain.BaseDirectory + "\\files";
  81.             EndianIO endianIO = new EndianIO(str + "kerb_ticket.bin", 1);
  82.             endianIO.get_Reader().BaseStream.Position = 212L;
  83.  
  84.             ///////////////////////////////////////////////////////////////////////////1
  85.             byte[] key = endianIO.get_Reader().ReadBytes(16);
  86.             addtoArray(pwnd, "key: " + convByteArrToStr(key));
  87.  
  88.             ///////////////////////////////////////////////////////////////////////////2
  89.             endianIO.get_Reader().BaseStream.Position = 318L;
  90.             byte[] sourceArray = endianIO.get_Reader().ReadBytes(345);
  91.             addtoArray(pwnd, "Source Array: " + convByteArrToStr(sourceArray));
  92.  
  93.             ///////////////////////////////////////////////////////////////////////////3
  94.             byte[] array = File.ReadAllBytes(str + "TGSREQ.bin");
  95.             addtoArray(pwnd, "TGSREQ.bin: " + convByteArrToStr(array));
  96.            
  97.             ///////////////////////////////////////////////////////////////////////////4
  98.             Array.Copy(sourceArray, 0, array, 437, 345);
  99.             addtoArray(pwnd, "array: " + convByteArrToStr(array));
  100.             byte[] array2 = File.ReadAllBytes(str + "authenticator.bin");
  101.             addtoArray(pwnd, "authenticator.bin: " + convByteArrToStr(array2));
  102.            
  103.             ///////////////////////////////////////////////////////////////////////////5
  104.             byte[] passHash = MD5.Create().ComputeHash(array, 954, 75);
  105.             addtoArray(pwnd, "MD5passHash: " + BitConverter.ToString(passHash).Replace("-",""));
  106.  
  107.             ///////////////////////////////////////////////////////////////////////////6
  108.             Encoding aSCII = Encoding.ASCII;
  109.             string s = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmssZ");
  110.             Array.Copy(aSCII.GetBytes(s), 0, array2, 109, 15);
  111.  
  112.             addtoArray(pwnd, "array2 + (Year|Month|Day|Hours|Minutes|Seconds): " + convByteArrToStr(array2));
  113.  
  114.             ///////////////////////////////////////////////////////////////////////////5
  115.             Array.Copy(Program.RC4HMACEncrypt(key, 16, array2, array2.Length, 7), 0, array, 799, 153);
  116.             addtoArray(pwnd, "(RC4HMACEncrypted) key: " + convByteArrToStr(key) + " | (RC4HMACEncrypted) array: " + array);
  117.  
  118.             ///////////////////////////////////////////////////////////////////////////
  119.             byte[] key2 = Program.ComputeKdcNoonce(key, 16);
  120.             addtoArray(pwnd, "RC4HMACEncrypted: " + convByteArrToStr(key) + "array: " + array2 + "array2: " + array);
  121.            
  122.             ///////////////////////////////////////////////////////////////////////////
  123.             byte[] data = File.ReadAllBytes(str + "servicereq.bin");
  124.             addtoArray(pwnd, "servicereq.bin: " + convByteArrToStr(data));
  125.  
  126.             ///////////////////////////////////////////////////////////////////////////
  127.             Array.Copy(Program.RC4HMACEncrypt(key2, 16, data, 126, 1201), 0, array, 55, 150);
  128.             addtoArray(pwnd, "servicereq.bin: " + convByteArrToStr(data));
  129.  
  130.             ///////////////////////////////////////////////////////////////////////////
  131.             byte[] sourceArray2 = File.ReadAllBytes(str + "apreq2.bin");
  132.             addtoArray(pwnd, "servicereq.bin: " + convByteArrToStr(data));
  133.            
  134.             ///////////////////////////////////////////////////////////////////////////
  135.             byte[] array3 = new byte[66];
  136.             addtoArray(pwnd, "array3: " + convByteArrToStr(array3));
  137.            
  138.             ///////////////////////////////////////////////////////////////////////////
  139.             Array.Copy(sourceArray2, 116, array3, 0, 66);
  140.             addtoArray(pwnd, "Array3: " + convByteArrToStr(array3));
  141.            
  142.             ///////////////////////////////////////////////////////////////////////////
  143.             Array.Copy(Program.GetTitleAuthData(key, 16, array3), 0, array, 221, 82);
  144.             addtoArray(pwnd, "servicereq.bin: " + convByteArrToStr(data));
  145.            
  146.             ///////////////////////////////////////////////////////////////////////////
  147.             System.Net.Sockets.UdpClient udpClient = new System.Net.Sockets.UdpClient(88);
  148.             udpClient.Connect("XETGS.XBOXLIVE.COM", 88);
  149.             udpClient.Send(array, array.Length);
  150.             System.Net.IPEndPoint iPEndPoint = new System.Net.IPEndPoint(0L, 0);
  151.             byte[] array4 = udpClient.Receive(ref iPEndPoint);
  152.             File.WriteAllBytes(str + "tgsresp.bin", array4);
  153.             udpClient.Close();
  154.             byte[] array5 = new byte[84];
  155.             Array.Copy(array4, 50, array5, 0, 84);
  156.             BitConverter.ToUInt32(Program.RC4HMACDecrypt(key2, 16, array5, 84, 1202), 8);
  157.         }
  158.         private static byte[] Reverse8(byte[] input)
  159.         {
  160.             byte[] array = new byte[input.Length];
  161.             int num = input.Length - 8;
  162.             int num2 = 0;
  163.             for (int i = 0; i < input.Length / 8; i++)
  164.             {
  165.                 for (int j = 0; j < 8; j++)
  166.                 {
  167.                     array[num2 + j] = input[num + j];
  168.                 }
  169.                 num -= 8;
  170.                 num2 += 8;
  171.             }
  172.             return array;
  173.         }
  174.         private static RSACryptoServiceProvider LoadXmacsKey()
  175.         {
  176.             EndianIO endianIO = new EndianIO(RSAKeys.XMACS_RSA_PUB2048, 1);
  177.             endianIO.set_Position(4L);
  178.             byte[] exponent = endianIO.get_Reader().ReadBytes(4);
  179.             endianIO.set_Position(16L);
  180.             byte[] modulus = Program.Reverse8(endianIO.get_Reader().ReadBytes(256));
  181.             RSAParameters parameters = default(RSAParameters);
  182.             parameters.Exponent = exponent;
  183.             parameters.Modulus = modulus;
  184.             RSACryptoServiceProvider rSACryptoServiceProvider = new RSACryptoServiceProvider();
  185.             rSACryptoServiceProvider.ImportParameters(parameters);
  186.             return rSACryptoServiceProvider;
  187.         }
  188.         private static RSACryptoServiceProvider LoadConsolePrivateKey(byte[] Exponent, byte[] KeyParams)
  189.         {
  190.             RSACryptoServiceProvider rSACryptoServiceProvider = new RSACryptoServiceProvider();
  191.             try
  192.             {
  193.                 EndianIO endianIO = new EndianIO(KeyParams, 1);
  194.                 byte[] modulus = Program.Reverse8(endianIO.get_Reader().ReadBytes(128));
  195.                 byte[] p = Program.Reverse8(endianIO.get_Reader().ReadBytes(64));
  196.                 byte[] q = Program.Reverse8(endianIO.get_Reader().ReadBytes(64));
  197.                 byte[] dP = Program.Reverse8(endianIO.get_Reader().ReadBytes(64));
  198.                 byte[] dQ = Program.Reverse8(endianIO.get_Reader().ReadBytes(64));
  199.                 byte[] inverseQ = Program.Reverse8(endianIO.get_Reader().ReadBytes(64));
  200.                 RSAParameters parameters = default(RSAParameters);
  201.                 parameters.Exponent = Exponent;
  202.                 parameters.Modulus = modulus;
  203.                 parameters.P = p;
  204.                 parameters.Q = q;
  205.                 parameters.DP = dP;
  206.                 parameters.DQ = dQ;
  207.                 parameters.InverseQ = inverseQ;
  208.                 parameters.D = new byte[128];
  209.                 new Random(Environment.TickCount).NextBytes(parameters.D);
  210.                 rSACryptoServiceProvider.ImportParameters(parameters);
  211.             }
  212.             catch (Exception arg)
  213.             {
  214.                 MessageBox.Show("Sorry, an invalid .bin file was found in the file list\nPlease remove the file and restart the application\n\n" + arg, "Invalid Keyvault File");
  215.             }
  216.             return rSACryptoServiceProvider;
  217.         }
  218.         private static byte[] GetXmacsLogonKey(string fileName)
  219.         {
  220.             string str = AppDomain.CurrentDomain.BaseDirectory + "\\files\\";
  221.             RSACryptoServiceProvider rSACryptoServiceProvider = Program.LoadXmacsKey();
  222.             byte[] array = new byte[16];
  223.             new Random(Environment.TickCount).NextBytes(array);
  224.             byte[] array2 = rSACryptoServiceProvider.Encrypt(array, true);
  225.             Array.Reverse(array2);
  226.             byte[] array3 = File.ReadAllBytes(str + "XMACSREQ.bin");
  227.             Array.Copy(array2, 0, array3, 44, 256);
  228.             EndianIO endianIO = new EndianIO(fileName, 1);
  229.             endianIO.set_Position(176L);
  230.             byte[] array4 = endianIO.get_Reader().ReadBytes(12);
  231.             endianIO.set_Position(2504L);
  232.             byte[] sourceArray = endianIO.get_Reader().ReadBytes(424);
  233.             endianIO.set_Position(668L);
  234.             byte[] exponent = endianIO.get_Reader().ReadBytes(4);
  235.             endianIO.set_Position(680L);
  236.             byte[] keyParams = endianIO.get_Reader().ReadBytes(448);
  237.             endianIO.set_Position(2506L);
  238.             byte[] consoleId = endianIO.get_Reader().ReadBytes(5);
  239.             endianIO.Close();
  240.             byte[] sourceArray2 = Program.ComputeClientName(consoleId);
  241.             RSACryptoServiceProvider key = Program.LoadConsolePrivateKey(exponent, keyParams);
  242.             byte[] bytes = BitConverter.GetBytes(DateTime.UtcNow.ToFileTime());
  243.             Array.Reverse(bytes);
  244.             byte[] array5 = Program.GenerateTimeStamp();
  245.             byte[] sourceArray3 = Program.RC4HMACEncrypt(array, 16, array5, array5.Length, 1);
  246.             byte[] inputBuffer = SHA1.Create().ComputeHash(array);
  247.             SHA1CryptoServiceProvider sHA1CryptoServiceProvider = new SHA1CryptoServiceProvider();
  248.             sHA1CryptoServiceProvider.TransformBlock(bytes, 0, 8, null, 0);
  249.             byte[] array6 = new byte[16];
  250.             try
  251.             {
  252.                 sHA1CryptoServiceProvider.TransformBlock(array4, 0, 12, null, 0);
  253.                 sHA1CryptoServiceProvider.TransformFinalBlock(inputBuffer, 0, 20);
  254.                 byte[] hash = sHA1CryptoServiceProvider.Hash;
  255.                 RSAPKCS1SignatureFormatter rSAPKCS1SignatureFormatter = new RSAPKCS1SignatureFormatter(key);
  256.                 rSAPKCS1SignatureFormatter.SetHashAlgorithm("SHA1");
  257.                 byte[] array7 = rSAPKCS1SignatureFormatter.CreateSignature(hash);
  258.                 Array.Reverse(array7);
  259.                 Array.Copy(bytes, 0, array3, 300, 8);
  260.                 Array.Copy(array4, 0, array3, 308, 12);
  261.                 Array.Copy(array7, 0, array3, 320, 128);
  262.                 Array.Copy(sourceArray, 0, array3, 448, 424);
  263.                 Array.Copy(sourceArray3, 0, array3, 992, 52);
  264.                 Array.Copy(sourceArray2, 0, array3, 1072, 15);
  265.                 System.Net.Sockets.UdpClient udpClient = new System.Net.Sockets.UdpClient();
  266.                 udpClient.Connect("XEAS.XBOXLIVE.COM", 88);
  267.                 udpClient.Send(array3, array3.Length);
  268.                 System.Net.IPEndPoint iPEndPoint = new System.Net.IPEndPoint(0L, 0);
  269.                 int num = 0;
  270.                 while (true)
  271.                 {
  272.                     Thread.Sleep(10);
  273.                     if (udpClient.Available > 0)
  274.                     {
  275.                         break;
  276.                     }
  277.                     Thread.Sleep(500);
  278.                     num++;
  279.                     if (num == 10)
  280.                     {
  281.                         goto Block_4;
  282.                     }
  283.                 }
  284.                 byte[] sourceArray4 = udpClient.Receive(ref iPEndPoint);
  285.                 byte[] array8 = new byte[108];
  286.                 Array.Copy(sourceArray4, 53, array8, 0, 108);
  287.                 byte[] sourceArray5 = Program.RC4HMACDecrypt(Program.ComputeKdcNoonce(array, 16), 16, array8, 108, 1203);
  288.                 Array.Copy(sourceArray5, 76, array6, 0, 16);
  289.                 return array6;
  290.                 Block_4:
  291.                 return null;
  292.             }
  293.             catch (Exception var_28_2DD)
  294.             {
  295.             }
  296.             return array6;
  297.         }
  298.         [STAThread]
  299.         private static void Main(string[] args)
  300.         {
  301.             new Form1();
  302.             Application.EnableVisualStyles();
  303.             Application.Run(new Form1());
  304.         }
  305.         public void getStatus(string str2)
  306.         {
  307.             DateTime now = DateTime.Now;
  308.             string str3 = AppDomain.CurrentDomain.BaseDirectory + "KVs\\";
  309.             string str4 = AppDomain.CurrentDomain.BaseDirectory + "\\files\\";
  310.             Directory.GetFiles(str3);
  311.             Directory.GetDirectories(str3);
  312.             if (!(str2 == str3 + "log.txt"))
  313.             {
  314.                 byte[] xmacsLogonKey = Program.GetXmacsLogonKey(str2);
  315.                 if (xmacsLogonKey == null)
  316.                 {
  317.                     this.textWriter.WriteLine("GetXmacsLogonKey timed out. Trying one more time...");
  318.                     xmacsLogonKey = Program.GetXmacsLogonKey(str2);
  319.                     if (xmacsLogonKey == null)
  320.                     {
  321.                         this.textWriter.WriteLine(str2 + ": skipped");
  322.                         return;
  323.                     }
  324.                 }
  325.                 EndianIO endianIO = new EndianIO(str2, 1);
  326.                 endianIO.get_Reader().BaseStream.Position = 2506L;
  327.                 byte[] consoleId = endianIO.get_Reader().ReadBytes(5);
  328.                 endianIO.get_Reader().BaseStream.Position = 2504L;
  329.                 byte[] sourceArray = SHA1.Create().ComputeHash(endianIO.get_Reader().ReadBytes(168));
  330.                 byte[] array = File.ReadAllBytes(str4 + "apreq1.bin");
  331.                 byte[] array2 = Program.ComputeClientName(consoleId);
  332.                 this.textWriter.WriteLine("Attempting logon for \"" + Encoding.ASCII.GetString(array2) + "\"...");
  333.                 this.textWriter.WriteLine("Creating Kerberos AS-REQ...");
  334.                 Array.Copy(array2, 0, array, 258, 24);
  335.                 Array.Copy(sourceArray, 0, array, 36, 20);
  336.                 byte[] array3 = Program.GenerateTimeStamp();
  337.                 Array.Copy(Program.RC4HMACEncrypt(xmacsLogonKey, 16, array3, array3.Length, 1), 0, array, 176, 52);
  338.                 System.Net.Sockets.UdpClient udpClient = new System.Net.Sockets.UdpClient();
  339.                 udpClient.Connect("XEAS.gtm.XBOXLIVE.COM", 88);
  340.                 udpClient.Send(array, array.Length);
  341.                 this.textWriter.WriteLine("Sending Kerberos AS-REQ...");
  342.                 System.Net.IPEndPoint iPEndPoint = new System.Net.IPEndPoint(0L, 0);
  343.                 byte[] array4;
  344.                 try
  345.                 {
  346.                     while (true)
  347.                     {
  348.                         IL_1C4:
  349.                         Thread.Sleep(10);
  350.                         if (udpClient.Available > 0)
  351.                         {
  352.                             break;
  353.                         }
  354.                         udpClient.Send(array, array.Length);
  355.                     }
  356.                     array4 = udpClient.Receive(ref iPEndPoint);
  357.                 }
  358.                 catch (Exception var_13_1F2)
  359.                 {
  360.                     goto IL_1C4;
  361.                 }
  362.                 udpClient.Close();
  363.                 this.textWriter.WriteLine("AS replied wanting pre-auth data...");
  364.                 this.textWriter.WriteLine("Creating new Kerberos AS-REQ...");
  365.                 byte[] array5 = new byte[16];
  366.                 Array.Copy(array4, array4.Length - 16, array5, 0, 16);
  367.                 byte[] array6 = File.ReadAllBytes(str4 + "apreq2.bin");
  368.                 Array.Copy(array2, 0, array6, 286, 24);
  369.                 Array.Copy(sourceArray, 0, array6, 36, 20);
  370.                 byte[] array7 = Program.GenerateTimeStamp();
  371.                 Array.Copy(Program.RC4HMACEncrypt(xmacsLogonKey, 16, array7, array7.Length, 1), 0, array6, 204, 52);
  372.                 Array.Copy(array5, 0, array6, 68, 16);
  373.                 System.Net.Sockets.UdpClient udpClient2 = new System.Net.Sockets.UdpClient();
  374.                 udpClient2.Connect("XEAS.XBOXLIVE.COM", 88);
  375.                 udpClient2.Send(array6, array6.Length);
  376.                 this.textWriter.WriteLine("Sending Kerberos AS-REQ...");
  377.                 byte[] array8;
  378.                 try
  379.                 {
  380.                     while (true)
  381.                     {
  382.                         IL_2D0:
  383.                         Thread.Sleep(10);
  384.                         if (udpClient2.Available > 0)
  385.                         {
  386.                             break;
  387.                         }
  388.                         Thread.Sleep(50);
  389.                         udpClient2.Send(array6, array6.Length);
  390.                     }
  391.                     array8 = udpClient2.Receive(ref iPEndPoint);
  392.                 }
  393.                 catch (Exception var_19_305)
  394.                 {
  395.                     goto IL_2D0;
  396.                 }
  397.                 udpClient2.Close();
  398.                 File.WriteAllBytes(str4 + "APRESP.bin", array8);
  399.                 this.textWriter.WriteLine("Got AS-REP...");
  400.                 this.textWriter.WriteLine("Decrypting our session key...");
  401.                 this.textWriter.WriteLine("Creating Kerberos TGS-REQ...");
  402.                 byte[] array9 = new byte[210];
  403.                 Array.Copy(array8, array8.Length - 210, array9, 0, 210);
  404.                 byte[] array10 = Program.RC4HMACDecrypt(xmacsLogonKey, 16, array9, 210, 8);
  405.                 byte[] array11 = new byte[16];
  406.                 File.WriteAllBytes(str4 + "test.bin", array10);
  407.                 Array.Copy(array10, 27, array11, 0, 16);
  408.                 this.textWriter.WriteLine("Setting TGS ticket...");
  409.                 byte[] array12 = new byte[345];
  410.                 Array.Copy(array8, 168, array12, 0, 345);
  411.                 byte[] array13 = File.ReadAllBytes(str4 + "TGSREQ.bin");
  412.                 Array.Copy(array12, 0, array13, 437, 345);
  413.                 byte[] array14 = File.ReadAllBytes(str4 + "authenticator.bin");
  414.                 Array.Copy(array2, 0, array14, 40, 15);
  415.                 Encoding aSCII = Encoding.ASCII;
  416.                 string s = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmssZ");
  417.                 Array.Copy(aSCII.GetBytes(s), 0, array14, 109, 15);
  418.                 Array.Copy(MD5.Create().ComputeHash(array13, 954, 75), 0, array14, 82, 16);
  419.                 Array.Copy(Program.RC4HMACEncrypt(array11, 16, array14, array14.Length, 7), 0, array13, 799, 153);
  420.                 byte[] key = Program.ComputeKdcNoonce(array11, 16);
  421.                 byte[] array15 = File.ReadAllBytes(str4 + "servicereq.bin");
  422.                 Array.Copy(Program.RC4HMACEncrypt(key, 16, array15, array15.Length, 1201), 0, array13, 55, 150);
  423.                 byte[] array16 = new byte[66];
  424.                 Array.Copy(array6, 116, array16, 0, 66);
  425.                 Array.Copy(Program.GetTitleAuthData(array11, 16, array16), 0, array13, 221, 82);
  426.                 this.textWriter.WriteLine("Sending our TGS-REQ...");
  427.                 System.Net.Sockets.UdpClient udpClient3 = new System.Net.Sockets.UdpClient();
  428.                 udpClient3.Connect("XETGS.XBOXLIVE.COM", 88);
  429.                 udpClient3.Send(array13, array13.Length);
  430.                 iPEndPoint = new System.Net.IPEndPoint(0L, 0);
  431.                 byte[] array17;
  432.                 try
  433.                 {
  434.                     while (true)
  435.                     {
  436.                         IL_551:
  437.                         Thread.Sleep(10);
  438.                         if (udpClient3.Available > 0)
  439.                         {
  440.                             break;
  441.                         }
  442.                         Thread.Sleep(50);
  443.                         this.textWriter.WriteLine("server timeout.. retrying...");
  444.                         udpClient3.Send(array13, array13.Length);
  445.                     }
  446.                     array17 = udpClient3.Receive(ref iPEndPoint);
  447.                 }
  448.                 catch (Exception var_34_596)
  449.                 {
  450.                     goto IL_551;
  451.                 }
  452.                 this.textWriter.WriteLine("Got TGS-REP...");
  453.                 File.WriteAllBytes(str4 + "tgsres.bin", array17);
  454.                 this.textWriter.WriteLine("Decrypting Logon status...");
  455.                 byte[] array18 = new byte[84];
  456.                 Array.Copy(array17, 50, array18, 0, 84);
  457.                 byte[] value = Program.RC4HMACDecrypt(key, 16, array18, 84, 1202);
  458.                 byte[] array19 = new byte[208];
  459.                 Array.Copy(array17, 58, array19, 0, 208);
  460.                 byte[] bytes = Program.RC4HMACDecrypt(key, 16, array19, 208, 1202);
  461.                 File.WriteAllBytes(str4 + "resp.bin", bytes);
  462.                 uint num = BitConverter.ToUInt32(value, 8);
  463.                 this.textWriter.WriteLine("Logon Status: " + num.ToString("X2"));
  464.                 if (num != 2148866317u)
  465.                 {
  466.                     this.textWriter.WriteLine(str2 + " is Unbanned");
  467.                     this.banned = false;
  468.                     this.textWriter.Flush();
  469.                     Thread.Sleep(500);
  470.                 }
  471.                 else
  472.                 {
  473.                     this.textWriter.WriteLine(str2 + " is Banned");
  474.                     this.banned = true;
  475.                     this.textWriter.Flush();
  476.                     Thread.Sleep(500);
  477.                 }
  478.                 this.textWriter.WriteLine("Took " + (DateTime.Now - now).Seconds + " second(s)");
  479.             }
  480.         }
  481.         public bool returnStatus()
  482.         {
  483.             return this.banned;
  484.         }
  485.         private static byte[] ComputeClientName(byte[] ConsoleId)
  486.         {
  487.             byte[] result;
  488.             try
  489.             {
  490.                 long num = 0L;
  491.                 for (int i = 0; i < 5; i++)
  492.                 {
  493.                     num = (num | (long)((ulong)ConsoleId[i])) << 8;
  494.                 }
  495.                 long num2 = num >> 8;
  496.                 int num3 = (int)num2 & 15;
  497.                 string text = string.Format("XE.{0}{1}@xbox.com", (num2 >> 4).ToString(), num3.ToString());
  498.                 if (text.Length != 24)
  499.                 {
  500.                     int arg_53_0 = text.Length;
  501.                     for (int j = 0; j < 24 - (text.Length - 1); j++)
  502.                     {
  503.                         text = text.Insert(3, "0");
  504.                     }
  505.                 }
  506.                 result = Encoding.ASCII.GetBytes(text);
  507.             }
  508.             catch
  509.             {
  510.                 result = ConsoleId;
  511.             }
  512.             return result;
  513.         }
  514.         private static byte[] GetTitleAuthData(byte[] Key, int keyLen, byte[] titleData)
  515.         {
  516.             byte[] sourceArray = new HMACSHA1(Program.ComputeKdcNoonce(Key, 16)).ComputeHash(titleData, 0, 66);
  517.             byte[] array = new byte[82];
  518.             Array.Copy(sourceArray, array, 16);
  519.             Array.Copy(titleData, 0, array, 16, 66);
  520.             return array;
  521.         }
  522.         private static byte[] ComputeKdcNoonce(byte[] Key, int keyLen)
  523.         {
  524.             byte[] buffer = new byte[]
  525.             {
  526.                 115,
  527.                 105,
  528.                 103,
  529.                 110,
  530.                 97,
  531.                 116,
  532.                 117,
  533.                 114,
  534.                 101,
  535.                 107,
  536.                 101,
  537.                 121,
  538.                 0
  539.             };
  540.             byte[] key = new HMACMD5(Key).ComputeHash(buffer, 0, 13);
  541.             byte[] inputBuffer = new byte[4];
  542.             byte[] array = new byte[4];
  543.             array[0] = 2;
  544.             array[1] = 4;
  545.             byte[] inputBuffer2 = array;
  546.             MD5 mD = new MD5CryptoServiceProvider();
  547.             mD.TransformBlock(inputBuffer2, 0, 4, null, 0);
  548.             mD.TransformFinalBlock(inputBuffer, 0, 4);
  549.             byte[] hash = mD.Hash;
  550.             return new HMACMD5(key).ComputeHash(hash);
  551.         }
  552.         private static byte[] GenerateTimeStamp()
  553.         {
  554.             byte[] array = Misc.HexStringToBytes("301aa011180f32303132313231323139303533305aa10502030b3543");
  555.             Encoding aSCII = Encoding.ASCII;
  556.             string s = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmssZ");
  557.             Array.Copy(aSCII.GetBytes(s), 0, array, 6, 15);
  558.             return array;
  559.         }
  560.         private static byte[] RC4HMACDecrypt(byte[] key, int keyLen, byte[] data, int dataLen, int Idk)
  561.         {
  562.             HMACMD5 hMACMD = new HMACMD5(key);
  563.             byte[] bytes = BitConverter.GetBytes(Idk);
  564.             byte[] key2 = hMACMD.ComputeHash(bytes, 0, 4);
  565.             byte[] array = new byte[16];
  566.             Array.Copy(data, array, 16);
  567.             byte[] array2 = new byte[data.Length - 16];
  568.             Array.Copy(data, 16, array2, 0, data.Length - 16);
  569.             hMACMD.Key = key2;
  570.             byte[] array3 = hMACMD.ComputeHash(array);
  571.             Security.RC4(ref array2, array3);
  572.             return array2;
  573.         }
  574.         private static byte[] RC4HMACEncrypt(byte[] key, int keyLen, byte[] data, int dataLen, int Idk)
  575.         {
  576.             HMACMD5 hMACMD = new HMACMD5(key);
  577.             byte[] bytes = BitConverter.GetBytes(Idk);
  578.             byte[] key2 = hMACMD.ComputeHash(bytes, 0, 4);
  579.             byte[] sourceArray = Misc.HexStringToBytes("9b6bfacb5c488190");
  580.             byte[] array = new byte[data.Length + 8];
  581.             Array.Copy(sourceArray, array, 8);
  582.             Array.Copy(data, 0, array, 8, data.Length);
  583.             hMACMD.Key = key2;
  584.             byte[] array2 = hMACMD.ComputeHash(array);
  585.             byte[] array3 = hMACMD.ComputeHash(array2);
  586.             Security.RC4(ref array, array3);
  587.             byte[] array4 = new byte[dataLen + 24];
  588.             Array.Copy(array2, 0, array4, 0, 16);
  589.             Array.Copy(array, 0, array4, 16, array.Length);
  590.             return array4;
  591.         }
  592.     }
  593. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement