Guest User

Untitled

a guest
Feb 7th, 2020
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.06 KB | None | 0 0
  1. using System;
  2. using System.Threading.Tasks;
  3.  
  4. namespace TarkovBot
  5. {
  6.     class Program
  7.     {
  8.         static async Task Main(string[] args)
  9.         {
  10.             var req = new Requester("YOUR SESSION");
  11.            
  12.             await req.PostJson(Requester.PROD_ENDPOINT + "/client/game/profile/list", "");
  13.         }
  14.     }
  15. }
  16.  
  17. using System;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using System.IO;
  21. using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
  22. using System.Net.Http.Headers;
  23. using System.Net.Http;
  24. using System.Net;
  25.  
  26. namespace TarkovBot
  27. {
  28.     public class Requester
  29.     {
  30.         private static HttpClient client;
  31.  
  32.         public const string LAUNCHER_ENDPOINT = "https://launcher.escapefromtarkov.com";
  33.         public const string PROD_ENDPOINT = "https://prod.escapefromtarkov.com";
  34.         public const string TRADING_ENDPOINT = "https://trading.escapefromtarkov.com";
  35.         public const string RAGFAIR_ENDPOINT = "https://ragfair.escapefromtarkov.com";
  36.  
  37.         private const string BSG_LAUNCHER_VERSION = "0.9.2.970";
  38.         private const string EFT_CLIENT_VERSION = "0.12.3.5776";
  39.         private const string UNITY_VERSION = "2018.4.13f1";
  40.         public Requester(string session)
  41.         {
  42.             var cookies = new CookieContainer();
  43.            
  44.             cookies.Add(new Uri(PROD_ENDPOINT), new Cookie("PHPSESSID", session));
  45.             var handler = new HttpClientHandler
  46.             {
  47.                 CookieContainer = cookies,
  48.                 UseCookies = true,
  49.                 ClientCertificateOptions = ClientCertificateOption.Automatic
  50.             };
  51.             client = new HttpClient(handler);
  52.  
  53.             client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  54.             client.DefaultRequestHeaders.Add("User-Agent", $"UnityPlayer/{UNITY_VERSION} (UnityWebRequest/1.0, libcurl/7.52.0-DEV)");
  55.             client.DefaultRequestHeaders.Add("App-Version", $"EFT Client {EFT_CLIENT_VERSION}");
  56.             client.DefaultRequestHeaders.Add("X-Unity-Version", UNITY_VERSION);
  57.         }
  58.         public async Task PostJson(string uri, string body)
  59.         {
  60.             var content = new StringContent(body, Encoding.UTF8, "application/json");
  61.             content.Headers.ContentType.CharSet = "";
  62.            
  63.             var response = await client.PostAsync("https://prod.escapefromtarkov.com/client/game/profile/list", content);
  64.  
  65.             byte[] data = await response.Content.ReadAsByteArrayAsync();
  66.             Console.WriteLine("Status code: " + response.StatusCode);
  67.  
  68.             byte[] decompressedData = new byte[data.Length];
  69.             int decompressedLength = 0;
  70.  
  71.             using (MemoryStream memory = new MemoryStream(data))
  72.             using (InflaterInputStream inflater = new InflaterInputStream(memory))
  73.                 decompressedLength = inflater.Read(decompressedData, 0, decompressedData.Length);
  74.  
  75.             Console.WriteLine("Content:");
  76.             Console.WriteLine(Encoding.Default.GetString(decompressedData));
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment