Skip to content

Instantly share code, notes, and snippets.

@bing0o
Created April 3, 2020 19:44
Show Gist options
  • Save bing0o/cced853b0f1f7d7bcd2290dd5cfbdb66 to your computer and use it in GitHub Desktop.
Save bing0o/cced853b0f1f7d7bcd2290dd5cfbdb66 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# bash script for directory brute forcing but it takes a list of directories
# and try it one by one on a list of domains
#set -x
Usage() {
while read -r line
do
printf "%b\n" "$line"
done <<-EOF
\rOptions:
\r -d, --domains - the domains list file.
\r -t, --thread - the threads number.
\r -w, --wordlist - the wordlist.
\r -o, --output - the output directory.
\rExample:
\r ${0##*/} -d domains.txt -w wordlist.txt -t 20 -o results
\r
EOF
}
domains=False
thread=False
wordlist=False
output=False
while [ -n "$1" ]
do
case $1 in
-d|--domains)
domains=$2
shift ;;
-t|--thread)
thread=$2
shift ;;
-w|--wordlist)
wordlist=$2
shift ;;
-o|--output)
output=$2
shift ;;
-h|--help)
Usage
exit 0 ;;
*)
printf "[!] Unknown Option: $1\n"
exit 1 ;;
esac
shift
done
[ "$domains" == False ] || [ "$wordlist" == False ] && {
printf "[!] Arguments -d/--domains and -w/--wordlist Are Required!\n"
exit 1
}
sites() {
cat $domains | xargs -I{} -P $thread bash -c "curl -sk {}/$1 --connect-timeout 10 -w '%{http_code},%{url_effective},%{size_download},%{redirect_url}\n' -o /dev/null | grep -v \"^404\|^000\" | tee -a $output/{}"
}
paths() {
while read dir; do
sites $dir
done < $wordlist
}
main(){
paths
}
[ "$thread" == False ] && thread=5
[ "$output" == False ] && output="brute-results"
[ -d "$output" ] || mkdir "$output"
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment