|
| 1 | +# fdsdump |
| 2 | + |
| 3 | +Reads flow data stored in fdsdump format and displays them in a specified way. |
| 4 | + |
| 5 | +Supports sorting, filtering, aggregation, and selection of fields to display. Display can be in form of a formatted table output or a json output. |
| 6 | + |
| 7 | +## Command line options |
| 8 | +- `-r` — FDS files to read, can also be a glob pattern and can be specified multiple times to select more files |
| 9 | + |
| 10 | +- `-A` — Aggregator keys (TBD) |
| 11 | + |
| 12 | +- `-S` — Aggregated values (TBD) |
| 13 | + |
| 14 | +- `-I` — Run in statistics mode |
| 15 | + |
| 16 | +- `-F`, `--filter` — Filter the flow records based on a filter expression |
| 17 | + |
| 18 | +- `-o`, `--output` — The output format |
| 19 | + |
| 20 | +- `-O`, `--order` — The fields to order by |
| 21 | + |
| 22 | +- `-c`, `--limit` — Limit the number of records processed |
| 23 | + |
| 24 | +- `--no-biflow-autoignore` — Disable smart ignore functionality of empty biflow records |
| 25 | + |
| 26 | + |
| 27 | +## Modes |
| 28 | +### Statistics mode |
| 29 | + |
| 30 | +Selected using the -I flag |
| 31 | + |
| 32 | +Prints basic information about the flows contained in the fds files, such as packet counts, byte counts, flow counts in either directions in case of biflow. |
| 33 | + |
| 34 | + |
| 35 | +### Lister mode |
| 36 | + |
| 37 | +Displays flow records in a specified format (table or json). Flow records can be sorted and ordered based on field values. |
| 38 | + |
| 39 | +### Aggregation mode |
| 40 | + |
| 41 | +TBD |
| 42 | + |
| 43 | + |
| 44 | +## Output formats |
| 45 | + |
| 46 | +- `JSON-RAW` — prints flow records in the json format with all their fields |
| 47 | +- `json` — json output of selected fields |
| 48 | +- `table` — table output of selected fields |
| 49 | + |
| 50 | +Fields can be specified for `json` and `table` outputs as such: `json:srcip,dstip,srcport,dstport,flows,packets,bytes` |
| 51 | + |
| 52 | +## Filtering expressions |
| 53 | + |
| 54 | +Fields to filter on can be specified by their full name, or by aliases which are defined for the most commonly used fields, e.g. ip, srcip, dstport, port, srcport, packets, bytes, flows, and more. The full list of aliases can be seen in the aliases.xml file supplied by libfds, where more can be defined. |
| 55 | + |
| 56 | +### Supported operations |
| 57 | + |
| 58 | +- Comparison operators `==`, `<`, `>`, `<=`, `>=`, `!=`. If the comparison operator is ommited, the default comparison is `==`. |
| 59 | + |
| 60 | +- The `contains`, `startswith` and `endswith` operators for substring comparison, e.g. `DNSName contains "example"`. |
| 61 | + |
| 62 | +- Arithmetic operations `+`, `-`, `*`, `/`, `%`. |
| 63 | + |
| 64 | +- Bitwise operations not `~`, or `|`, and `&`, xor `^`. |
| 65 | + |
| 66 | +- The `in` operator for list comparison, e.g. `port in [80, 443]`. |
| 67 | + |
| 68 | +- The logical `and`, `or`, `not` operators. |
| 69 | + |
| 70 | +### Value formats |
| 71 | + |
| 72 | +- Numbers can be integer or floating point. Integer numbers can also be written in their hexadecimal or binary form using the `0x` or `0b` prefix. Floating point numbers also support the exponential notation such as `1.2345e+2`. A number can be explicitly unsigned using the `u` suffix. Numbers also support size suffixes `B`, `k`, `M`, `G`, `T`, and time suffixes `ns`, `us`, `ms`, `s`, `m`, `d`. |
| 73 | + |
| 74 | +- Strings are values enclosed in a pair of double quotes `"`. Supported escape sequences are `\n`, `\r`, `\t` and `\"`. The escape sequences to write characters using their octal or hexadecimal value are also supported, e.g. `\ux22` or `\042`. |
| 75 | + |
| 76 | +- IP addresses are written in their usual format, e.g. `127.0.0.1` or `1234:5678:9abc:def1:2345:6789:abcd:ef12`. The shortened IPv6 version is also supported, e.g. `::ff`. IP addresses can also contain a suffix specifying their prefix length, e.g. `10.0.0.0/16`. |
| 77 | + |
| 78 | +- MAC addresses are written in their usual format, e.g. `12:34:56:78:9a:bc`. |
| 79 | + |
| 80 | +- Timestamps use the ISO timestamp format, e.g. `2020-04-05T24:00Z`. |
| 81 | + |
| 82 | +Filtering expressions can be joined by logical operators and even nested using parentheses. |
| 83 | + |
| 84 | + |
| 85 | +### Example expressions |
| 86 | + |
| 87 | +- `ip == 10.0.0.1` — Exact match on source or destination IP address, specified using an alias |
| 88 | +- `ip == 10.0.0.0/8` — Subnet match on source or detination IP address |
| 89 | +- `ip 10.0.0.0/8` — Omitting comparison operator defaults to == |
| 90 | +-`ip 10.0.0.0/8 and port 80` — Also match source or destination port using an alias |
| 91 | +- `ip 10.0.0.0/8 and (port 80 or port 443)` — Match multiple ports |
| 92 | +- `ip 10.0.0.0/8 and port in [80, 443]` — A shorthand list syntax for specifying multiple ports |
| 93 | +- `ip 10.0.0.0/8 and port in [80, 443] and packets > 1000` — Using an alias for `iana:packetDeltaCount` |
| 94 | +- `ip 10.0.0.0/8 and port in [80, 443] and packets > 1M` — Using number units |
| 95 | +- `cesnet:DNSName contains "google"` — String operations and specification of a field by its full name |
| 96 | +`cesnet:DNSName endswith ".com"` — More string operations |
| 97 | +- `iana:sourceTransportPort == 80 and iana:octetDeltaCount > 100` — Specification of fields by their full name |
| 98 | + |
| 99 | +Sorting |
| 100 | +--------- |
| 101 | + |
| 102 | +Fields to order by is specified by the `-O` flag such as: `-O packets/desc,flows/desc`. Field names can be aliases or their full name. Possible ordering options are `asc` for ascending or `desc` for descending. |
| 103 | + |
| 104 | +Example usage |
| 105 | +-------------- |
| 106 | + |
| 107 | +- Write out all the flow records in JSON format |
| 108 | + ``` |
| 109 | + fdsdump -r ./flows.fds -o 'JSON-RAW' |
| 110 | + ``` |
| 111 | +
|
| 112 | +- Write out the source IP, source port, destination IP, destination port, number of packets and number of bytes of each flow in JSON format. |
| 113 | + ``` |
| 114 | + fdsdump -r ./flows.fds -o 'json:srcip,srcport,dstip,dstport,packets,bytes' |
| 115 | + ``` |
| 116 | +
|
| 117 | +- Write out the source IP, source port, destination IP, destination port, number of packets and number of bytes of the top 10 flows with most packets as a formatted table. |
| 118 | + ``` |
| 119 | + fdsdump -r ./flows.fds -o 'table:srcip,srcport,dstip,dstport,packets,bytes' -O 'packets/desc' -c 10 |
| 120 | + ``` |
| 121 | +
|
| 122 | +- Write out the source IP, source port, destination IP, destination port, number of packets and number of bytes of the top 10 flows with most packets from where either the source or destination address is from the subnet 12.34.56.0/24 as a formatted table. |
| 123 | + ``` |
| 124 | + fdsdump -r ./flows.fds -o 'table:srcip,srcport,dstip,dstport,packets,bytes' -O 'packets/desc' -c 10 -F 'ip 12.34.56.0/24' |
| 125 | + ``` |
0 commit comments