I need a script maybe in python or bash that accepts /path/to list of urls.txt with parameters and then create urls like the above on each URL only if it's possible to create on the url.
Then return or display the generated urls in realtime in the cli.
Handle every exceptions, the tool should work in every situation no matter what.
It should only return/display the generated urls.
Here's a Python script that fulfills your requirements. This script reads URLs from a text file and generates modified URLs by injecting various payloads between the domain and the path. It handles exceptions and outputs the generated URLs in real-time.
python
import sys
import urllib.parse
# Define the payloads to inject
payloads = [
';knx',
';knx',
';%27knx%27',
';%22knx%22',
';%3C1knx%3C1',
';%3C%3Xknx%3C%3X',
';%2522knx%2522',
';\%22knx\%22',
';\%27knx\%27',
';%253Cxknx%253Cx',
';%2527knx%2527',
';knx&knx=knx',
';S05Y',
';%27%22knx',
';https://example.com/knx',
';knx',
]
def generate_urls(filename):
try:
with open(filename, 'r') as f:
for line in f:
url = line.strip()
if not url:
continue
for payload in payloads:
try:
# Parse the URL into components
parsed_url = urllib.parse.urlsplit(url)
# Inject the payload into the path
new_path = payload + parsed_url.path
# Reconstruct the new URL
new_url = urllib.parse.urlunsplit((
parsed_url.scheme,
parsed_url.netloc,
new_path,
parsed_url.query,
parsed_url.fragment
))
# Output the modified URL
print(new_url)
except Exception:
# Continue on exception
continue
except Exception:
# Handle exceptions such as file not found
pass
if __name__ == '__main__':
if len(sys.argv) != 2:
print("Usage: python script.py urls.txt")
else:
generate_urls(sys.argv[1])
How to use the script:
Save the script to a file, for example, generate_urls.py.
Make sure you have Python 3 installed on your system.
Place your list of URLs with parameters into a text file, say urls.txt.
Run the script from the command line:
bash
python generate_urls.py urls.txt
Example:
Given the URL https://example.com/api/user/excuse?username=xssparam&date=11 in your urls.txt, the script will output: