Skip to content

Instantly share code, notes, and snippets.

@prettycode
Created December 2, 2023 14:54
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 prettycode/b682cf780783175ecb853c7af19f8822 to your computer and use it in GitHub Desktop.
Save prettycode/b682cf780783175ecb853c7af19f8822 to your computer and use it in GitHub Desktop.
Console app to launch cubitcrack.exe with specific range
// https://privatekeyfinder.io/bitcoin-puzzle/
using System;
using System.Diagnostics;
using System.Globalization;
using System.Numerics;
using System.Security.Cryptography;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
var low = BigInteger.Parse("2000000000000000", NumberStyles.HexNumber);
var high = BigInteger.Parse("3FFFFFFFFFFFFFFFF", NumberStyles.HexNumber);
var randomKeyspace = GenerateRandomBigInteger(low, high);
const string crackerPath = "C:\\BitCrack\\x64\\Debug\\cubitcrack.exe";
const string addressToCrack = "13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so";
string privateKeyOutputPath = $"randkey.{DateTime.UtcNow.ToString("o").Replace(":", "-")}.txt";
string command = $"{crackerPath} --keyspace {randomKeyspace:X} {addressToCrack} -o {privateKeyOutputPath}";
Console.WriteLine($"Opening separate command prompt running:\n\n{command}");
Process.Start(new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = $"/c {command}",
RedirectStandardOutput = false,
UseShellExecute = true,
CreateNoWindow = false
});
Console.WriteLine("\nPress Enter key to exit.");
Console.ReadLine();
}
static BigInteger GenerateRandomBigInteger(BigInteger minValue, BigInteger maxValue)
{
if (minValue > maxValue)
{
throw new ArgumentOutOfRangeException($"'{nameof(minValue)}' should not be greater than '{nameof(maxValue)}'.");
}
BigInteger result;
using (var random = new RNGCryptoServiceProvider())
{
byte[] bytes = maxValue.ToByteArray();
do
{
random.GetBytes(bytes);
result = new BigInteger(bytes);
}
while (result < minValue || result >= maxValue);
}
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment