Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Inspired by:
- * https://www.reddit.com/r/btc/comments/4dkw1q/no_one_cracked_05btc_paperwallet_with_easy/ ( https://archive.is/1y58e )
- *
- * A very inefficient way to generate every possible password meeting the following criteria:
- *
- * 1: Password is 6 characters long
- * 2: Password is made up of ONLY letters from the US alphabet, lower and upper case (a-z and A-Z). No symbols or numbers.
- * 3: If you divide the number of uppercase letters by the number of lower case letters in the password, you get an integer
- * (assume this means there are 3, 4, or 5 upper-case letters in the password).
- *
- * Then write every 100,000 passwords out to a new file, which can be used to attempt to actually bruteforce the passwords in the file(s) using something like
- * https://github.com/Dirbaio/bip38-cracker ( https://archive.is/OrHRc )
- * Note that BIP-38 intentionally makes it time consuming to attempt passwords, so trying all ~20 billion (52^6) in one go is unrealistic.
- * Hence breaking them up into subsets of 100,000 passwords.
- */
- using UnityEngine;
- using System.Collections;
- using System;
- using System.Text;
- using System.IO;
- using System.Runtime.Serialization.Formatters.Binary;
- // Attach this component to an object in Unity and let it do its thing.
- public class BruteForce : MonoBehavior {
- public int startPos1 = 0;
- public int startPos2 = 0;
- public int startPos3 = 0;
- public int startPos4 = 0;
- public int startPos5 = 0;
- public int startPos6 = 0;
- public int startFile = 0;
- string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- string outputFile = "bf.txt";
- void Start() {
- if (!File.Exists(outputFile)) {
- File.Create(outputFile);
- }
- StartCoroutine(GenerateFile());
- }
- IEnumerator GenerateFile() {
- yield return new WaitForSeconds(0.25f);
- StringBuilder result = new StringBuilder();
- int linesAdded = 0;
- int filesWritten = startFile;
- float timer = Time.realtimeSinceStartup;
- #region sanity checking
- if (startPos6 >= 52) {
- startPos6 = 0;
- startPos5++;
- }
- if (startPos5 >= 52) {
- startPos5 = 0;
- startPos4++;
- }
- if (startPos4 >= 52) {
- startPos4 = 0;
- startPos3++;
- }
- if (startPos3 >= 52) {
- startPos3 = 0;
- startPos2++;
- }
- if (startPos2 >= 52) {
- startPos2 = 0;
- startPos1++;
- }
- #endregion //sanity checking
- int chr1 = startPos1;
- int chr2 = startPos2;
- int chr3 = startPos3;
- int chr4 = startPos4;
- int chr5 = startPos5;
- int chr6 = startPos6;
- Debug.Log("Starting at positions: " + chr1 + " " + chr2 + " " + chr3 + " " + chr4 + " " + chr5 + " " + chr6 +
- " Chars length is: " + chars.Length);
- yield return 0;
- for (chr1 = startPos1; chr1 < chars.Length; chr1++) {
- startPos1 = 0;
- for (chr2 = startPos2; chr2 < chars.Length; chr2++) {
- startPos2 = 0;
- for (chr3 = startPos3; chr3 < chars.Length; chr3++) {
- startPos3 = 0;
- for (chr4 = startPos4; chr4 < chars.Length; chr4++) {
- startPos4 = 0;
- for (chr5 = startPos5; chr5 < chars.Length; chr5++) {
- startPos5 = 0;
- for (chr6 = startPos6; chr6 < chars.Length; chr6++) {
- startPos6 = 0;
- if (PwdMeetsCriteria(chr1, chr2, chr3, chr4, chr5, chr6)) {
- string pwd = chars.Substring(chr1, 1) + chars.Substring(chr2, 1) + chars.Substring(chr3, 1) + chars.Substring(chr4, 1) + chars.Substring(chr5, 1) + chars.Substring(chr6, 1);
- result.AppendLine(pwd);
- linesAdded++;
- if (linesAdded >= 100000) {
- File.AppendAllText(String.Format("bf/bf{0:D6}.txt", filesWritten), result.ToString(), new System.Text.UTF8Encoding());
- filesWritten++;
- Debug.LogWarning("Writing out file #" + filesWritten.ToString("N0") +
- ".\nCurrently done with: " + chr1 + " " + chr2 + " " + chr3 + " " + chr4 + " " + chr5 + " " + (chr6 + 1));
- // reset these things back to the beginning
- linesAdded = 0;
- result = new StringBuilder();
- //yield return 0;
- }
- } else {
- chr6 = (chr6 == 0) ? 25 : 51;
- }
- if (Time.realtimeSinceStartup > (timer + 1)) {
- //Debug.Log("RealTime Since Startup: " + Time.realtimeSinceStartup);
- // reset timer and display progress
- timer = Time.realtimeSinceStartup;
- Debug.Log("Progress: " + ((UInt64)(((UInt64)chr1 * 52L * 52L * 52L * 52L * 52L) + ((UInt64)chr2 * 52L * 52L * 52L * 52L) + ((UInt64)chr3 * 52L * 52L * 52L) + ((UInt64)chr4 * 52L * 52L) + ((UInt64)chr5 * 52L) + ((UInt64)chr6))).ToString("N0") +
- " of 19,763,298,048" +
- ".\nLines added: " + linesAdded.ToString("N0") +
- ".\nCurrently done with: " + chr1 + " " + chr2 + " " + chr3 + " " + chr4 + " " + chr5 + " " + (chr6 + 1));
- yield return 0;
- }
- }
- }
- }
- }
- }
- }
- if (linesAdded > 0) {
- File.AppendAllText(String.Format("bf/bf{0:D6}.txt", filesWritten), result.ToString(), new System.Text.UTF8Encoding());
- filesWritten++;
- }
- Debug.Log("FINISHED! Currently done with: " + chr1 + " " + chr2 + " " + chr3 + " " + chr4 + " " + chr5 + " " + chr6);
- }
- bool PwdMeetsCriteria(int chr1, int chr2, int chr3, int chr4, int chr5, int chr6) {
- int lower = 0;
- int upper = 0;
- if (chr1 < 26) { lower++; } else { upper++; }
- if (chr2 < 26) { lower++; } else { upper++; }
- if (chr3 < 26) { lower++; } else { upper++; }
- if (chr4 < 26) { lower++; } else { upper++; }
- if (chr5 < 26) { lower++; } else { upper++; }
- if (chr6 < 26) { lower++; } else { upper++; }
- if (upper == 3 || upper == 4 || upper == 5) {
- return true;
- } else {
- return false;
- }
- }
- }
Add Comment
Please, Sign In to add comment