Skip to content

Commit 2298d8a

Browse files
(NEEDS TESTING) - Unify Backend framework to set-up some massive performance boost.
(NEEDS TESTING) - Unify Backend framework to set-up some massive performance boost. HTTP backend now has a stack based stream copy, aim at massively improving speed on CPUs like the Ryzen X3D series. Also uses SIMD for byte/int comparing. A fewx tweeks here and there to improve/secure more the server. This needs testing to make sure those improvements are fine and safe (they should).
1 parent 90af2df commit 2298d8a

File tree

31 files changed

+595
-141
lines changed

31 files changed

+595
-141
lines changed

BackendServices/AuxiliaryServices/HomeTools/HomeTools.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
6+
<IsTrimmable>true</IsTrimmable>
67
<IsPublishable>false</IsPublishable>
78
</PropertyGroup>
89

BackendServices/AuxiliaryServices/HomeTools/UnBAR/LegacyMapper.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public Task MapperStart(string foldertomap, string? helperfolder, string prefix,
2525

2626
if (string.IsNullOrEmpty(prefix))
2727
{
28-
#if NETSTANDARD2_1_OR_GREATER
29-
Match match = new Regex(@"[0-9a-fA-F]{8}-[0-9a-fA-F]{8}-[0-9a-fA-F]{8}-[0-9a-fA-F]{8}").Match(foldertomap);
30-
#elif NET7_0_OR_GREATER
28+
#if NET7_0_OR_GREATER
3129
Match match = UUIDRegex().Match(foldertomap);
30+
#else
31+
Match match = new Regex(@"[0-9a-fA-F]{8}-[0-9a-fA-F]{8}-[0-9a-fA-F]{8}-[0-9a-fA-F]{8}").Match(foldertomap);
3232
#endif
3333
if (match.Success)
3434
prefix = $"objects/{match.Groups[0].Value}/";
@@ -85,7 +85,7 @@ public Task MapperStart(string foldertomap, string? helperfolder, string prefix,
8585
{
8686
if (File.Exists(Path.Combine(foldertomap, file.Name)))
8787
{
88-
new FileInfo(Path.Combine(foldertomap, text).ToUpper()).Directory.Create();
88+
new FileInfo(Path.Combine(foldertomap, text).ToUpper()).Directory?.Create();
8989
if (!File.Exists(Path.Combine(foldertomap, text.ToUpper())))
9090
{
9191
File.Move(Path.Combine(foldertomap, file.Name), Path.Combine(foldertomap, text.ToUpper()));
@@ -104,7 +104,7 @@ public Task MapperStart(string foldertomap, string? helperfolder, string prefix,
104104
{
105105
if (File.Exists(Path.Combine(foldertomap, file.Name)))
106106
{
107-
new FileInfo(Path.Combine(foldertomap, cdatafromatmos).ToUpper()).Directory.Create();
107+
new FileInfo(Path.Combine(foldertomap, cdatafromatmos).ToUpper()).Directory?.Create();
108108
if (!File.Exists(Path.Combine(foldertomap, cdatafromatmos.ToUpper())))
109109
{
110110
File.Move(Path.Combine(foldertomap, file.Name), Path.Combine(foldertomap, cdatafromatmos.ToUpper()));
@@ -270,23 +270,25 @@ private void CopyFiles(string sourceDir, string targetDir)
270270
Directory.CreateDirectory(targetDir);
271271

272272
// Get all files in the source directory and its subdirectories
273-
string[] files = Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories);
274-
275-
foreach (string file in files)
273+
foreach (string file in Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories))
276274
{
277275
filePathList.Add(file);
278276

279277
try
280278
{
281279
string targetPath = Path.Combine(targetDir, Path.GetRelativePath(sourceDir, file));
280+
string? directorytargetPath = Path.GetDirectoryName(targetPath);
282281

283-
// Create the directory structure in the target directory if it doesn't exist
284-
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
282+
if (!string.IsNullOrEmpty(directorytargetPath))
283+
{
284+
// Create the directory structure in the target directory if it doesn't exist
285+
Directory.CreateDirectory(directorytargetPath);
285286

286-
// Copy the file to the target directory
287-
File.Copy(file, targetPath, true); // Use true to overwrite existing files
287+
// Copy the file to the target directory
288+
File.Copy(file, targetPath, true); // Use true to overwrite existing files
289+
}
288290
}
289-
catch (Exception)
291+
catch
290292
{
291293
// Not Important.
292294
}

BackendServices/AuxiliaryServices/WebAPIService/CDS/CTRExploitProcess.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public class CTRExploitProcess
132132
{
133133
byte[]? TestFileBytes = LIBSECURE.InitiateBlowfishBuffer(EncryptedFileBytes, ToolsImpl.DefaultKey, GuessedIV, "CTR");
134134

135-
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindbyteSequence(TestFileBytes, new byte[] { 0xAD, 0xEF, 0x17, 0xE1, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 }))
135+
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindBytePattern(TestFileBytes, new byte[] { 0xAD, 0xEF, 0x17, 0xE1, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 }) != -1)
136136
{
137137
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Valid File was bruteforced! - {0}", DateTime.Now.ToString());
138138
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Found IV - {0}", DataTypesUtils.ByteArrayToHexString(GuessedIV));
@@ -145,7 +145,7 @@ public class CTRExploitProcess
145145
{
146146
TestFileBytes = LIBSECURE.InitiateBlowfishBuffer(EncryptedFileBytes, ToolsImpl.DefaultKey, GuessedIV, "CTR");
147147

148-
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindbyteSequence(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }))
148+
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindBytePattern(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }) != -1)
149149
{
150150
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Valid File was bruteforced! - {0}", DateTime.Now.ToString());
151151
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Found IV - {0}", DataTypesUtils.ByteArrayToHexString(GuessedIV));
@@ -158,7 +158,7 @@ public class CTRExploitProcess
158158
{
159159
TestFileBytes = LIBSECURE.InitiateBlowfishBuffer(EncryptedFileBytes, ToolsImpl.DefaultKey, GuessedIV, "CTR");
160160

161-
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindbyteSequence(TestFileBytes, new byte[] { 0xAD, 0xEF, 0x17, 0xE1, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }))
161+
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindBytePattern(TestFileBytes, new byte[] { 0xAD, 0xEF, 0x17, 0xE1, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }) != 1)
162162
{
163163
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Valid File was bruteforced! - {0}", DateTime.Now.ToString());
164164
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Found IV - {0}", DataTypesUtils.ByteArrayToHexString(GuessedIV));
@@ -171,7 +171,7 @@ public class CTRExploitProcess
171171
{
172172
TestFileBytes = LIBSECURE.InitiateBlowfishBuffer(EncryptedFileBytes, ToolsImpl.DefaultKey, GuessedIV, "CTR");
173173

174-
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindbyteSequence(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }))
174+
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindBytePattern(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }) != -1)
175175
{
176176
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Valid File was bruteforced! - {0}", DateTime.Now.ToString());
177177
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Found IV - {0}", DataTypesUtils.ByteArrayToHexString(GuessedIV));
@@ -184,7 +184,7 @@ public class CTRExploitProcess
184184
{
185185
TestFileBytes = LIBSECURE.InitiateBlowfishBuffer(EncryptedFileBytes, ToolsImpl.DefaultKey, GuessedIV, "CTR");
186186

187-
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindbyteSequence(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }))
187+
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindBytePattern(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }) != -1)
188188
{
189189
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Valid File was bruteforced! - {0}", DateTime.Now.ToString());
190190
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Found IV - {0}", DataTypesUtils.ByteArrayToHexString(GuessedIV));

BackendServices/AuxiliaryServices/WebAPIService/HELLFIRE/Helpers/NPTicket.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class NPTicket
6060
extractedData[i] = 0x20;
6161
}
6262

63-
if (DataTypesUtils.FindbyteSequence(ticketData, new byte[] { 0x52, 0x50, 0x43, 0x4E }))
63+
if (DataTypesUtils.FindBytePattern(ticketData, new byte[] { 0x52, 0x50, 0x43, 0x4E }) != -1)
6464
{
6565
LoggerAccessor.LogInfo($"[HFGames] : User {Encoding.ASCII.GetString(extractedData).Replace("H", string.Empty)} logged in and is on RPCN");
6666

BackendServices/AuxiliaryServices/WebAPIService/WebAPIService.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
6+
<IsTrimmable>true</IsTrimmable>
67
<IsPublishable>false</IsPublishable>
78
</PropertyGroup>
89

910
<ItemGroup>
1011
<ProjectReference Include="..\HomeTools\HomeTools.csproj" />
1112
<PackageReference Include="HttpMultipartParser" Version="8.4.0" />
12-
<PackageReference Include="NLua" Version="1.7.2" />
13+
<PackageReference Include="NLua" Version="1.7.3" />
1314
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
1415
</ItemGroup>
1516

BackendServices/CastleLibrary/CastleLibrary.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
4+
<TargetFramework>net6.0</TargetFramework>
55
<!-- In case we disable signing for local builds, ignore identity mismatch with baseline version. -->
66
<NoWarn Condition="'$(SignAssembly)' != 'true'">$(NoWarn);CP0003</NoWarn>
77

@@ -16,6 +16,7 @@
1616
<RunAnalyzersDuringBuild>False</RunAnalyzersDuringBuild>
1717
<DefineConstants />
1818
<Optimize>True</Optimize>
19+
<IsTrimmable>true</IsTrimmable>
1920
<IsPublishable>false</IsPublishable>
2021
</PropertyGroup>
2122

BackendServices/CavemanTcp/CavemanTcp.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
4+
<TargetFramework>net6.0</TargetFramework>
55
<Version>2.0.2</Version>
66
<Authors>Joel Christner</Authors>
77
<Description>CavemanTcp is a simple TCP client and server providing easy integration and full control over network reads and writes, allowing you to build your own state machines with ease.</Description>
@@ -14,6 +14,7 @@
1414
<PackageReleaseNotes>Add permitted, blocked IPs</PackageReleaseNotes>
1515
<PackageId>CavemanTcp</PackageId>
1616
<Product>CavemanTcp</Product>
17+
<IsTrimmable>true</IsTrimmable>
1718
<IsPublishable>false</IsPublishable>
1819
</PropertyGroup>
1920

BackendServices/CompressionLibrary/CompressionLibrary.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<IsTrimmable>true</IsTrimmable>
56
<IsPublishable>false</IsPublishable>
67
</PropertyGroup>
78

BackendServices/CustomLogger/CustomLogger.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<IsTrimmable>true</IsTrimmable>
56
<IsPublishable>false</IsPublishable>
67
</PropertyGroup>
78

0 commit comments

Comments
 (0)