Skip to content

Instantly share code, notes, and snippets.

@joshjohanning
Created August 24, 2022 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshjohanning/355380de17e0ff507f71d66bf4ec8123 to your computer and use it in GitHub Desktop.
Save joshjohanning/355380de17e0ff507f71d66bf4ec8123 to your computer and use it in GitHub Desktop.
sample vulnerable .NET C# code for CodeQL
using System;
using System.Security.Cryptography;
class WeakEncryption
{
public static byte[] encryptString()
{
SymmetricAlgorithm serviceProvider = new DESCryptoServiceProvider();
byte[] key = { 16, 22, 240, 11, 18, 150, 192, 21 };
serviceProvider.Key = key;
ICryptoTransform encryptor = serviceProvider.CreateEncryptor();
String message = "Hello World";
byte[] messageB = System.Text.Encoding.ASCII.GetBytes(message);
return encryptor.TransformFinalBlock(messageB, 0, messageB.Length);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment