├── .gitattributes ├── .gitignore ├── LICENSE ├── LawinServer.sln ├── LawinServer ├── Core │ ├── AppRegistry.cs │ ├── Extensions.cs │ ├── Logger.cs │ └── Win32.cs ├── LawinServer.csproj ├── Program.cs ├── Properties │ └── launchSettings.json ├── Proxy │ ├── PrivateKeyDeleters.cs │ └── Proxy.cs └── logopepega.ico └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # JustCode is a .NET coding add-in 131 | .JustCode 132 | 133 | # TeamCity is a build add-in 134 | _TeamCity* 135 | 136 | # DotCover is a Code Coverage Tool 137 | *.dotCover 138 | 139 | # AxoCover is a Code Coverage Tool 140 | .axoCover/* 141 | !.axoCover/settings.json 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 PsychoPast 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LawinServer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30225.117 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawinServer", "LawinServer\LawinServer.csproj", "{04A953AF-22D0-47C4-9C94-0E01618E3B3B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {04A953AF-22D0-47C4-9C94-0E01618E3B3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {04A953AF-22D0-47C4-9C94-0E01618E3B3B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {04A953AF-22D0-47C4-9C94-0E01618E3B3B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {04A953AF-22D0-47C4-9C94-0E01618E3B3B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {7A2D72F2-205F-4C77-99A1-46B0E15069A0} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /LawinServer/Core/AppRegistry.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace LawinServer.Core 6 | { 7 | internal class AppRegistry : IDisposable 8 | { 9 | private const string AppKey = @"SOFTWARE\LawinServer"; 10 | 11 | private readonly RegistryKey _registryKey; 12 | 13 | private readonly RegistryKey currentUser = Registry.CurrentUser; 14 | 15 | private RegistryKey OpenKey => currentUser.OpenSubKey(AppKey, RegistryKeyPermissionCheck.ReadWriteSubTree); 16 | 17 | public AppRegistry() => _registryKey = OpenKey switch 18 | { 19 | null => currentUser.CreateSubKey(AppKey, RegistryKeyPermissionCheck.ReadWriteSubTree), 20 | _ => currentUser.OpenSubKey(AppKey, RegistryKeyPermissionCheck.ReadWriteSubTree) 21 | }; 22 | 23 | public void UpdateRegistry(List registryInfos) => _registryKey.SetValues(registryInfos); 24 | 25 | public void Dispose() 26 | { 27 | _registryKey.Close(); 28 | _registryKey.Dispose(); 29 | GC.SuppressFinalize(this); 30 | } 31 | 32 | public T GetRegistryValue(string name) => (T)_registryKey.GetValue(name, null); 33 | } 34 | 35 | internal class RegistryInfo 36 | { 37 | public string Name { get; set; } 38 | 39 | public object Value { get; set; } 40 | 41 | public RegistryValueKind RegistryValueKind { get; set; } 42 | } 43 | } -------------------------------------------------------------------------------- /LawinServer/Core/Extensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Win32; 2 | using System.Collections.Generic; 3 | 4 | namespace LawinServer.Core 5 | { 6 | internal static class Extensions 7 | { 8 | public static void SetValues(this RegistryKey registryKey, List registryInfos) => registryInfos 9 | .ForEach(x => registryKey 10 | .SetValue(x.Name, x.Value, x.RegistryValueKind)); 11 | } 12 | } -------------------------------------------------------------------------------- /LawinServer/Core/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LawinServer.Core 4 | { 5 | internal static class Logger 6 | { 7 | public static void LogError(string content) 8 | { 9 | ConsoleColor oldColor = Console.ForegroundColor; 10 | Console.ForegroundColor = ConsoleColor.Red; 11 | Console.WriteLine(content); 12 | Console.ForegroundColor = oldColor; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /LawinServer/Core/Win32.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace LawinServer 5 | { 6 | internal static class Win32 7 | { 8 | /// 9 | /// Adds or removes an application-defined HandlerRoutine function from the list of handler functions for the calling process. 10 | /// 11 | /// A pointer to the application-defined HandlerRoutine function to be added or removed. 12 | /// If this parameter is TRUE, the handler is added; if it is FALSE, the handler is removed. 13 | /// If the function succeeds, the return value is nonzero, else zero. 14 | [DllImport("Kernel32")] 15 | public static extern bool SetConsoleCtrlHandler(SetConsoleCtrlEventHandler HandlerRoutine, bool Add); 16 | 17 | /// 18 | /// An application-defined function used with the SetConsoleCtrlHandler function. 19 | /// 20 | /// The type of control signal received by the handler. 21 | /// If the function handles the control signal, it should return TRUE. If it returns FALSE, the next handler function in the list of handlers for this process is used. 22 | public delegate bool SetConsoleCtrlEventHandler(CtrlType dwCtrlType); 23 | 24 | /// 25 | /// The type of control signal received by the handler. 26 | /// 27 | public enum CtrlType 28 | { 29 | /// 30 | /// A CTRL+C signal was received. 31 | /// 32 | CTRL_C_EVENT = 0, 33 | 34 | /// 35 | /// A CTRL+BREAK signal was received. 36 | /// 37 | CTRL_BREAK_EVENT = 1, 38 | 39 | /// 40 | /// A signal that the system sends to all processes attached to a console when the user closes the console. 41 | /// 42 | CTRL_CLOSE_EVENT = 2, 43 | 44 | /// 45 | /// A signal that the system sends to all console processes when a user is logging off. 46 | /// 47 | CTRL_LOGOFF_EVENT = 5, 48 | 49 | /// 50 | /// A signal that the system sends when the system is shutting down. 51 | /// 52 | CTRL_SHUTDOWN_EVENT = 6 53 | } 54 | 55 | /// 56 | /// Set an internet option. 57 | /// 58 | /// Handle on which to set information. 59 | /// Internet option to be set. 60 | /// Pointer to a buffer that contains the option setting. 61 | /// Size of the lpBuffer buffer. 62 | /// 63 | [DllImport("wininet.dll")] 64 | public static extern bool InternetSetOption(IntPtr hInternet, InternetOptions dwOption, IntPtr lpBuffer, uint dwBufferLength); 65 | 66 | /// 67 | /// The following option flags are used with the InternetQueryOption and InternetSetOption functions. 68 | /// 69 | internal enum InternetOptions : int 70 | { 71 | /// 72 | /// Causes the proxy data to be reread from the registry for a handle. 73 | /// 74 | INTERNET_OPTION_REFRESH = 37, 75 | 76 | /// 77 | /// Notifies the system that the registry settings have been changed so that it verifies the settings on the next call to InternetConnect. 78 | /// 79 | INTERNET_OPTION_SETTINGS_CHANGED = 39 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /LawinServer/LawinServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | PsychoPast 7 | Copyright © 2020 PsychoPast 8 | LICENSE 9 | git 10 | https://github.com/psychopast/LawinServer 11 | logopepega.ico 12 | logopepega.ico 13 | A launcher for LawinServer (Fortnite's private server). 14 | 1.0.5 15 | 1.0.5 16 | 1.0.5 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | True 27 | 28 | 29 | 30 | True 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /LawinServer/Program.cs: -------------------------------------------------------------------------------- 1 | using LawinServer.Net; 2 | using System; 3 | using static LawinServer.Win32; 4 | 5 | namespace LawinServer 6 | { 7 | internal class Program 8 | { 9 | private SetConsoleCtrlEventHandler setConsoleCtrlEventHandler; 10 | private Proxy proxy; 11 | private static void Main(string[] args) 12 | { 13 | ushort? port = null; 14 | if (args.Length == 1) 15 | { 16 | if (ushort.TryParse(args[0], out ushort portValue)) 17 | { 18 | port = portValue; 19 | } 20 | } 21 | Console.WriteLine("Thanks for using LawinServer made by Lawin#0001 :D\n" + 22 | "This launcher was made for LawinServer by PsychoPast.\n" + 23 | "Running... PLEASE, don't close the window else the connection will be aborted."); 24 | new Program().Run(port); 25 | Console.ReadLine(); 26 | } 27 | 28 | private void Run(ushort? port) 29 | { 30 | setConsoleCtrlEventHandler = CleanUp; 31 | SetConsoleCtrlHandler(setConsoleCtrlEventHandler, true); 32 | proxy = port switch 33 | { 34 | null => new Proxy(), 35 | _ => new Proxy((ushort)port) 36 | }; 37 | proxy.StartProxy(); 38 | } 39 | 40 | private bool CleanUp(CtrlType ctrlType) 41 | { 42 | switch (ctrlType) 43 | { 44 | case CtrlType.CTRL_BREAK_EVENT: 45 | case CtrlType.CTRL_CLOSE_EVENT: 46 | case CtrlType.CTRL_C_EVENT: 47 | case CtrlType.CTRL_LOGOFF_EVENT: 48 | case CtrlType.CTRL_SHUTDOWN_EVENT: 49 | proxy.StopProxy(); 50 | return true; 51 | default: 52 | return false; 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /LawinServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "LawinServer": { 4 | "commandName": "Project" 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /LawinServer/Proxy/PrivateKeyDeleters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Security.Cryptography; 4 | 5 | namespace LawinServer.Net 6 | { 7 | public class PrivateKeyDeleters 8 | { 9 | private readonly IDictionary> privateKeyDeleters = new Dictionary>(); 10 | 11 | public PrivateKeyDeleters() 12 | { 13 | AddPrivateKeyDeleter(DefaultRSACngPrivateKeyDeleter); 14 | AddPrivateKeyDeleter(DefaultRSACryptoServiceProviderPrivateKeyDeleter); 15 | } 16 | 17 | private void AddPrivateKeyDeleter(Action keyDeleter) where T : AsymmetricAlgorithm => privateKeyDeleters[typeof(T)] = (a) => keyDeleter((T)a); 18 | 19 | public void DeletePrivateKey(AsymmetricAlgorithm asymmetricAlgorithm) 20 | { 21 | for (Type type = asymmetricAlgorithm.GetType(); type != null; type = type.BaseType) 22 | { 23 | if (privateKeyDeleters.TryGetValue(type, out Action deleter)) 24 | { 25 | deleter(asymmetricAlgorithm); 26 | return; 27 | } 28 | } 29 | } 30 | 31 | private void DefaultRSACryptoServiceProviderPrivateKeyDeleter(RSACryptoServiceProvider rsaCryptoServiceProvider) 32 | { 33 | rsaCryptoServiceProvider.PersistKeyInCsp = false; 34 | rsaCryptoServiceProvider.Clear(); 35 | } 36 | 37 | private void DefaultRSACngPrivateKeyDeleter(RSACng rsaCng) 38 | { 39 | rsaCng.Key.Delete(); 40 | rsaCng.Clear(); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /LawinServer/Proxy/Proxy.cs: -------------------------------------------------------------------------------- 1 | using Fiddler; 2 | using LawinServer.Core; 3 | using Microsoft.Win32; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Security.Cryptography.X509Certificates; 7 | using static Fiddler.FiddlerApplication; 8 | using static LawinServer.Core.Logger; 9 | using static LawinServer.Win32; 10 | 11 | namespace LawinServer.Net 12 | { 13 | internal class Proxy 14 | { 15 | #region VARIABLES 16 | private const string Proxy_Server = "ProxyServer"; 17 | 18 | private const string Proxy_Enable = "ProxyEnable"; 19 | 20 | private readonly AppRegistry appRegistry; 21 | 22 | private readonly string proxyKey = @$"{Registry.CurrentUser}\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings"; 23 | 24 | private readonly FiddlerCoreStartupSettings startupSettings; 25 | 26 | private (object _currentProxyServer, int _defaultUserProxyState) proxySettings; 27 | 28 | private (string _fiddlerCert, string _privateKey) _fiddlerCertInfos; 29 | 30 | private int count = 0; 31 | #endregion 32 | 33 | public Proxy() : this(9999) { } //default port 34 | 35 | public Proxy(ushort port) 36 | { 37 | appRegistry = new AppRegistry(); 38 | 39 | GetDefaultProxySettingsValue(); 40 | ConfigureFiddlerSettings(out bool fiddlerCertRegKeysExist); 41 | startupSettings = new FiddlerCoreStartupSettingsBuilder() 42 | .ListenOnPort(port) 43 | .RegisterAsSystemProxy() 44 | .DecryptSSL() 45 | .OptimizeThreadPool() 46 | .Build(); 47 | if (!CertificateHandler(fiddlerCertRegKeysExist)) 48 | { 49 | LogError("[Certificate Install Error] Could not install the certificate. Please restart the app and try again!"); 50 | StopProxy(); 51 | Environment.Exit(69); 52 | } 53 | } 54 | 55 | #region CONFIGURATION 56 | private void GetDefaultProxySettingsValue() 57 | { 58 | proxySettings._currentProxyServer = Registry.GetValue(proxyKey, Proxy_Server, null); 59 | proxySettings._defaultUserProxyState = (int)Registry.GetValue(proxyKey, Proxy_Enable, 0); 60 | } 61 | 62 | private void ConfigureFiddlerSettings(out bool fiddlerCertRegKeysExist) 63 | { 64 | CONFIG.IgnoreServerCertErrors = false; 65 | Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true); 66 | Prefs.SetBoolPref("fiddler.certmaker.PreferCertEnroll", true); 67 | _fiddlerCertInfos._fiddlerCert = appRegistry.GetRegistryValue("FiddlerCert"); 68 | _fiddlerCertInfos._privateKey = appRegistry.GetRegistryValue("PrivateKey"); 69 | fiddlerCertRegKeysExist = _fiddlerCertInfos._fiddlerCert != null && _fiddlerCertInfos._privateKey != null; 70 | if (fiddlerCertRegKeysExist) 71 | { 72 | Prefs.SetStringPref("fiddler.certmaker.bc.cert", _fiddlerCertInfos._fiddlerCert); 73 | Prefs.SetStringPref("fiddler.certmaker.bc.key", _fiddlerCertInfos._privateKey); 74 | } 75 | } 76 | 77 | private bool CertificateHandler(bool valueExist) 78 | { 79 | if (!CertMaker.rootCertExists()) 80 | { 81 | if (!CertMaker.createRootCert()) 82 | { 83 | return false; 84 | } 85 | } 86 | bool certificateSuccess = CertMaker.rootCertIsTrusted() || CertMaker.trustRootCert(); 87 | if (!certificateSuccess) 88 | { 89 | return false; 90 | } 91 | _fiddlerCertInfos._fiddlerCert ??= Prefs.GetStringPref("fiddler.certmaker.bc.cert", null); 92 | _fiddlerCertInfos._privateKey ??= Prefs.GetStringPref("fiddler.certmaker.bc.key", null); 93 | if (!valueExist) 94 | { 95 | List registryInfo = new List() 96 | { 97 | new RegistryInfo() 98 | { 99 | Name = "FiddlerCert", 100 | Value = _fiddlerCertInfos._fiddlerCert, 101 | RegistryValueKind = RegistryValueKind.String 102 | }, 103 | new RegistryInfo() 104 | { 105 | Name = "PrivateKey", 106 | Value = _fiddlerCertInfos._privateKey, 107 | RegistryValueKind = RegistryValueKind.String 108 | } 109 | }; 110 | appRegistry.UpdateRegistry(registryInfo); 111 | } 112 | return true; 113 | } 114 | #endregion 115 | 116 | public void StartProxy() 117 | { 118 | appRegistry.Dispose(); 119 | BeforeRequest += OnBeforeRequest; 120 | AfterSessionComplete += OnAfterSessionComplete; 121 | Startup(startupSettings); 122 | Console.WriteLine($"Proxy started listening on port {startupSettings.ListenPort}."); 123 | } 124 | 125 | public bool StopProxy() 126 | { 127 | DeletePrivateKeys(); 128 | return ResetProxySettings(); 129 | } 130 | 131 | #region EVENT_HANDLERS 132 | private void OnBeforeRequest(Session oSession) 133 | { 134 | if (oSession.hostname.Contains(".ol.epicgames.com")) 135 | { 136 | if (oSession.HTTPMethodIs("CONNECT")) 137 | { 138 | oSession["x-replywithtunnel"] = "FortniteTunnel"; 139 | return; 140 | } 141 | oSession.fullUrl = "https://lawinserverfinal.herokuapp.com" + oSession.PathAndQuery; 142 | 143 | } 144 | } 145 | 146 | private void OnAfterSessionComplete(Session oSession) 147 | { 148 | if (oSession.hostname != "lawinserverfinal.herokuapp.com") 149 | { 150 | return; 151 | } 152 | if (oSession.responseCode >= 400) 153 | { 154 | string fullUrl = oSession.fullUrl; 155 | string requestHeaders = oSession.oRequest.headers.ToString(); 156 | int responseCode = oSession.responseCode; 157 | 158 | LogError($"[Endpoint] {fullUrl}\n" + 159 | $"[ResponseCode] {responseCode}\n" + 160 | $"[RequestHeader] { requestHeaders}\n\n" 161 | ); 162 | } 163 | Console.Title = $"LawinServer - Redirected {++count} endpoints"; 164 | } 165 | #endregion 166 | 167 | #region CLEANUP 168 | private bool ResetProxySettings() 169 | { 170 | Registry.SetValue(proxyKey, Proxy_Server, proxySettings._currentProxyServer, RegistryValueKind.String); 171 | if (proxySettings._defaultUserProxyState == 0) 172 | { 173 | Registry.SetValue(proxyKey, Proxy_Enable, 0, RegistryValueKind.DWord); 174 | bool successfulyChanged = InternetSetOption(IntPtr.Zero, InternetOptions.INTERNET_OPTION_SETTINGS_CHANGED, IntPtr.Zero, 0); 175 | bool successfulyRefreshed = InternetSetOption(IntPtr.Zero, InternetOptions.INTERNET_OPTION_REFRESH, IntPtr.Zero, 0); 176 | return successfulyChanged && successfulyRefreshed; 177 | } 178 | return true; 179 | } 180 | 181 | private void DeletePrivateKeys() 182 | { 183 | if (!(CertMaker.oCertProvider is ICertificateProvider4 certProvider)) 184 | { 185 | return; 186 | } 187 | PrivateKeyDeleters privateKeyDeleter = new PrivateKeyDeleters(); 188 | IDictionary certs = certProvider.CertCache; 189 | foreach (X509Certificate2 cert in certs.Values) 190 | { 191 | privateKeyDeleter.DeletePrivateKey(cert.PrivateKey); 192 | } 193 | } 194 | #endregion 195 | } 196 | } -------------------------------------------------------------------------------- /LawinServer/logopepega.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PsychoPast/LawinServer/5a80163dea84fa89373c5bd8a2555735825bc336/LawinServer/logopepega.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | usage: 2 | Double click the exe (uses default port: 9999) *RECOMMENDED* 3 | 4 | Launch with arg: LawinServer.exe *port* (specifies the port to use. Keep in mind a port can be unavailable) 5 | 6 | [Download Net core 3.1 Runtime](https://download.visualstudio.microsoft.com/download/pr/d97cfaf4-b17f-46c7-9a11-7f0d25dfd8b0/f76d4fce8e38b289efb9403aab0a0c9f/dotnet-runtime-3.1.5-win-x64.exe) --------------------------------------------------------------------------------