This repository has been archived by the owner on Feb 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the code a bit and added an inline_matches field to allow …
…Top N vizualisation of all matches
- Loading branch information
Showing
18 changed files
with
150 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package logdata | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/bonjourmalware/melody/internal/loggable" | ||
) | ||
|
||
// IPLogData is the interface used by packet structs supporting an IP layer | ||
type IPLogData interface{} | ||
|
||
// BaseLogData is used as the base packet log and contains common data, such as the timestamp | ||
type BaseLogData struct { | ||
Timestamp string `json:"timestamp"` | ||
Session string `json:"session"` | ||
Type string `json:"type"` | ||
SourceIP string `json:"src_ip"` | ||
DestPort uint16 `json:"dst_port"` | ||
Tags map[string][]string `json:"matches"` | ||
InlineTags []string `json:"inline_matches"` | ||
Additional map[string]string `json:"embedded"` | ||
} | ||
|
||
// Init takes the common BaseEvent attributes to setup the BaseLogData struct | ||
func (l *BaseLogData) Init(ev loggable.Loggable) { | ||
l.Type = ev.GetKind() | ||
l.SourceIP = ev.GetSourceIP() | ||
l.DestPort = ev.GetDestPort() | ||
l.Session = ev.GetSession() | ||
l.InlineTags = []string{} | ||
|
||
if len(ev.GetTags()) == 0 { | ||
l.Tags = make(map[string][]string) | ||
} else { | ||
l.Tags = ev.GetTags() | ||
l.InlineTags = makeInlineArray(ev.GetTags()) | ||
} | ||
} | ||
|
||
//makeInlineArray converts a Tags map to an array of its values with the keys and values merged with a '.' | ||
func makeInlineArray(tags map[string][]string) []string { | ||
var inlineTags []string | ||
|
||
for key, values := range tags { | ||
for _, val := range values { | ||
inlineTags = append(inlineTags, fmt.Sprintf("%s.%s", key, val)) | ||
} | ||
} | ||
|
||
return inlineTags | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package loggable | ||
|
||
// Loggable is an interface to allow mutual use of events.BaseEvent for logdata.BaseLogData | ||
type Loggable interface { | ||
GetSession() string | ||
GetTags() map[string][]string | ||
GetKind() string | ||
GetSourceIP() string | ||
GetDestPort() uint16 | ||
} |