Compare commits
No commits in common. "434a62f49dc3bbb4fea1de5c698a26b68408c07b" and "11b125eb2bf49386b7cd2330620a5a4cc76aa1ba" have entirely different histories.
434a62f49d
...
11b125eb2b
18
.github/workflows/daily-axfr.yml
vendored
18
.github/workflows/daily-axfr.yml
vendored
@ -28,14 +28,19 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
pip install dnspython
|
||||
|
||||
- name: Create directories
|
||||
- name: Set up environment
|
||||
run: |
|
||||
mkdir -p axfrout/root
|
||||
chmod +x ./extras/mdaxfr.py
|
||||
mkdir -p axfrout
|
||||
|
||||
- name: Run AXFR scan with TLDs
|
||||
- name: Run AXFR scan
|
||||
run: |
|
||||
python ./extras/mdaxfr.py --tlds
|
||||
curl -s 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt' | \
|
||||
tail -n +2 | \
|
||||
tr '[:upper:]' '[:lower:]' | \
|
||||
while read domain; do
|
||||
python ./extras/mdaxfr.py -d "$domain"
|
||||
done
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
@ -44,9 +49,8 @@ jobs:
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
# Stage both directories
|
||||
# Stage only the axfrout directory
|
||||
git add axfrout/
|
||||
git add root/
|
||||
|
||||
# Only commit if there are changes
|
||||
if git diff --staged --quiet; then
|
||||
@ -55,4 +59,4 @@ jobs:
|
||||
fi
|
||||
|
||||
git commit -m "Auto: Daily AXFR scan results $(date -u '+%Y-%m-%d')"
|
||||
git push
|
||||
git push
|
107
extras/mdaxfr.py
107
extras/mdaxfr.py
@ -147,95 +147,46 @@ def process_domain(domain: str):
|
||||
if __name__ == '__main__':
|
||||
import argparse
|
||||
import concurrent.futures
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser(description='Mass DNS AXFR')
|
||||
parser.add_argument('-d', '--domain', type=str, help='domain to perform AXFR on')
|
||||
parser.add_argument('-i', '--input', type=str, help='input file')
|
||||
parser.add_argument('-t', '--tlds', action='store_true', help='Perform AXFR on all TLDs')
|
||||
parser.add_argument('-d', '--domain', type=str,help='domain to perform AXFR on')
|
||||
parser.add_argument('-i', '--input', type=str, help='input directory')
|
||||
parser.add_argument('-t', '--tld', type=str, help='TLD to perform AXFR on')
|
||||
parser.add_argument('-p', '--psl', action='store_true', help='use the Public Suffix List')
|
||||
parser.add_argument('-c', '--concurrency', type=int, default=30, help='maximum concurrent tasks')
|
||||
parser.add_argument('-o', '--output', dest='output_dir', type=str, default='axfrout', help='output directory')
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
# Create output directories
|
||||
os.makedirs(args.output_dir, exist_ok=True)
|
||||
root_dir = os.path.join(args.output_dir, 'root')
|
||||
root_dir = os.path.join(args.output, 'root')
|
||||
os.makedirs(root_dir, exist_ok=True)
|
||||
os.makedirs(args.output, exist_ok=True)
|
||||
dns.resolver._DEFAULT_TIMEOUT = args.timeout
|
||||
|
||||
# Set DNS timeout
|
||||
dns.resolver._DEFAULT_TIMEOUT = 30
|
||||
|
||||
logging.info('Fetching root nameservers...')
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=args.concurrency) as executor:
|
||||
if args.domain:
|
||||
# Single domain mode
|
||||
process_domain(args.domain)
|
||||
|
||||
elif args.input:
|
||||
# Input file mode
|
||||
futures = [executor.submit(attempt_axfr, '', root, os.path.join(args.output, f'root/{root}.txt')) for root in get_nameservers('.')]
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
with open(args.input, 'r') as f:
|
||||
domains = [line.strip() for line in f if line.strip()]
|
||||
futures = [executor.submit(process_domain, domain) for domain in domains]
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
logging.error(f'Error processing domain: {e}')
|
||||
except FileNotFoundError:
|
||||
logging.error(f'Input file not found: {args.input}')
|
||||
sys.exit(1)
|
||||
future.result()
|
||||
except Exception as e:
|
||||
logging.error(f'Error in TLD task: {e}')
|
||||
|
||||
elif args.tlds:
|
||||
# TLD mode
|
||||
logging.info('Fetching root nameservers...')
|
||||
# First get root nameservers
|
||||
for root in get_nameservers('.'):
|
||||
try:
|
||||
attempt_axfr('', root, os.path.join(root_dir, f'{root}.txt'))
|
||||
except Exception as e:
|
||||
logging.error(f'Error processing root nameserver {root}: {e}')
|
||||
logging.info('Fetching root TLDs...')
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=args.concurrency) as executor:
|
||||
futures = [executor.submit(attempt_axfr, tld, ns, os.path.join(args.output, tld + '.txt')) for tld in get_root_tlds(root_dir) for ns in get_nameservers(tld) if ns]
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
logging.error(f'Error in TLD task: {e}')
|
||||
|
||||
# Then process TLDs
|
||||
logging.info('Processing TLDs...')
|
||||
tlds = get_root_tlds(root_dir)
|
||||
futures = []
|
||||
for tld in tlds:
|
||||
try:
|
||||
nameservers = get_nameservers(tld)
|
||||
for ns in nameservers:
|
||||
futures.append(executor.submit(process_domain, tld))
|
||||
except Exception as e:
|
||||
logging.error(f'Error processing TLD {tld}: {e}')
|
||||
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
logging.error(f'Error in TLD task: {e}')
|
||||
|
||||
elif args.psl:
|
||||
# PSL mode
|
||||
logging.info('Fetching PSL domains...')
|
||||
psl_dir = os.path.join(args.output_dir, 'psl')
|
||||
os.makedirs(psl_dir, exist_ok=True)
|
||||
|
||||
domains = get_psl_tlds()
|
||||
futures = []
|
||||
for domain in domains:
|
||||
try:
|
||||
futures.append(executor.submit(process_domain, domain))
|
||||
except Exception as e:
|
||||
logging.error(f'Error processing PSL domain {domain}: {e}')
|
||||
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
logging.error(f'Error in PSL task: {e}')
|
||||
|
||||
else:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
logging.info('Fetching PSL TLDs...')
|
||||
os.makedirs(os.path.join(args.output, 'psl'), exist_ok=True)
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=args.concurrency) as executor:
|
||||
futures = [executor.submit(attempt_axfr, tld, ns, os.path.join(args.output, f'psl/{tld}.txt')) for tld in get_psl_tlds() for ns in get_nameservers(tld) if ns]
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
logging.error(f'Error in TLD task: {e}')
|
Loading…
Reference in New Issue
Block a user