Skip to content

Instantly share code, notes, and snippets.

@nlitsme
Created December 14, 2017 08:10
Show Gist options
  • Save nlitsme/6f138e72b328c28520d64d7e03f2d5f9 to your computer and use it in GitHub Desktop.
Save nlitsme/6f138e72b328c28520d64d7e03f2d5f9 to your computer and use it in GitHub Desktop.
query.sh for older bash versions - from magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3
#!/bin/bash
# query.sh from BreachCompilation - magnet:?xt=urn:btih:7ffbcd8cee06aba2ce6561688cf68ce2addca0a3
# works with older bash versions.
# patch by Willem <itsme@xs4all.nl>
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if [ "$1" != "" ]; then
word1=$(echo $1 | tr A-Z a-z)
letter1=$(echo $word1|cut -b1)
if [[ $letter1 == [a-zA-Z0-9] ]]; then
if [ -f "$dir/data/$letter1" ]; then
grep -ai "^$1" "$dir/data/$letter1"
else
letter2=$(echo $word1|cut -b2)
if [[ $letter2 == [a-zA-Z0-9] ]]; then
if [ -f "$dir/data/$letter1/$letter2" ]; then
grep -ai "^$1" "$dir/data/$letter1/$letter2"
else
letter3=$(echo $word1|cut -b3)
if [[ $letter3 == [a-zA-Z0-9] ]]; then
if [ -f "$dir/data/$letter1/$letter2/$letter3" ]; then
grep -ai "^$1" "$dir/data/$letter1/$letter2/$letter3"
fi
else
if [ -f "$dir/data/$letter1/$letter2/symbols" ]; then
grep -ai "^$1" "$dir/data/$letter1/$letter2/symbols"
fi
fi
fi
else
if [ -f "$dir/data/$letter1/symbols" ]; then
grep -ai "^$1" "$dir/data/$letter1/symbols"
fi
fi
fi
else
if [ -f "$dir/data/symbols" ]; then
grep -ai "^$1" "$dir/data/symbols"
fi
fi
else
echo "[*] Example: ./query name@domain.com"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment