Last active
January 18, 2022 13:48
-
-
Save itherunder/5967a11015113a8e9ee6e34e404b5ca4 to your computer and use it in GitHub Desktop.
生成以太坊地址和私钥,Golang版本,记得go get go-ethereum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"crypto/ecdsa" | |
crand "crypto/rand" | |
"fmt" | |
"io" | |
"log" | |
"net/smtp" | |
"os" | |
"strings" | |
"github.com/ethereum/go-ethereum/crypto" | |
) | |
//错误处理 | |
func handle(why string, e error) { | |
if e == io.EOF { | |
return | |
} | |
if e != nil { | |
fmt.Println(why, "错误为:", e) | |
} | |
} | |
var balance_addrs map[string]bool | |
func ReadLine(filename string) { | |
// bfile, e := os.OpenFile("", os.O_RDONLY, 0761) | |
bfile, e := os.OpenFile(filename, os.O_RDONLY, 0761) | |
handle("文件打开失败!", e) | |
defer bfile.Close() | |
buf := bufio.NewReader(bfile) | |
for { | |
line, e := buf.ReadString('\n') | |
handle("readfile error", e) | |
line = strings.TrimSpace(line) | |
addr := strings.Split(line, "#")[0] | |
balance_addrs[addr] = true | |
} | |
} | |
func SendMail(mail, addr, pk string) { | |
auth := smtp.PlainAuth("", "$YOUR QQ EMAIL$", "$EMAIL PASS$", "smtp.qq.com") | |
to := []string{"$TO EMAIL$"} | |
str := fmt.Sprintf("From:$YOUR EMAIL$\r\nTo:$TO MAIL$\r\nSubject:verifycode\r\n\r\n您的被破解地址为:%s,私钥为:%s\r\n", addr, pk) //邮件格式 | |
msg := []byte(str) | |
err := smtp.SendMail("smtp.qq.com:25", auth, "$YOUR QQ EMAIL$", to, msg) | |
if err != nil { | |
log.Fatal(err.Error()) | |
} | |
log.Println(mail, addr, pk) | |
} | |
func main() { | |
file, e := os.OpenFile("./pri_addr.txt", os.O_WRONLY|os.O_CREATE, 0761) | |
handle("文件打开失败!", e) | |
defer file.Close() | |
balance_addrs = make(map[string]bool) | |
ReadLine("a_results_0.txt") | |
log.Printf("stage1: %d\n", len(balance_addrs)) | |
ReadLine("a_results_1.txt") | |
log.Printf("stage2: %d\n", len(balance_addrs)) | |
ReadLine("a_results_2.txt") | |
log.Printf("stage3: %d\n", len(balance_addrs)) | |
ReadLine("a_results_3.txt") | |
log.Printf("stage4: %d\n", len(balance_addrs)) | |
ReadLine("a_results_4.txt") | |
log.Printf("开始开始: %d\n", len(balance_addrs)) | |
cnt := 0 | |
// for i := 0; i < 100000; i++ { | |
for { | |
cnt++ | |
if cnt%1000000 == 0 { | |
log.Println(cnt) | |
} | |
privateKeyECDSA, err := ecdsa.GenerateKey(crypto.S256(), crand.Reader) | |
//fmt.Printf("%x",privateKeyECDSA.D.Bytes()) | |
if err != nil { | |
return | |
} | |
address := crypto.PubkeyToAddress(privateKeyECDSA.PublicKey) | |
addr := address.String() | |
addr = strings.ToLower(addr) | |
// fmt.Printf("privateKey: %x", privateKeyECDSA.D.Bytes()) | |
// fmt.Println("\taddr :", addr) | |
if _, ok := balance_addrs[addr]; ok { | |
pk := fmt.Sprintf("%x", privateKeyECDSA.D.Bytes()) | |
file.WriteString(pk + "#" + addr + "\n") | |
SendMail("$YOUR EMAIL$", addr, pk) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment