Created
November 17, 2022 20:20
-
-
Save Reelix/1d97150a855698b611f78d9f408f2528 to your computer and use it in GitHub Desktop.
Brute Force Numerical Cryptography Ciphertext
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Created to test out brute force speed on https://tryhackme.com/room/willow
Found some unexpected results.