Reset connection PoC
This commit is contained in:
@@ -2,6 +2,9 @@ package interception
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
ct "github.com/florianl/go-conntrack"
|
||||
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portmaster/network/packet"
|
||||
@@ -49,3 +52,24 @@ func Stop() error {
|
||||
|
||||
return stop()
|
||||
}
|
||||
|
||||
func CloseAllConnections() error {
|
||||
nfct, err := ct.Open(&ct.Config{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = nfct.Close() }()
|
||||
|
||||
connections, err := nfct.Dump(ct.Conntrack, ct.IPv4)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Criticalf("Number of connections: %d", len(connections))
|
||||
for _, connection := range connections {
|
||||
fmt.Printf("[%2d] %s - %s\n", connection.Origin.Proto.Number, connection.Origin.Src, connection.Origin.Dst)
|
||||
err := nfct.Delete(ct.Conntrack, ct.IPv4, connection)
|
||||
log.Errorf("Error deleting connection %q", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user