launch + proxy
This commit is contained in:
parent
30260485dd
commit
eb0a76a3d8
70
Partypacker/Core/Server.cs
Normal file
70
Partypacker/Core/Server.cs
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Partypacker.Core
|
||||||
|
{
|
||||||
|
internal class Server
|
||||||
|
{
|
||||||
|
public static KeyValuePair<bool, string> GET(string URL = "/")
|
||||||
|
{
|
||||||
|
if (URL.StartsWith("/"))
|
||||||
|
URL = "https://example.com" + URL;
|
||||||
|
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
|
||||||
|
request.Method = "GET";
|
||||||
|
// request.Headers.Add("my-header", "my-value");
|
||||||
|
|
||||||
|
string Response = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var WebResponse = request.GetResponse();
|
||||||
|
|
||||||
|
StreamReader sr = new StreamReader(WebResponse.GetResponseStream());
|
||||||
|
Response = sr.ReadToEnd();
|
||||||
|
sr.Close();
|
||||||
|
|
||||||
|
return new KeyValuePair<bool, string>(true, Response);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return new KeyValuePair<bool, string>(false, string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static KeyValuePair<bool, string> POST(string URL = "/", string Body = "")
|
||||||
|
{
|
||||||
|
if (URL.StartsWith("/"))
|
||||||
|
URL = "https://example.com" + URL;
|
||||||
|
|
||||||
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
|
||||||
|
request.Method = "POST";
|
||||||
|
request.ContentType = "text/plain";
|
||||||
|
|
||||||
|
string Response = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var WebRequest = request.GetRequestStream();
|
||||||
|
WebRequest.Write(Encoding.UTF8.GetBytes(Body), 0, Body.Length);
|
||||||
|
|
||||||
|
var WebResponse = request.GetResponse();
|
||||||
|
|
||||||
|
StreamReader sr = new StreamReader(WebResponse.GetResponseStream());
|
||||||
|
Response = sr.ReadToEnd();
|
||||||
|
sr.Close();
|
||||||
|
|
||||||
|
return new KeyValuePair<bool, string>(true, Response);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
return new KeyValuePair<bool, string>(false, string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Partypacker.Core
|
namespace Partypacker
|
||||||
{
|
{
|
||||||
internal static class Win32
|
internal static class Win32
|
||||||
{
|
{
|
||||||
|
|
1
Partypacker/NewFile1.txt
Normal file
1
Partypacker/NewFile1.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||||
|
<PackageIcon>icon.ico</PackageIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -13,4 +15,11 @@
|
||||||
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
|
<PackageReference Include="System.ComponentModel.Composition" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="icon.ico">
|
||||||
|
<Pack>True</Pack>
|
||||||
|
<PackagePath></PackagePath>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,12 +1,26 @@
|
||||||
using Partypacker;
|
using Partypacker.Net;
|
||||||
using Pastel;
|
using Pastel;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using static Partypacker.Win32;
|
||||||
|
|
||||||
Console.SetWindowSize(75, 20);
|
namespace Partypacker
|
||||||
|
{
|
||||||
|
public static class Program
|
||||||
|
{
|
||||||
|
private static SetConsoleCtrlEventHandler CtrlHandler;
|
||||||
|
private static Proxy Proxx;
|
||||||
|
|
||||||
Console.CursorVisible = false;
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
ushort? port = 6969;
|
||||||
|
|
||||||
Console.WriteLine(@"
|
Console.SetWindowSize(75, 20);
|
||||||
|
Console.SetBufferSize(75, 20);
|
||||||
|
|
||||||
|
Console.CursorVisible = false;
|
||||||
|
|
||||||
|
Console.WriteLine(@"
|
||||||
_____ _ _
|
_____ _ _
|
||||||
| __ \ | | | |
|
| __ \ | | | |
|
||||||
| |__) |_ _ _ __| |_ _ _ _ __ __ _ ___| | _____ _ __
|
| |__) |_ _ _ __| |_ _ _ _ __ __ _ ___| | _____ _ __
|
||||||
|
@ -15,22 +29,25 @@ Console.WriteLine(@"
|
||||||
|_| \__,_|_| \__|\__, | .__/ \__,_|\___|_|\_\___|_|
|
|_| \__,_|_| \__|\__, | .__/ \__,_|\___|_|\_\___|_|
|
||||||
__/ | |
|
__/ | |
|
||||||
|___/|_| ".Pastel(Color.IndianRed));
|
|___/|_| ".Pastel(Color.IndianRed));
|
||||||
Console.WriteLine("-----------------------------------------------------------".Pastel(Color.CadetBlue));
|
Console.WriteLine("-----------------------------------------------------------".Pastel(Color.CadetBlue));
|
||||||
|
|
||||||
Console.WriteLine("Welcome to Partypacker - Select an option below:");
|
Console.WriteLine("Welcome to Partypacker - Select an option below:");
|
||||||
|
|
||||||
ConsoleKeyInfo ReceivedKeyInput;
|
ConsoleKeyInfo ReceivedKeyInput;
|
||||||
int SelectedOptionIndex = 0;
|
int SelectedOptionIndex = 0;
|
||||||
bool Running = true;
|
bool Running = true;
|
||||||
SelectableOption[] Options = new SelectableOption[]
|
SelectableOption[] Options = new SelectableOption[]
|
||||||
{
|
{
|
||||||
new SelectableOption("Launch Fortnite", () => { Console.WriteLine("cool!"); }),
|
new SelectableOption("Launch Fortnite", () =>
|
||||||
|
Run(port, () => Process.Start("com.epicgames.launcher://apps/fn%3A4fe75bbc5a674f4f9b356b5c90567da5%3AFortnite?action=launch&silent=true"))),
|
||||||
new SelectableOption("Open Dashboard", () => { Console.WriteLine("epic!"); }),
|
new SelectableOption("Open Dashboard", () => { Console.WriteLine("epic!"); }),
|
||||||
new SelectableOption("Settings", () => { Console.WriteLine("awesome!"); })
|
new SelectableOption("Settings", () => { Console.WriteLine("awesome!"); })
|
||||||
};
|
};
|
||||||
|
|
||||||
while (Running)
|
try
|
||||||
{
|
{
|
||||||
|
while (Running)
|
||||||
|
{
|
||||||
(int left, int top) = Console.GetCursorPosition();
|
(int left, int top) = Console.GetCursorPosition();
|
||||||
for (int i = 0; i < Options.Length; i++)
|
for (int i = 0; i < Options.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -55,4 +72,42 @@ while (Running)
|
||||||
|
|
||||||
Console.SetCursorPosition(left, top);
|
Console.SetCursorPosition(left, top);
|
||||||
SelectedOptionIndex = Math.Clamp(SelectedOptionIndex, 0, Options.Length);
|
SelectedOptionIndex = Math.Clamp(SelectedOptionIndex, 0, Options.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
OnApplicationExit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Run(ushort? port, Action Finish)
|
||||||
|
{
|
||||||
|
CtrlHandler = CleanUp;
|
||||||
|
SetConsoleCtrlHandler(CtrlHandler, true);
|
||||||
|
Proxx = port switch
|
||||||
|
{
|
||||||
|
null => new Proxy(),
|
||||||
|
_ => new Proxy((ushort)port)
|
||||||
|
};
|
||||||
|
Proxx.StartProxy();
|
||||||
|
|
||||||
|
Finish.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnApplicationExit()
|
||||||
|
{
|
||||||
|
CleanUp(CtrlType.CTRL_C_EVENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool CleanUp(CtrlType ctrlType)
|
||||||
|
{
|
||||||
|
Proxx.StopProxy();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace Partypacker.Proxy
|
namespace Partypacker.Net
|
||||||
{
|
{
|
||||||
internal class PrivateKeyDeleters
|
internal class PrivateKeyDeleters
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,9 +8,11 @@ using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static Fiddler.FiddlerApplication;
|
using static Fiddler.FiddlerApplication;
|
||||||
using static Partypacker.Core.Win32;
|
using static Partypacker.Win32;
|
||||||
|
using Pastel;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace Partypacker.Proxy
|
namespace Partypacker.Net
|
||||||
{
|
{
|
||||||
internal class Proxy
|
internal class Proxy
|
||||||
{
|
{
|
||||||
|
@ -18,23 +20,14 @@ namespace Partypacker.Proxy
|
||||||
// https://github.com/PsychoPast/LawinServer/blob/master/LawinServer/Proxy/Proxy.cs
|
// https://github.com/PsychoPast/LawinServer/blob/master/LawinServer/Proxy/Proxy.cs
|
||||||
// without it, fiddler-less proxying would have never been achieved
|
// without it, fiddler-less proxying would have never been achieved
|
||||||
|
|
||||||
#region VARIABLES
|
|
||||||
private const string Proxy_Server = "ProxyServer";
|
private const string Proxy_Server = "ProxyServer";
|
||||||
|
|
||||||
private const string Proxy_Enable = "ProxyEnable";
|
private const string Proxy_Enable = "ProxyEnable";
|
||||||
|
|
||||||
private readonly AppRegistry appRegistry;
|
private readonly AppRegistry appRegistry;
|
||||||
|
|
||||||
private readonly string proxyKey = @$"{Registry.CurrentUser}\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings";
|
private readonly string proxyKey = @$"{Registry.CurrentUser}\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings";
|
||||||
|
|
||||||
private readonly FiddlerCoreStartupSettings startupSettings;
|
private readonly FiddlerCoreStartupSettings startupSettings;
|
||||||
|
|
||||||
private (object _currentProxyServer, int _defaultUserProxyState) proxySettings;
|
private (object _currentProxyServer, int _defaultUserProxyState) proxySettings;
|
||||||
|
|
||||||
private (string _fiddlerCert, string _privateKey) _fiddlerCertInfos;
|
private (string _fiddlerCert, string _privateKey) _fiddlerCertInfos;
|
||||||
|
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
#endregion
|
|
||||||
|
|
||||||
public Proxy() : this(9999) { } //default port
|
public Proxy() : this(9999) { } //default port
|
||||||
|
|
||||||
|
@ -123,9 +116,8 @@ namespace Partypacker.Proxy
|
||||||
{
|
{
|
||||||
appRegistry.Dispose();
|
appRegistry.Dispose();
|
||||||
BeforeRequest += OnBeforeRequest;
|
BeforeRequest += OnBeforeRequest;
|
||||||
AfterSessionComplete += OnAfterSessionComplete;
|
|
||||||
Startup(startupSettings);
|
Startup(startupSettings);
|
||||||
Console.WriteLine($"Proxy started listening on port {startupSettings.ListenPort}.");
|
Console.WriteLine($"Proxy started listening on port {startupSettings.ListenPort.ToString().Pastel(Color.LimeGreen)}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool StopProxy()
|
public bool StopProxy()
|
||||||
|
@ -137,38 +129,33 @@ namespace Partypacker.Proxy
|
||||||
#region EVENT_HANDLERS
|
#region EVENT_HANDLERS
|
||||||
private void OnBeforeRequest(Session oSession)
|
private void OnBeforeRequest(Session oSession)
|
||||||
{
|
{
|
||||||
if (oSession.hostname.Contains(".ol.epicgames.com"))
|
if (oSession.PathAndQuery.Contains("/content/api/pages/fortnite-game/spark-tracks")
|
||||||
|
|| oSession.HostnameIs("cdn.qstv.on.epicgames.com")
|
||||||
|
|| oSession.PathAndQuery.Contains("/master.blurl")
|
||||||
|
|| oSession.PathAndQuery.Contains("/main.blurl")
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (oSession.HTTPMethodIs("CONNECT"))
|
if (oSession.HTTPMethodIs("CONNECT"))
|
||||||
{
|
{
|
||||||
oSession["x-replywithtunnel"] = "FortniteTunnel";
|
oSession["x-replywithtunnel"] = "FortniteTunnel";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
oSession.fullUrl = "https://lawinserverfinal.herokuapp.com" + oSession.PathAndQuery;
|
|
||||||
|
|
||||||
}
|
string BaseURL = // thats gonna be taken on most machines but sure
|
||||||
}
|
#if DEBUG
|
||||||
|
"http://localhost:80";
|
||||||
|
#else
|
||||||
|
"https://api.partypack.mcthe.dev";
|
||||||
|
#endif
|
||||||
|
|
||||||
private void OnAfterSessionComplete(Session oSession)
|
if (oSession.PathAndQuery.Contains("/master.blurl")
|
||||||
{
|
|| oSession.PathAndQuery.Contains("/main.blurl"))
|
||||||
if (oSession.hostname != "lawinserverfinal.herokuapp.com")
|
oSession.fullUrl = BaseURL + oSession.PathAndQuery;
|
||||||
{
|
else
|
||||||
return;
|
oSession.fullUrl = BaseURL + oSession.PathAndQuery;
|
||||||
}
|
}
|
||||||
if (oSession.responseCode >= 400)
|
|
||||||
{
|
|
||||||
string fullUrl = oSession.fullUrl;
|
|
||||||
string requestHeaders = oSession.oRequest.headers.ToString();
|
|
||||||
int responseCode = oSession.responseCode;
|
|
||||||
|
|
||||||
/*LogError($"[Endpoint] {fullUrl}\n" +
|
|
||||||
$"[ResponseCode] {responseCode}\n" +
|
|
||||||
$"[RequestHeader] {requestHeaders}\n\n"
|
|
||||||
);*/
|
|
||||||
}
|
}
|
||||||
Console.Title = $"LawinServer - Redirected {++count} endpoints";
|
#endregion
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region CLEANUP
|
#region CLEANUP
|
||||||
private bool ResetProxySettings()
|
private bool ResetProxySettings()
|
||||||
|
|
BIN
Partypacker/icon.ico
Normal file
BIN
Partypacker/icon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 KiB |
Loading…
Reference in New Issue
Block a user