Oct 6, 2026 · HackerOnStreet
Advanced BugHunting Testing Script with Payload
Customization and Detailed Response Handling Advanced BugHunting Testing Script with Payload Customization and Detailed Response Handling Importtant laibaretoy import dns. resolver import csv import pandas
advanced bughuntingadvanced bughunting testingadvancedbughuntingtestingscriptpayloadresponseheaderssession
Customization and Detailed Response Handling
Advanced BugHunting Testing Script with Payload
Customization and Detailed Response Handling
Importtant laibaretoy
import dns.resolver
import csv
import pandas
import pandas as pd
import numpy as np
import matplotlib as plt
import sys
import ntpath
import os
import glob, os For XSS testing
import requests
from bs4 import BeautifulSoup
from html_sanitizer import Sanitizer
from concurrent.futures import ThreadPoolExecutor
def read_payloads_from_file(file_path):
try:
with open(file_path, 'r') as file:
payloads = file.read().splitlines()
return payloads
except Exception as e:
print(f"Error reading payloads from file: {e}")
return []
def sanitize_html(html_content):
# Sanitize HTML content to remove malicious code
sanitizer = Sanitizer()
return sanitizer.sanitize(html_content)
def find_input_fields(html_content):
soup = BeautifulSoup(html_content, 'html.parser')
input_fields = soup.find_all('input')
return [field.get('name') for field in input_fields if field.get('name')]
def test_xss(url, payload, method='get', headers=None, session=None):
success = False
try:
if not session:
session = requests.Session()
if method.lower() == 'get':
response = session.get(url, headers=headers)
elif method.lower() == 'post':
response = session.get(url, headers=headers)
else:
print(f"Unsupported HTTP method: {method}")
return
if response.status_code == 200:
input_fields = find_input_fields(response.text)
for field in input_fields:
modified_payload = payload.replace('{input}', field)
modified_response = session.get(url, headers=headers, params={'payload': modified_payload})
if modified_payload in modified_response.text:
print(f"XSS vulnerability found at: {url} in input field: {field} with payload: {modified_payload}")
success = True
except requests.RequestException as e:
print(f"RequestException: {e}")
return success
def handle_response(url, response):
print(f"Status for {url}: {response.status_code}")
# Print response headers
print("Response Headers:")
for header, value in response.headers.items():
print(f"{header}: {value}")
# Print sanitized HTML content
sanitized_html = sanitize_html(response.text)
print("Sanitized HTML Content:")
print(sanitized_html)
if __name__ == "__main__":
target_url = input("Enter the target URL (e.g., https://www.xx.com/writeareview/search?): ")
payloads_file_path = "payloads.txt"
xss_payloads = read_payloads_from_file(payloads_file_path)
custom_headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
with requests.Session() as session:
with ThreadPoolExecutor() as executor:
for payload in xss_payloads:
success = executor.submit(test_xss, target_url, payload, method='get', headers=custom_headers, session=session)
if not success.result():
print(f"Payload failed for method 'GET' with payload: {payload}")
success = executor.submit(test_xss, target_url, payload, method='post', headers=custom_headers, session=session)
if not success.result():
print(f"Payload failed for method 'POST' with payload: {payload}")
# Show detailed information about the response
response = session.get(target_url, headers=custom_headers)
handle_response(target_url, response)