Skip to content

Instantly share code, notes, and snippets.

@jabb3rd
Created January 5, 2021 00:33
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 jabb3rd/b28f36f4fb011d0ec54b137f02e64f8f to your computer and use it in GitHub Desktop.
Save jabb3rd/b28f36f4fb011d0ec54b137f02e64f8f to your computer and use it in GitHub Desktop.
Build a frequency-sorted dictionary from <address>\t<login>\t<password> with optionally given minimal and maximal occurencies.
#!/bin/bash
usage() {
echo "Usage: $(basename $0) <file.creds> [<min> [max]]"
exit 0
}
[ -f "$1" ] || usage
if [ "$2" == "" ]; then
cat "$1" | sort -u | cut -f2,3 | sort | uniq -c | sort -nr | sed 's/^ *\([0-9]*\) /\1\t/'
elif [ "$2" != "" -a "$3" == "" ]; then
cat "$1" | sort -u | cut -f2,3 | sort | uniq -c | sort -nr | sed 's/^ *\([0-9]*\) /\1\t/' | awk -v min="$2" '{if ($1 >= min) print $0}'
else
cat "$1" | sort -u | cut -f2,3 | sort | uniq -c | sort -nr | sed 's/^ *\([0-9]*\) /\1\t/' | awk -v min="$2" -v max="$3" '{if ($1 >= min && $1 <= max) print $0}'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment