#!/usr/bin/env python
import argparse
from termcolor import colored
"""
Script to generate a collection of potential values to use when probing a endpoint for any existing hidden parameters.

Sources:
    https://sidechannel.blog/en/url-filter-subversion/index.html
    https://doriantaylor.com/policy/http-url-path-parameter-syntax
"""


def generate_values():
    values = [0, 1, -1, 1000000000, -1000000000, "true", "false", True, False, "'", "''", '"', '""']
    for i in [100, 1000, 10000, 100000]:
        values.append("A"*i)
    for ext in ["js", "css", "txt", "html", "png", "jpg"]:
        values.append(f"x.{ext}")
    return values


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Script to generate a collection of potential values to use when probing a endpoint for any existing hidden parameters.")
    parser.add_argument("-o", action="store", dest="out_file", help="Output file path in which store the collections (ex: /tmp/values.txt).", required=False, default="/tmp/values.txt")
    args = parser.parse_args()
    print(colored("[i] Hints - Use the following syntaxes to test the parameters", "yellow"))
    print("As query string parameters: /endpoint?[PARAM_NAME]=[PARAM_VALUE]")
    print("As path         parameters: /endpoint;[PARAM_NAME]=[PARAM_VALUE]")
    print(colored("[+] Generate collections of values...", "yellow"))
    values = generate_values()
    print(f"{len(values)} values generated.")
    print(colored(f"[+] Save values to file '{args.out_file}'...", "yellow"))
    with open(args.out_file, mode="w", encoding="utf-8") as f:
        for v in values:
            f.write(f"{v}\n")
    print(f"Values saved.")
