Bulk Backup File Leak Scanner
This utility scans target web domains for exposed backup archive files. It reads a list of target URLs from tar.txt, appends common backup file names to each base URL, and validates leaks by checking the response's Content-Type header against known archive MIME types. Vulnerable ednpoints are written to bfvul.txt.
import requests
import re
import multiprocessing
# List of common exposed backup archive filenames
BACKUP_ARCHIVES = [
"wwwroot.rar", "wwwroot.zip", "new_folder.rar", "new_folder.zip",
"www.rar", "www.zip", "web.rar", "web.zip"
]
REQUEST_HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0"
}
# MIME types for common compressed archive formats
VALID_CONTENT_TYPES = [
"application/x-rar", "application/x-gzip", "application/zip",
"application/octet-stream", "application/x-7z-compressed"
]
def scan_target(target_url_line):
# Strip newline characters and extract valid HTTP/HTTPS URLs
cleaned_url = target_url_line.strip("\n")
matched_urls = re.findall(r"https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+", cleaned_url)
if not matched_urls:
return
# Use first matched URL to avoid invalid combined URLs
base_url = matched_urls[0]
for archive_name in BACKUP_ARCHIVES:
try:
full_test_url = f"{base_url}/{archive_name}"
response = requests.head(full_test_url, headers=REQUEST_HEADERS, timeout=10)
if response.headers.get("Content-Type") in VALID_CONTENT_TYPES:
with open("bfvul.txt", "a", encoding="utf-8") as vuln_file:
vuln_file.write(f"Exposed backup file found: {full_test_url}\n")
else:
print(f"No backup file detected at {full_test_url}")
except requests.exceptions.RequestException:
print(f"Failed to connect to {full_test_url}")
if __name__ == "__main__":
# Use 50 worker processes for concurrent scanning
scan_pool = multiprocessing.Pool(50)
with open("tar.txt", "r", encoding="utf-8") as target_file:
target_lines = target_file.readlines()
for line in target_lines:
scan_pool.apply_async(scan_target, (line,))
scan_pool.close()
scan_pool.join()
Bulk Git, SVN and Sensitive File Leak Scanner
This extended script scans targets for exposed sensitive infrastructure files including Git repositories, SVN working copies, .DS_Store files, and robots.txt. It sends GET requests to each constructed endpoint, checks for a 200 OK status code, then validates Git leaks by searching the response body for Git-specific contant like logs. Valid Git leaks are logged to git.txt, other 200 OK endpoinst are logged to qita.txt.
import requests
import re
import multiprocessing
# List of common sensitive file/directory paths
SENSITIVE_PATHS = [".git", ".svn", ".DS_Store", "robots.txt"]
REQUEST_HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0"
}
def scan_target(target_url_line):
cleaned_url = target_url_line.strip("\n")
matched_urls = re.findall(r"https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+", cleaned_url)
if not matched_urls:
return
base_url = matched_urls[0]
for path in SENSITIVE_PATHS:
try:
full_test_url = f"{base_url}/{path}"
response = requests.get(full_test_url, headers=REQUEST_HEADERS, timeout=10)
response.encoding = response.apparent_encoding
if response.status_code == 200:
if "logs" in response.text:
with open("git.txt", "a", encoding="utf-8") as git_file:
git_file.write(f"Confirmed Git leak: {full_test_url}\n")
else:
with open("qita.txt", "a", encoding="utf-8") as other_file:
other_file.write(f"Potential leak detected: {full_test_url}\n")
else:
print(f"No sensitive file found at {full_test_url}")
except requests.exceptions.RequestException:
print(f"Failed to connect to {full_test_url}")
if __name__ == "__main__":
scan_pool = multiprocessing.Pool(50)
with open("tar.txt", "r", encoding="utf-8") as target_file:
target_lines = target_file.readlines()
for line in target_lines:
scan_pool.apply_async(scan_target, (line,))
scan_pool.close()
scan_pool.join()
Common Python Script Errors
IndentationError: expected an indented block: This error occurs when a conditional or loop block does not have any indented code following its declaration. Ensure all block bodies include proper indentation.IndentationError: unindent does not match any outer indentation level: Triggered by mixing tab and space characters for indentation. Use a consistent indentation style (all spaces or all tabs) across the entire script.