du1462 2017-06-23 18:11
浏览 69
已采纳

Go语言:编译期间出错

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?

  • 写回答

1条回答 默认 最新

  • duanqiang5722 2017-06-23 18:53
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据