Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Improved HTTP basic auth script #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A script that generates base64 encoded combinations of username:password values
Test each HTTP basic authentication username:password combination in https://example.org/endpoint, and filter out 403 - Forbidden responses.

```
./ffuf_basicauth.sh usernames.txt passwords.txt |ffuf -w -:AUTH -u https://example.org/endpoint -H "Authorization: Basic AUTH" -fc 403 -c
./ffuf_basicauth.sh usernames.txt passwords.txt |ffuf -w -:AUTH -u https://example.org/endpoint -H "Authorization: Basic AUTH" -enc AUTH:b64encode -fc 403 -c
```

## Contributing
Expand Down
18 changes: 2 additions & 16 deletions ffuf_basicauth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# in https://example.org/endpoint, and filter out 403 - Forbidden responses.
#
# ./ffuf_basicauth.sh usernames.txt passwords.txt |ffuf -w -:AUTH \
# -u https://example.org/endpoint -H "Authorization: Basic AUTH" -fc 403
# -u https://example.org/endpoint -H "Authorization: Basic AUTH" -fc 403 -enc AUTH:b64encode
#
##############################################################################

Expand All @@ -36,19 +36,5 @@ fi

USERNAME_WORDLIST="$1"
PASSWORD_WORDLIST="$2"
USERNAME_WORDLIST_SIZE=$(wc -l "$USERNAME_WORDLIST" |awk '{print $1;}')
PASSWORD_WORDLIST_SIZE=$(wc -l "$PASSWORD_WORDLIST" |awk '{print $1;}')
OUTPUT_WORDLIST_SIZE=$((USERNAME_WORDLIST_SIZE * PASSWORD_WORDLIST_SIZE))

printf "\nGenerating HTTP basic authentication strings. This can take a while depending on the length of user and password lists.\n\n" >&2
printf "Usernames: %s\n" "$USERNAME_WORDLIST_SIZE" >&2
printf "Passwords: %s\n" "$PASSWORD_WORDLIST_SIZE" >&2
printf "Total combinations: %s\n\n" "$OUTPUT_WORDLIST_SIZE" >&2

while IFS= read -r user
do
while IFS= read -r password
do
printf "%s:%s" "$user" "$password" |base64
done < "$PASSWORD_WORDLIST"
done < "$USERNAME_WORDLIST"
awk 'NR==FNR{user[NR]=$0; next} {for (i=1;i<=length(user);i++) {printf "%s:%s\n", user[i], $0}}' "$USERNAME_WORDLIST" "$PASSWORD_WORDLIST"