Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CrustySean committed May 2, 2021
0 parents commit 1f9cb6f
Show file tree
Hide file tree
Showing 68 changed files with 12,668 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Switch
/build
*.elf
*.nso
*.nro
*.nsp
*.nacp
*.npdm
*.pfs0

# VS
/.vs
/packages
/BCAT-Toolbox/bin
/BCAT-Toolbox/obj
25 changes: 25 additions & 0 deletions BCAT-Toolbox.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30517.126
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BCAT-Toolbox", "BCAT-Toolbox\BCAT-Toolbox.csproj", "{796200EB-5DBA-4504-A3D2-946116335D5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{796200EB-5DBA-4504-A3D2-946116335D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{796200EB-5DBA-4504-A3D2-946116335D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{796200EB-5DBA-4504-A3D2-946116335D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{796200EB-5DBA-4504-A3D2-946116335D5E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F9CE1C8A-80B9-4610-880B-E765DC2BE6BA}
EndGlobalSection
EndGlobal
56 changes: 56 additions & 0 deletions BCAT-Toolbox/AesCrypto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace BcatToolbox
{
public class AesCrypto
{
public static byte[] PerformAesCTR(byte[] SourceBuffer, int Offset, int Size, byte[] key, byte[] iv)
{
byte[] encCounter = new byte[0x10];
byte[] decryptedBuffer = new byte[Size];
byte[] ctr = iv;

Aes aes = Aes.Create();
aes.Mode = CipherMode.ECB;
aes.BlockSize = 128;
aes.KeySize = key.Length * 8;
aes.Key = key;

for (int i = Offset; i < Size; i += 0x10)
{
using (var transform = aes.CreateEncryptor())
{

int transed = 0;
for (int j = 0; j < 0x10; j += transed)
{
transed = transform.TransformBlock(ctr, j, 0x10, encCounter, j);
}

int rest = Size - i;
if (rest > 0x10) rest = 0x10;

//xor encrypted counter with ciphertext
for (int j = 0; j < rest; j++)
{
decryptedBuffer[i + j] = (byte)(encCounter[j] ^ SourceBuffer[i + j]);
}
//increment counter
for (var j = ctr.Length - 1; j >= 0; j--)
{
if (++ctr[j] != 0)
break;
}
}
}

return decryptedBuffer;
}
}
}
27 changes: 27 additions & 0 deletions BCAT-Toolbox/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<probing privatePath="lib;libs" xmlns="" />
</assemblyBinding>
</runtime>
</configuration>
Loading

0 comments on commit 1f9cb6f

Please sign in to comment.