Skip to content

Commit

Permalink
Merge pull request #60 from GitHubProUser67/Nightly
Browse files Browse the repository at this point in the history
Nightly update (16/06/2024).
  • Loading branch information
GitHubProUser67 authored Jun 16, 2024
2 parents 90af2df + b907131 commit 6f56ff2
Show file tree
Hide file tree
Showing 196 changed files with 9,526 additions and 321 deletions.
3 changes: 2 additions & 1 deletion BackendServices/AuxiliaryServices/HomeTools/HomeTools.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsTrimmable>true</IsTrimmable>
<IsPublishable>false</IsPublishable>
</PropertyGroup>

Expand Down
28 changes: 15 additions & 13 deletions BackendServices/AuxiliaryServices/HomeTools/UnBAR/LegacyMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public Task MapperStart(string foldertomap, string? helperfolder, string prefix,

if (string.IsNullOrEmpty(prefix))
{
#if NETSTANDARD2_1_OR_GREATER
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);
#elif NET7_0_OR_GREATER
#if NET7_0_OR_GREATER
Match match = UUIDRegex().Match(foldertomap);
#else
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);
#endif
if (match.Success)
prefix = $"objects/{match.Groups[0].Value}/";
Expand Down Expand Up @@ -85,7 +85,7 @@ public Task MapperStart(string foldertomap, string? helperfolder, string prefix,
{
if (File.Exists(Path.Combine(foldertomap, file.Name)))
{
new FileInfo(Path.Combine(foldertomap, text).ToUpper()).Directory.Create();
new FileInfo(Path.Combine(foldertomap, text).ToUpper()).Directory?.Create();
if (!File.Exists(Path.Combine(foldertomap, text.ToUpper())))
{
File.Move(Path.Combine(foldertomap, file.Name), Path.Combine(foldertomap, text.ToUpper()));
Expand All @@ -104,7 +104,7 @@ public Task MapperStart(string foldertomap, string? helperfolder, string prefix,
{
if (File.Exists(Path.Combine(foldertomap, file.Name)))
{
new FileInfo(Path.Combine(foldertomap, cdatafromatmos).ToUpper()).Directory.Create();
new FileInfo(Path.Combine(foldertomap, cdatafromatmos).ToUpper()).Directory?.Create();
if (!File.Exists(Path.Combine(foldertomap, cdatafromatmos.ToUpper())))
{
File.Move(Path.Combine(foldertomap, file.Name), Path.Combine(foldertomap, cdatafromatmos.ToUpper()));
Expand Down Expand Up @@ -270,23 +270,25 @@ private void CopyFiles(string sourceDir, string targetDir)
Directory.CreateDirectory(targetDir);

// Get all files in the source directory and its subdirectories
string[] files = Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories);

foreach (string file in files)
foreach (string file in Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories))
{
filePathList.Add(file);

try
{
string targetPath = Path.Combine(targetDir, Path.GetRelativePath(sourceDir, file));
string? directorytargetPath = Path.GetDirectoryName(targetPath);

// Create the directory structure in the target directory if it doesn't exist
Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
if (!string.IsNullOrEmpty(directorytargetPath))
{
// Create the directory structure in the target directory if it doesn't exist
Directory.CreateDirectory(directorytargetPath);

// Copy the file to the target directory
File.Copy(file, targetPath, true); // Use true to overwrite existing files
// Copy the file to the target directory
File.Copy(file, targetPath, true); // Use true to overwrite existing files
}
}
catch (Exception)
catch
{
// Not Important.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class CTRExploitProcess
{
byte[]? TestFileBytes = LIBSECURE.InitiateBlowfishBuffer(EncryptedFileBytes, ToolsImpl.DefaultKey, GuessedIV, "CTR");

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

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

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

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

if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindbyteSequence(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }))
if (TestFileBytes != null && TestFileBytes.Length > 12 && DataTypesUtils.FindBytePattern(TestFileBytes, new byte[] { 0xE1, 0x17, 0xEF, 0xAD, 0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }) != -1)
{
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Valid File was bruteforced! - {0}", DateTime.Now.ToString());
CustomLogger.LoggerAccessor.LogInfo("[CDS] - CTRExploitProcess - Found IV - {0}", DataTypesUtils.ByteArrayToHexString(GuessedIV));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class NPTicket
extractedData[i] = 0x20;
}

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

Expand Down
3 changes: 3 additions & 0 deletions BackendServices/AuxiliaryServices/WebAPIService/OHS/Batch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public class Batch
case "usercounter/incrementmany/":
resultfromcommand = UserCounter.Increment_Many(PostData, ContentType, directorypath, data, game);
break;
case "usercounter/increment_setentry/":
resultfromcommand = UserCounter.IncrementSetEntry(PostData, ContentType, directorypath, data, game);
break;
case "userinventory/addglobalitems/":
resultfromcommand = UserInventory.AddGlobalItems(PostData, ContentType, directorypath + $"/{project}/", data, game);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class JaminProcessor
{
public static bool VerifyHash(string str, string referencehash)
{
if (EncryptDecrypt.Hash32Str(str) == referencehash.ToUpper())
if (EncryptDecrypt.Hash32Str(str).Equals(referencehash, StringComparison.InvariantCultureIgnoreCase))
return true;

return false;
Expand Down Expand Up @@ -309,8 +309,8 @@ public static object[] ExecuteLuaScript(string luaScript)
private static string ToLiteral(string input)
{
StringBuilder literal = new StringBuilder(input.Length + 2);
literal.Append("\"");
foreach (var c in input)
literal.Append('"');
foreach (char c in input)
{
switch (c)
{
Expand All @@ -327,10 +327,8 @@ private static string ToLiteral(string input)
default:
// ASCII printable character
if (c >= 0x20 && c <= 0x7e)
{
literal.Append(c);
// As UTF16 escaped character
}
else
{
literal.Append(@"\u");
Expand All @@ -339,7 +337,7 @@ private static string ToLiteral(string input)
break;
}
}
literal.Append("\"");
literal.Append('"');
return literal.ToString();
}
}
Expand Down
52 changes: 17 additions & 35 deletions BackendServices/AuxiliaryServices/WebAPIService/OHS/Leaderboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System;
using System.Linq;

namespace WebAPIService.OHS
{
Expand Down Expand Up @@ -374,13 +375,16 @@ public static string UpdateScoreboard(string json, string nameToUpdate, int newS
{
foreach (var entry in entries)
{
var rankData = new Dictionary<string, object>
{
{ "[\"user\"]", $"\"{entry.Name}\"" }, // Enclose string in double quotes and put it inside the brackets
{ "[\"score\"]", $"\"{entry.Score}\"" } // For numbers, no need to enclose in quotes and put it inside the brackets
};
if (!string.IsNullOrEmpty(entry.Name))
{
var rankData = new Dictionary<string, object>
{
{ "[\"user\"]", $"\"{entry.Name}\"" }, // Enclose string in double quotes and put it inside the brackets
{ "[\"score\"]", $"\"{entry.Score}\"" } // For numbers, no need to enclose in quotes and put it inside the brackets
};

luaTable.Add(entry.Rank, rankData);
luaTable.Add(entry.Rank, rankData);
}
}

// Step 3: Format the Lua table as a string using regex
Expand Down Expand Up @@ -421,7 +425,7 @@ public static string RequestByUsers(string? jsontable, string scoreboardpath)
{
StringBuilder? resultBuilder = new StringBuilder();

foreach (string user in data.Users)
foreach (string user in data.Users.Where(user => !string.IsNullOrEmpty(user)))
{
string? scoreboarddata = File.ReadAllText(scoreboardfile);

Expand All @@ -441,7 +445,7 @@ public static string RequestByUsers(string? jsontable, string scoreboardpath)
{
foreach (var entry in entries)
{
if (entry.Name == user)
if (!string.IsNullOrEmpty(entry.Name) && entry.Name.Equals(user))
{
if (entry.Score != 0)
{
Expand Down Expand Up @@ -492,7 +496,7 @@ public static string RequestByUsers(string? jsontable, string scoreboardpath)

foreach (var entry in scoreentries)
{
if (i >= 1)
if (i >= 1 && !string.IsNullOrEmpty(entry.Name))
{
var rankData = new Dictionary<string, object>
{
Expand Down Expand Up @@ -564,11 +568,7 @@ public static string RequestByUsers(string? jsontable, string scoreboardpath)
string scoreboardfile = scoreboardpath + $"/scoreboard_{key}.json";

if (!File.Exists(scoreboardfile))
{
Scoreboard? scoreboard = GenerateSampleScoreboard(numEntries);
File.WriteAllText(scoreboardfile, JsonConvert.SerializeObject(scoreboard, Formatting.Indented));
scoreboard = null;
}
File.WriteAllText(scoreboardfile, JsonConvert.SerializeObject(GenerateSampleScoreboard(numEntries), Formatting.Indented));

scoreboardfile = File.ReadAllText(scoreboardfile);

Expand Down Expand Up @@ -596,7 +596,7 @@ public static string RequestByUsers(string? jsontable, string scoreboardpath)

foreach (var entry in entries)
{
if (i >= start)
if (i >= start && !string.IsNullOrEmpty(entry.Name))
{
var rankData = new Dictionary<string, object>
{
Expand Down Expand Up @@ -632,15 +632,12 @@ public static string RequestByUsers(string? jsontable, string scoreboardpath)
public static Scoreboard GenerateSampleScoreboard(int numEntries)
{
Scoreboard scoreboard = new Scoreboard();
Random? random = new Random();

scoreboard.Entries = new List<ScoreboardEntry>();
scoreboard.Entries = new List<ScoreboardEntry>(numEntries);

for (int i = 1; i <= numEntries; i++)
{
string playerName = ScoreboardNameGenerator.GenerateRandomName();
int score = random.Next(100, 1000); // Generate a random score between 100 and 999
scoreboard.Entries.Add(new ScoreboardEntry { Name = playerName, Score = score });
scoreboard.Entries.Add(new ScoreboardEntry { Name = string.Empty, Score = 0 });
}

// Sort the entries by score in descending order
Expand All @@ -652,8 +649,6 @@ public static Scoreboard GenerateSampleScoreboard(int numEntries)
scoreboard.Entries[i].Rank = i + 1;
}

random = null;

return scoreboard;
}

Expand Down Expand Up @@ -763,19 +758,6 @@ public override void WriteJson(JsonWriter writer, ScoreBoardUpdate? value, JsonS
}
}

public class ScoreboardNameGenerator
{
private static Random random = new Random();

// List of silly French-sounding words to be used in the names
private static string[] sillyFrenchWords = { "Croissant", "Baguette", "Fougasse", "TarteAuFromage", "Tabernack", "UnePetiteContine", "ChuckNorris", "Pamplemousse", "JimCarrey", "Fromage" };

public static string GenerateRandomName()
{
return sillyFrenchWords[random.Next(0, sillyFrenchWords.Length)];
}
}

public class ScoreboardEntry
{
public string? Name { get; set; }
Expand Down
Loading

0 comments on commit 6f56ff2

Please sign in to comment.