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.

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

报告相同问题?

悬赏问题

  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加