You are on page 1of 1

#!

/bin/bash

# Set target domain to monitor from first line in scopes.txt


TARGET_DOMAIN=$(head -n 1 scopes.txt)

# Set loop counter


loopnumber=0

# Start infinite loop to continuously monitor for new subdomains


while true; do

# Increment loop counter


loopnumber=$((loopnumber+1))

# Run subdomain enumeration tools to discover new subdomains and save to new-
subs-TARGET_NAME.txt
subfinder -d $TARGET_DOMAIN -o new-subs-$TARGET_DOMAIN-$loopnumber.txt
amass enum -passive -d $TARGET_DOMAIN -o new-subs-$TARGET_DOMAIN-$loopnumber.txt
findomain -t $TARGET_DOMAIN -u new-subs-$TARGET_DOMAIN-$loopnumber.txt
chaos -d $TARGET_DOMAIN -o new-subs-$TARGET_DOMAIN-$loopnumber.txt
assetfinder $TARGET_DOMAIN | tee -a new-subs-$TARGET_DOMAIN-$loopnumber.txt

# Remove duplicates from new-subs-TARGET_NAME.txt


sort -u new-subs-$TARGET_DOMAIN-$loopnumber.txt -o new-subs-$TARGET_DOMAIN-
$loopnumber.txt

# Check if new subdomains have been discovered


if [ -s new-subs-$TARGET_DOMAIN-$loopnumber.txt ]; then

# Compare new-subs-TARGET_NAME.txt with old version to find new subdomains and


save to alert-sub-TARGET_NAME.txt
diff --new-line-format='%L' --unchanged-line-format='' new-subs-$TARGET_DOMAIN-
$((loopnumber-1)).txt new-subs-$TARGET_DOMAIN-$loopnumber.txt > alert-sub-
$TARGET_DOMAIN.txt

# Notify via Telegram using Project Discovery's Notify tool


CONTENT=$(cat alert-sub-$TARGET_DOMAIN.txt)
if [ ! -z "$CONTENT" ]; then
notify -telegram-message "New subdomains discovered for $TARGET_DOMAIN: \n
$CONTENT"
fi

# Clear alert-sub-TARGET_NAME.txt
> alert-sub-$TARGET_DOMAIN.txt
fi

# Wait for one hour before running again


sleep 3600

# Read next target domain to monitor from scopes.txt and set loopnumber to 0 if
end of file is reached
TARGET_DOMAIN=$(sed -n $((loopnumber+1))p scopes.txt)
if [ -z "$TARGET_DOMAIN" ]; then
TARGET_DOMAIN=$(head -n 1 scopes.txt)
loopnumber=0
fi
done

You might also like