Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Reelix
Created November 17, 2022 20:20
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 Reelix/1d97150a855698b611f78d9f408f2528 to your computer and use it in GitHub Desktop.
Save Reelix/1d97150a855698b611f78d9f408f2528 to your computer and use it in GitHub Desktop.
Brute Force Numerical Cryptography Ciphertext
static void Main(string[] args)
{
Console.WriteLine("Input path to numerical ciphertext.");
string path = Console.ReadLine();
string input = File.ReadAllText(path);
int[] intList = input.Split(' ').Select(int.Parse).ToArray();
int intListLength = intList.Length;
StringBuilder final = new StringBuilder();
for (int n = 1; n < 100000; n++)
{
if (n % 100 == 0)
{
Console.WriteLine("n: " + n);
}
for (int d = 1; d < 100000; d++)
{
final.Clear();
foreach (int bla in intList)
{
BigInteger woof = BigInteger.ModPow(bla, d, n);
if (((int)woof > 126 || (int)woof < 32) && ((int)woof != 10))
{
break;
}
char c = (char)woof;
final.Append(c);
}
if (final.Length == intListLength)
{
Console.WriteLine("Found!");
Console.WriteLine("n: " + n.ToString());
Console.WriteLine("d: " + d.ToString());
Console.WriteLine(final);
Console.WriteLine("zz");
Console.ReadLine();
}
}
}
}
@Reelix
Copy link
Author

Reelix commented Nov 17, 2022

Created to test out brute force speed on https://tryhackme.com/room/willow

Found some unexpected results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment