Skip to content

Commit

Permalink
Update the packets seen count in the database when added a new packet
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr. Brandon Wiley committed Mar 22, 2018
1 parent 8293ba5 commit de01d30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 5 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,12 @@ func capture(dataset string, allowBlock bool, port *string) {
}

func usage() {
fmt.Println("client-cli capture [protocol] [dataset] <port>")
fmt.Println("Example: client-cli capture testing allow")
fmt.Println("Example: client-cli capture testing allow 80")
fmt.Println("Example: client-cli capture testing block")
fmt.Println("Example: client-cli capture testing block 443")
fmt.Println("AdversaryLabClient capture [protocol] [dataset] <port>")
fmt.Println("Example: AdversaryLabClient capture testing allow")
fmt.Println("Example: AdversaryLabClient capture testing allow 80")
fmt.Println("Example: AdversaryLabClient capture testing block")
fmt.Println("Example: AdversaryLabClient capture testing block 443")
fmt.Println()
fmt.Println("client-cli rules [protocol]")
fmt.Println("Example: client-client rules HTTP")
os.Exit(1)
}

Expand Down
8 changes: 8 additions & 0 deletions protocol/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ import (
)

const (
packetStatsKey = "Packet:Stats"

allowedConnectionsKey = "Allowed:Connections"
allowedIncomingKey = "Allowed:Incoming:Packets"
allowedOutgoingKey = "Allowed:Outgoing:Packets"

allowedIncomingDatesKey = "Allowed:Incoming:Dates"
allowedOutgoingDatesKey = "Allowed:Outgoing:Dates"

allowedPacketsSeenKey = "Allowed:Connections:Seen"

blockedConnectionsKey = "Blocked:Connections"
blockedIncomingKey = "Blocked:Incoming:Packets"
blockedOutgoingKey = "Blocked:Outgoing:Packets"

blockedIncomingDatesKey = "Blocked:Incoming:Dates"
blockedOutgoingDatesKey = "Blocked:Outgoing:Dates"

blockedPacketsSeenKey = "Blocked:Connections:Seen"
)

// Client holds the connection to the Redis database
Expand Down Expand Up @@ -77,12 +83,14 @@ func (client Client) AddTrainPacket(dataset string, allowBlock bool, conn Connec
client.conn.Do("hset", allowedIncomingDatesKey, connectionIDString, incomingTime)
client.conn.Do("hset", allowedOutgoingDatesKey, connectionIDString, outgoingTime)
client.conn.Do("rpush", allowedConnectionsKey, connectionIDString)
client.conn.Do("hincrby", packetStatsKey, allowedPacketsSeenKey, "1")
} else {
client.conn.Do("hset", blockedIncomingKey, connectionIDString, incomingPayload)
client.conn.Do("hset", blockedOutgoingKey, connectionIDString, outgoingPayload)
client.conn.Do("hset", blockedIncomingDatesKey, connectionIDString, incomingTime)
client.conn.Do("hset", blockedOutgoingDatesKey, connectionIDString, outgoingTime)
client.conn.Do("rpush", blockedConnectionsKey, connectionIDString)
client.conn.Do("hincrby", packetStatsKey, blockedPacketsSeenKey, "1")
}
}

Expand Down

0 comments on commit de01d30

Please sign in to comment.