Skip to content

Instantly share code, notes, and snippets.

@korc
Created February 18, 2018 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korc/06ecaecfff43d9f123c490896fcebc95 to your computer and use it in GitHub Desktop.
Save korc/06ecaecfff43d9f123c490896fcebc95 to your computer and use it in GitHub Desktop.
#!/bin/sh
red="$(tput setaf 1)" green="$(tput setaf 2)" blue="$(tput setaf 4)"
sg0="$(tput sgr0)" ul="$(tput smul)" b="$(tput bold)"
dq='"'
sed -ur \
-e '/^==>/d' \
-e '/^[[:space:]]*$/d' \
-e 's/^.*\[ *[.0-9]*\] //' \
-e 's/ - - \[[^]]* [+-][0-9]\+\]//' \
-e 's/^[[:space:]]*//' \
-e 's/(MAC|PHYSIN|TOS|PREC|ID|WINDOW|RES|URGP)=[^[:space:]]* //g' \
-e "s/(SPT|DPT|SRC|DST)=([^[:space:]]*)/${blue}\\1=${b}\\2${sg0}/g" \
-e "s/(POST|GET|HEAD|OPTIONS|CONNECT) [^[:space:]]*/${b}${blue}&${sg0}/g" \
-e "s/([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])/${b}&${sg0}/g" \
-e "s/[[:alpha:]]\{3,10\}:\/\/[^\/]*\/[[:alnum:]?/&=%;_\.-]*/${ul}&${sg0}/g" \
-e "s/( - )([^[:space:]]\{,12\})( \[)/\\1${ul}${b}\\2${sg0}\\3/" \
-e "s/\b[a-zA-Z0-9._%+-]\+@[a-zA-Z0-9.-]\+\.[A-Za-z]\{2,4\}\b/${ul}&${sg0}/g" \
-e "s/\[(notice|info|debug)\]/${blue}&${sg0}/g" \
-e "s/\[(crit|err|error|warn|warning)\]/${red}&${sg0}/g" \
-e "s/[^[:space:]]*(DENIED|DROP|REJECT)/${red}${b}&${sg0}/g" \
-e "s/(\" )([45][0-9][0-9]) /\\1${b}${red}\\2${sg0} /g" \
-e "s/[^[:space:]]*(TCP_MISS|ACCEPT)/${green}&${sg0}/g" \
-e "s/(\" )([123][0-9][0-9]) /\\1${green}\\2${sg0} /g"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment