Bitcoin Forum
May 07, 2024, 02:45:16 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: [Release][Source] BitcoinLottery (Bitcoin Brute Force Cracking Tool in Java)  (Read 595 times)
DeeGee
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
April 01, 2020, 01:29:42 PM
 #21

cypherion would it be possible to reshare your compiled file again for download please?
1715049916
Hero Member
*
Offline Offline

Posts: 1715049916

View Profile Personal Message (Offline)

Ignore
1715049916
Reply with quote  #2

1715049916
Report to moderator
1715049916
Hero Member
*
Offline Offline

Posts: 1715049916

View Profile Personal Message (Offline)

Ignore
1715049916
Reply with quote  #2

1715049916
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
ashraful1980
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
September 28, 2020, 06:40:33 PM
 #22

Hi Bitcointalk!
I'm not good at java and crypto algorithms, but I wanted to check how the author's code works and in addition .EXE the file looks suspicious.
Maybe because I'm not so lazy, sorry about that.

I didn't change anything in the original code just added (System.out.println) the output of some information to the console, that's all, becauce I want to see what the values genereting code.

Source:
Code:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.security.Security;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.Scanner;

import org.spongycastle.asn1.sec.SECNamedCurves;
import org.spongycastle.asn1.x9.X9ECParameters;
import org.spongycastle.crypto.digests.RIPEMD160Digest;
import org.spongycastle.crypto.params.ECDomainParameters;
import org.spongycastle.math.ec.ECPoint;

public class BitcoinLottery {
private static File BitcoinAddressen = new File("./Addys.txt");
private static String genPrivateKey;
private static BigInteger privateKeyNumber;
private static byte[] publicKey;
private static String genAddy;
private static final ECDomainParameters EC_PARAMS;
private static final BigInteger BASE58_CHUNK_MOD = BigInteger.valueOf(0x5fa8624c7fba400L);
private static final int BASE58_CHUNK_DIGITS = 10;
private static final char[] BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray();
     private static int Counter = 0;

//Generate Curve for Eliptic Curve Algo:
static {
       X9ECParameters params = SECNamedCurves.getByName("secp256k1");
       EC_PARAMS = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
   }

     public static void main(String[] args) throws FileNotFoundException {
       System.out.println("Let`s start!!!");
     while(true) {
     System.out.println("Iteration no: " + Counter);
       Counter = Counter + 1;
     Scanner AddressStream = new Scanner(BitcoinAddressen);
    
     //Generate new privatekey and convert it to hex
     privateKeyNumber = new BigInteger(256, new Random()); //random generation
     System.out.println("Private Key Number: " + privateKeyNumber);
     //Generate PublicKey to calculate Address from:
     ECPoint uncompressed = EC_PARAMS.getG().multiply(privateKeyNumber);
     publicKey = uncompressed.getEncoded(false);
     System.out.println("Public Key: " + publicKey);
    
        
     //Generate Bitcoin-Address:
     try {
             byte[] hashedPublicKey = sha256ripemd160(publicKey);
             byte[] addressBytes = new byte[1 + hashedPublicKey.length + 4];
             addressBytes[0] = (byte) (0);
             System.arraycopy(hashedPublicKey, 0, addressBytes, 1, hashedPublicKey.length);
             MessageDigest digestSha = MessageDigest.getInstance("SHA-256");
             digestSha.update(addressBytes, 0, addressBytes.length - 4);
             byte[] check = digestSha.digest(digestSha.digest());
             System.arraycopy(check, 0, addressBytes, hashedPublicKey.length + 1, 4);
             genAddy = encodeBase58(addressBytes);
             System.out.println("Gen Bitcoin-Address: " + genAddy);
         }
     catch (NoSuchAlgorithmException e) {
         }
    
     //Check if Address is in our List:
     while(AddressStream.hasNextLine()){
     if(AddressStream.nextLine().equals(genAddy)){
     System.out.println("!!!!SUCCESS!!!!");
       //Convert PrivateKey to Wallet Input Format:
       genPrivateKey = privateKeyNumber.toString(16);
             System.out.println("Convert PK to Wallet: " + genPrivateKey);
       genPrivateKey = "80"+genPrivateKey;
             System.out.println("Convert PK to Wallet +80 (magic): " + genPrivateKey);
       try {
MessageDigest digestSha = MessageDigest.getInstance("SHA-256");
byte[] hash = digestSha.digest(genPrivateKey.getBytes(StandardCharsets.UTF_8));
hash = digestSha.digest(hash);
String checksum = "";

for(int i=1; i < 5; i++) {
 checksum = checksum + hash[i];
}

genPrivateKey = genPrivateKey + checksum;
genPrivateKey = encodeBase58(genPrivateKey.getBytes(StandardCharsets.UTF_8));
System.out.println("Final Private Key: " + genPrivateKey);
writeStuffToFile();
} catch (NoSuchAlgorithmException e) {
writeStuffToFile();
}
      
     }
      }
     AddressStream.close();  
     }
   }
    
     public static void writeStuffToFile() {
     try {
        String Info = "Private Key: "+ privateKeyNumber + " HEX: " + privateKeyNumber.toString(16) + " WIF: "+ genPrivateKey;
        Files.write(Paths.get("PrivateKeys.txt"), Info.getBytes(), StandardOpenOption.APPEND);
     }catch (IOException e) {
     System.out.println("KEY FOUND BUT THERE WAS A PROBLEM WRITING TO FILE!:");
        System.out.println("Private Key: "+ privateKeyNumber + " HEX: " + privateKeyNumber.toString(16));
        System.out.println("WIF: "+ genPrivateKey);
        System.out.println();
     }
     }
     public static String encodeBase58(byte[] input) {
         if (input == null) {
             return null;
         }
         StringBuilder str = new StringBuilder((input.length * 350) / 256 + 1);
         BigInteger bn = new BigInteger(1, input);
         long rem;
         while (true) {
             BigInteger[] divideAndRemainder = bn.divideAndRemainder(BASE58_CHUNK_MOD);
             bn = divideAndRemainder[0];
             rem = divideAndRemainder[1].longValue();
             if (bn.compareTo(BigInteger.ZERO) == 0) {
                 break;
             }
             for (int i = 0; i < BASE58_CHUNK_DIGITS; i++) {
                 str.append(BASE58[(int) (rem % 58)]);
                 rem /= 58;
             }
         }
         while (rem != 0) {
             str.append(BASE58[(int) (rem % 58)]);
             rem /= 58;
         }
         str.reverse();
         int nLeadingZeros = 0;
         while (nLeadingZeros < input.length && input[nLeadingZeros] == 0) {
             str.insert(0, BASE58[0]);
             nLeadingZeros++;
         }
         return str.toString();
     }
  
     public static byte[] sha256ripemd160(byte[] publicKey) {
         try {
             MessageDigest sha256 = MessageDigest.getInstance("SHA-256");
             byte[] sha256hash = sha256.digest(publicKey);
             RIPEMD160Digest ripemd160Digest = new RIPEMD160Digest();
             ripemd160Digest.update(sha256hash, 0, sha256hash.length);
             byte[] hashedPublicKey = new byte[20];
             ripemd160Digest.doFinal(hashedPublicKey, 0);
             return hashedPublicKey;
         } catch (NoSuchAlgorithmException e) {
             throw new RuntimeException(e);
         }
     }
}

How I tried to set up (Windows OS):
  - compile the Source
    -- downloaded and installed JDK
    -- downloaded Spongy Castle and copied jar(s) to the ..\Java\jdk1.8.0\jre\lib\ext\ directory
    -- created folder BitcoinLottery (on desktop for example) containing 2 files within "BitcoinLottery.java" and "Manifest.txt", into the "BitcoinLottery.java" file pasted code from top, into the "Manifest.txt" pasted
Code:
Main-class: BitcoinLottery
   -- started cmd.exe and tried run command:
Code:
javac C:\Users\USER_NAME\Desktop\BitcoinLottery\BitcoinLottery.java
   -- run next command:
Code:
jar cfvm C:\Users\USER_NAME\Desktop\BitcoinLottery\BitcoinLottery.jar C:\Users\USER_NAME\Desktop\BitcoinLottery\Manifest.txt C:\Users\USER_NAME\Desktop\BitcoinLottery\BitcoinLottery.class
   -- created empty text file called "PrivateKeys.txt", download list with the addresses for crack and name it "Addys.txt" and saved both into the BitcoinLottery folder
    -- run the last commnad into console: java -jar C:\Users\USER_NAME\Desktop\BitcoinLottery\BitcoinLottery.jar


If everythings all right you could see something like that:
http://i67.tinypic.com/9uqagk.jpg

I don't know is that correctly works, i mean methods and algorithms, but generation values happen.
It somehow works.


Note:
  - The zip file blelow does contain all components for start. Before run "BitcoinLottery.jar" in console, computer need to has JRE


Download: https://sundryfiles.com/3wg

References:
http://www.bouncycastle.org/documentation.html
Tutorial on how to make a Java JAR file with the command prompt

P.S.: I'm not native English speaker and hope you'll not have any problems with reading and running.



Hi,
I was converted the BitcoinLottery.java to BitcoinLottery.py as bellow. It was found some error massage; somebody help to modify for working accurately.


#!/usr/bin/env python
""" generated source for module HelloWorld """
from __future__ import print_function
class BitcoinLottery(object):
    """ generated source for class BitcoinLottery """
    BitcoinAddressen = File("Addys.txt")
    genPrivateKey = None
    privateKeyNumber = None
    publicKey = []
    genAddy = None
    EC_PARAMS = None
    BASE58_CHUNK_MOD = BigInteger.valueOf(0x5fa8624c7fba400L)
    BASE58_CHUNK_DIGITS = 10
    BASE58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".toCharArray()

    #  private static int Counter = 0;
    # Generate Curve for Eliptic Curve Algo:
    params = SECNamedCurves.getByName("secp256k1")

    @classmethod
    def main(cls, args):
        """ generated source for method main """
        while True:
            # print("Iteration no:" + Counter);
            AddressStream = Scanner(cls.BitcoinAddressen)
            # Generate new privatekey and convert it to hex
            cls.privateKeyNumber = BigInteger(256, Random())
            # random generation
            # Generate PublicKey to calculate Address from:
            uncompressed = cls.EC_PARAMS.getG().multiply(cls.privateKeyNumber)
            cls.publicKey = uncompressed.getEncoded(False)
            # Generate Bitcoin-Address:
            try:
                hashedPublicKey = sha256ripemd160(cls.publicKey)
                addressBytes = [None] * 4 + len(hashedPublicKey)
                addressBytes[0] = int((0))
                System.arraycopy(hashedPublicKey, 0, addressBytes, 1, )
                digestSha = MessageDigest.getInstance("SHA-256")
                digestSha.update(addressBytes, 0, len(addressBytes))
                check = digestSha.digest(digestSha.digest())
                System.arraycopy(check, 0, addressBytes, len(hashedPublicKey), 4)
                cls.genAddy = encodeBase58(addressBytes)
            except NoSuchAlgorithmException as e:
                pass
            # Check if Address is in our List:
            while AddressStream.hasNextLine():
                if AddressStream.nextLine() == cls.genAddy:
                    print("!!!!SUCCESS!!!!")
                    # Convert PrivateKey to Wallet Input Format:
                    cls.genPrivateKey = cls.privateKeyNumber.toString(16)
                    cls.genPrivateKey = "80" + cls.genPrivateKey
                    try:
                        digestSha = MessageDigest.getInstance("SHA-256")
                        hash = digestSha.digest(cls.genPrivateKey.getBytes(StandardCharsets.UTF_8))
                        hash = digestSha.digest(hash)
                        checksum = ""
                        i = 1
                        while i < 5:
                            checksum = checksum + hash
                            i += 1
                        cls.genPrivateKey = cls.genPrivateKey + checksum
                        cls.genPrivateKey = encodeBase58(cls.genPrivateKey.getBytes(StandardCharsets.UTF_8))
                        writeStuffToFile()
                    except NoSuchAlgorithmException as e:
                        writeStuffToFile()
            AddressStream.close()

    @classmethod
    def writeStuffToFile(cls):
        """ generated source for method writeStuffToFile """
        try:
            Info = "Private Key: " + cls.privateKeyNumber + " HEX: " + cls.privateKeyNumber.toString(16) + " WIF: " + cls.genPrivateKey
            Files.write(Paths.get("PrivateKeys.txt"), Info.getBytes(), StandardOpenOption.APPEND)
        except IOError as e:
            print("KEY FOUND BUT THERE WAS A PROBLEM WRITING TO FILE!:")
            print("Private Key: " + cls.privateKeyNumber + " HEX: " + cls.privateKeyNumber.toString(16))
            print("WIF: " + cls.genPrivateKey)
            print()

    @classmethod
    def encodeBase58(cls, input):
        """ generated source for method encodeBase58 """
        if input == None:
            return None
        str_ = StringBuilder((len(input)) / 256 + 1)
        bn = BigInteger(1, input)
        rem = long()
        while True:
            divideAndRemainder = bn.divideAndRemainder(cls.BASE58_CHUNK_MOD)
            bn = divideAndRemainder[0]
            rem = divideAndRemainder[1].longValue()
            if bn.compareTo(BigInteger.ZERO) == 0:
                break
            i = 0
            while i < cls.BASE58_CHUNK_DIGITS:
                str_.append(cls.BASE58[int((rem % 58))])
                rem /= 58
                i += 1
        while rem != 0:
            str_.append(cls.BASE58[int((rem % 58))])
            rem /= 58
        str_.reverse()
        nLeadingZeros = 0
        while input[nLeadingZeros] == 0 and len(input):
            str_.insert(0, cls.BASE58[0])
            nLeadingZeros += 1
        return str_.__str__()

    @classmethod
    def sha256ripemd160(cls, publicKey):
        """ generated source for method sha256ripemd160 """
        try:
            sha256 = MessageDigest.getInstance("SHA-256")
            sha256hash = sha256.digest(publicKey)
            ripemd160Digest = RIPEMD160Digest()
            ripemd160Digest.update(sha256hash, 0, )
            hashedPublicKey = [None] * 20
            ripemd160Digest.doFinal(hashedPublicKey, 0)
            return hashedPublicKey
        except NoSuchAlgorithmException as e:
            raise RuntimeException(e)
Pages: « 1 [2]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!