-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
74 lines (66 loc) · 1.95 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"crypto/ecdsa"
"flag"
"fmt"
"math/rand"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/holiman/uint256"
)
func getAddress(devContractAddress common.Address, initCodeHash []byte, p string, s string) {
for {
i := rand.Uint64()
salt := uint256.NewInt(i).Bytes32()
address := crypto.CreateAddress2(devContractAddress, salt, initCodeHash).String()
if strings.HasPrefix(address, p) && strings.HasSuffix(address, s) {
fmt.Println(i)
fmt.Println(address)
fmt.Println()
}
}
}
func getAddressEoa(p string, s string) {
for {
privateKey, _ := crypto.GenerateKey()
publicKey := privateKey.Public()
publicKeyECDSA, _ := publicKey.(*ecdsa.PublicKey)
address := crypto.PubkeyToAddress(*publicKeyECDSA).String()
if strings.HasPrefix(address, p) && strings.HasSuffix(address, s) {
fmt.Println(address)
privateKeyBytes := crypto.FromECDSA(privateKey)
fmt.Println(hexutil.Encode(privateKeyBytes))
fmt.Println()
}
}
}
var (
address = flag.String("a", "", "dev contract address")
byteCode = flag.String("i", "", "init byte code")
prefix = flag.String("p", "", "prefix of address")
suffix = flag.String("s", "", "suffix of address")
)
func main() {
flag.Parse()
p := "0x" + *prefix
s := *suffix
fmt.Println("[+] Start!")
if *address == "" {
go getAddressEoa(p, s)
go getAddressEoa(p, s)
go getAddressEoa(p, s)
go getAddressEoa(p, s)
getAddressEoa(p, s)
} else {
devContractAddress := common.BytesToAddress(common.FromHex(*address))
initByteCode := common.FromHex(*byteCode)
initCodeHash := crypto.Keccak256(initByteCode)
go getAddress(devContractAddress, initCodeHash, p ,s)
go getAddress(devContractAddress, initCodeHash, p ,s)
go getAddress(devContractAddress, initCodeHash, p ,s)
go getAddress(devContractAddress, initCodeHash, p ,s)
getAddress(devContractAddress, initCodeHash, p ,s)
}
}