-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
58 lines (48 loc) · 1.21 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
package main
import (
"flag"
"fmt"
"net"
"github.com/hexoul/ether-stealer/crypto"
"github.com/hexoul/ether-stealer/steal"
"github.com/korovkin/limiter"
)
var (
concurrency *int
iteration *int
identifier *string
)
func init() {
concurrency = flag.Int("concurrency", 10, "The number of threads can be executed concurrently.")
iteration = flag.Int("iteration", 0, "The number of iterations. If set, it will be terminated within a finite time.")
identifier = flag.String("id", "anonymous", "An identifier of a client.")
}
func main() {
var ip string
if addrs, err := net.InterfaceAddrs(); err == nil {
for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && ipnet.IP.To4() != nil {
ip = ipnet.IP.String()
}
}
}
flag.Parse()
fmt.Printf("Start to steal!!! from <%s> by <%s>\n", ip, *identifier)
limit := limiter.NewConcurrencyLimiter(*concurrency)
stealer := steal.New()
steal := func() {
pubkey, privkey := crypto.GenerateKeyPair()
addr := crypto.PubkeyToAddress(pubkey)
limit.Execute(func() { stealer.Steal(addr, privkey) })
}
if *iteration > 0 {
for i := 0; i < *iteration; i++ {
steal()
}
limit.WaitAndClose()
return
}
for {
steal()
}
}