Network Security Center
flow-extract man page
NAME
flow-extract --- flow-extract - Displays flows from a flow file.SYNOPSIS
flow-extract [-aDRBbnh] [ -e program ] [ -E program ] [ -f file ] [ -F file ] [ -d dumpfile ] [-o outfile ] [ -z complevel ]DESCRIPTION
The flow-extract is used for selecting flows from a binary log file created by Flow-tools(1). The program uses the same syntax as the Netlogger extract program to select flows.
OPTIONS
- -a
- Output matching flows in ASCII format (the default).
- -B
- Specify the endianness of the input ('big' or 'little').
- -b
- Output matching flows in binary format. This is useful for selecting data which can then be processed by flow-tools such as flow-stat(1). This option implies -n.
- -n
- Do not resolve IP address or port information when displaying the flows in ASCII format.
- -D
- Do not port information, but do resolve IP addresses when displaying the flows in ASCII format.
- -R
- Do not resolve IP address, but do resolve port information when displaying the flows in ASCII format.
- -n
- Do not resolve port information when displaying the flows in ASCII format. IP addresses will be resolved, however.
- -h
- Print an informative help message describing the options and then exit.
- -e program
- Specify an extract program on the command line.
- -E program
- Specify an extract program on the command line.
- -f file
- Specify a script containing an extract program.
- -F file
- Specify a script containing an extract program.
Multiple -e, -f, -E, and -F options can be specified. They are all combined together and treated as a single program. Programs specified by -e and -f are appended to the program, while programs specified with -E and -F are prepended. -E and -F can be used with extract scripts to insert addition conditions at the top of the script without having to edit it each time.
- -d dumpfile
- Specify the datafile to read as input. Defaults to standard input.
- -o outfile
- Specify the output file. Defaults to standard output.
- -z complevel
- Specify the compression level. Flow-extract compresses files by default using zlib. This option specifies how much the files should be compressed. Defaults to 6, valid numbers are 0 (no compression) to 9.
USAGE
Programs
program consists of selector-action statements. Statements have the form
- selector { action }
A missing selector means to always select the flow. Flow-extract processes the entire program for each flow in the log file unless a matching statement contains a next action.
Actions
There are three actions currently define, print, printall and next.
Print outputs the flow in the format selected using the -a and -b switches.
Printall outputs the flow with all of the information in it. This format displays the data that is specific to various flow versions. Its format is consistent between all versions. Those fields which do not exist in the flow version that is being processed contain a dash. If -b is used for binary output there is no difference between .BI print and printall as the binary version contains all of the flow information regardless.
Next skips to the next flow and restarts scanning of program.
Selectors
The following selectors are available.net =, != netname|ipaddr[/netmask]
srcnet =, != netname|ipaddr[/netmask]
dstnet =, != netname|ipaddr[/netmask]
host =, !=, <, >, ><, <=, >= hostname|ipaddr
srchost =, !=, <, >, ><, <=, >= hostname|ipaddr
dsthost =, !=, <, >, ><, <=, >= hostname|ipaddr
iface =, !=, <, >, ><, <=, >= interface
srciface =, !=, <, >, ><, <=, >= interface
dstiface =, !=, <, >, ><, <=, >= interface
hp =, !=, <, >, ><, <=, >= hostname|ipaddr service-name|port
srchp =, !=, <, >, ><, <=, >= hostname|ipaddr service-name|port
dsthp =, !=, <, >, ><, <=, >= hostname|ipaddr service-name|port
dstport =, !=, <, >, ><, <=, >= service-name|port
proto =, !=, <, >, ><, <=, >= number
pkts =, !=, <, >, ><, <=, >= number
octets =, !=, <, >, ><, <=, >= number
flag FIN|SYN|RST|PUSH|ACK|URG
flags safrpu/safrpu
date =, !=, <, >, ><, <=, >= YYYY-MM-DD | YY-MM-DD | MM/DD/YY | MM/DD | today | yesterday
time =, !=, <, >, ><, <=, >= HH:MM:SS | HH:MM
before YYYY-MM-DD [HH:MM] | YY-MM-DD [HH:MM] | MM/DD/YY [HH:MM] | today [HH:MM] | yesterday [HH:MM]
since YYYY-MM-DD [HH:MM] | YY-MM-DD [HH:MM] | MM/DD/YY [HH:MM] | today [HH:MM] | yesterday [HH:MM]
Combining Selectors
Selectors can be combined using the following operators.- and,
- && Short circuited boolean AND.
- or,
- || Short circuited boolean OR.
- not,
- ! Unary negation operators.
Parenthesis can be used to group expressions.
EXAMPLES
Print in ASCII any records showing attempts to ssh to host myhost.
-
flow-extract -e 'dsthost = myhost && dstport = ssh {print}' -d ft-v06.2002-02-15.200000
Show all traffic on 2001-02-15 to the 128.135.119.0/255.255.255.0 subnet and sent it to flow-stat to find the top bandwidth user by port.
-
flow-cat ft-v06.2002-02-15* | flow-extract -be 'net = 128.135.119.0/255.255.255.0 {print}' | flow-stat -f7 | sort -nr +2 -3
Show the details of all traffic crossing router interface 43 that is a successful TCP connection.
-
flow-extract -e 'iface = 43 && flag ack && ! flags ar/arf {printall}'
Sample script called unusual to print records for unexpected TCP traffic. This would have to be tailored to a site.
-
#!/opt/bin/flow-extract -f
# Script 'unusual' for printing unusual traffic
port = ssh || port = SMTP || port = http || port = 113 {next}
hp = news.uchicago.edu NNTP {next}
# If we made it to here, then print the record
{print}
Run the previous script, but only show records for today.
-
unusual -E 'before today {next}'
BUGS
This man page needs more examples.AUTHORS
flow-extract was ported from the TAMU extract program to use flow data by E. Larry Lidz. Large portions of the code (and this man page) come directly from there. Many flow specific features have been added to the program by E. Larry Lidz as well. If you're interested in the changes, see the ChangeLog with the source, or compare this man page to extract(8).SEE ALSO
flow-tools(1), extract(8)
Last updated: 8/14/08