Last active
October 16, 2021 12:21
-
-
Save mauromarano/c1699c91676cf8051a00aaa9419721b9 to your computer and use it in GitHub Desktop.
# Download the top used passwords from passwordrandom.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Download the top used passwords from passwordrandom.com | |
#Set Script Name variable | |
SCRIPT=`basename ${BASH_SOURCE[0]}` | |
URL="http://www.passwordrandom.com/most-popular-passwords/page/" | |
OUTPUT="top_password.txt" | |
NUMBER=100 | |
#Help function | |
function HELP { | |
echo "Basic usage:./$SCRIPT -n 1000 -o result.txt"\\n | |
echo "Default output file (if none specified) is $OUTPUT" | |
echo "-n Number of password to crawl (default = 100)" | |
echo "-o Output file where to write the output." | |
echo "-h Displays this help message. No further functions are performed." | |
echo "Example: $SCRIPT -n 1500 -o output.txt" | |
exit 1 | |
} | |
NUMARGS=$# | |
if [ $NUMARGS -eq 0 ]; then | |
HELP | |
fi | |
while getopts n:o: FLAG; do | |
case $FLAG in | |
o) | |
OUTPUT=$OPTARG | |
;; | |
n) | |
NUMBER=$OPTARG | |
PAGE_TO_CRAWL=$(($NUMBER/100)) | |
;; | |
h) #show help | |
HELP | |
;; | |
\?) #unrecognized option - show help | |
echo -e \\n"Option -$OPTARG not allowed." | |
HELP | |
#If you just want to display a simple error message instead of the full | |
#help, remove the 2 lines above and uncomment the 2 lines below. | |
#echo -e "Use ${BOLD}$SCRIPT -h${NORM} to see the help documentation."\\n | |
#exit 2 | |
;; | |
esac | |
done | |
download_page(){ | |
curl -s $URL$1 | egrep -o ">.+<\/td><td>.{32}<\/" | cut -d'>' -f4 | cut -d'<' -f1 >> $OUTPUT | |
} | |
for (( c=1; c<=$PAGE_TO_CRAWL;c++ ));do | |
download_page $c | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sir, would you please elaborate a little more how to use it simply in terminal. I removed # sign from first line and ran command by name starting ./ but not working. followings are the errors
1- ./passwords_downloader: 1: !/bin/bash: not found
2- ./passwords_downloader: 1: Bad substitution
3- ./passwords_downloader: 14: function: not found
.. more over I want to download all 10000 of avaiable, but you specify limit upto 100. can i change it to 10000?.
Thank