I'm trying to compile this program written in Go on Windows 10 but i get these errors:
warpwallet_cracker.go:12:2: cannot find package "github.com/vsergeev/btckeygenie/btckey" in any of:
C:\Go\src\github.com\vsergeev\btckeygenie\btckey (from $GOROOT)
C:\Users\user\go\src\github.com\vsergeev\btckeygenie\btckey (from $GOPATH)
warpwallet_cracker.go:4:5: cannot find package "golang.org/x/crypto/pbkdf2" in any of:
C:\Go\src\golang.org\x\crypto\pbkdf2 (from $GOROOT)
C:\Users\user\go\src\golang.org\x\crypto\pbkdf2 (from $GOPATH)
warpwallet_cracker.go:5:2: cannot find package "golang.org/x/crypto/scrypt" in any of:
C:\Go\src\golang.org\x\crypto\scrypt (from $GOROOT)
C:\Users\user\go\src\golang.org\x\crypto\scrypt (from $GOPATH)
Github: https://github.com/nachowski/warpwallet_cracker
Here's the code:
package main
import (
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
"bytes"
"crypto/sha256"
"fmt"
"time"
"os"
"math/rand"
"github.com/vsergeev/btckeygenie/btckey"
)
const letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
func random(r *rand.Rand, n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytes[r.Intn(62)]
}
return string(b)
}
func main () {
r := rand.New(rand.NewSource(time.Now().Unix()))
var address string
saltValue := ""
if len(os.Args) >= 2 {
address = os.Args[1]
if len(os.Args) == 3 {
saltValue = os.Args[2]
} else {
saltValue = "";
}
} else {
fmt.Printf("Usage: %s [Address] [Salt - optional]
", os.Args[0])
os.Exit(0)
}
fmt.Printf("Using address \"%s\" and salt \"%s\"
", address, saltValue)
tries := 0
start := time.Now()
for {
passphraseValue := random(r, 8)
result := bruteforce(passphraseValue, saltValue, address);
if result != "" {
fmt.Printf("Found! Passphrase %s
", passphraseValue)
os.Exit(0)
} else {
tries += 1
fmt.Printf("Tried %d passphrases in %s [last passphrase: %s]", tries, time.Since(start), passphraseValue)
}
}
}
func bruteforce(passphraseValue string, saltValue string, address string) string {
var priv btckey.PrivateKey
var err error
pass := fmt.Sprint(passphraseValue, "\x01")
salt := fmt.Sprint(saltValue, "\x01")
key, _ := scrypt.Key([]byte(pass), []byte(salt), 262144, 8, 1, 32)
pass = fmt.Sprint(passphraseValue, "\x02")
salt = fmt.Sprint(saltValue, "\x02")
key2 := pbkdf2.Key([]byte(pass), []byte(salt), 65536, 32, sha256.New)
var result bytes.Buffer
for i := 0; i < len(key); i++ {
result.WriteByte(key[i] ^ key2[i])
}
err = priv.FromBytes(result.Bytes())
if err != nil {
fmt.Printf("Error importing private key: %s [%s]
", err, passphraseValue)
return ""
}
address_uncompressed := priv.ToAddressUncompressed()
if (address_uncompressed == address) {
return passphraseValue
}
return ""
}
I don't know what the problem can be, can anyone help me?
You need to install the dependencies using the "go get" command.
You don't have the dependencies installed, as stated in the error message. Look a little closer at the error messages, you are getting three different errors. One for each package that is not part of the go standard libary.
When you try to import a package that is not part of the go standard library, the go compiler looks under the $GOROOT path and the $GOPATH path to try to find a package matching the name that you tried to import. If it is not found the compiler throws the error that you were seeing above. As @Adrian said, you can run:
go get ./...
to automatically download all of your dependencies.