Я пишу сценарий на Python 3, который будет проверять веб-сайт на наличие распространенных ошибок конфигурации, таких как отсутствие заголовков http и отсутствие флагов cook ie. Когда я делаю запрос к веб-сайту, я ожидаю увидеть заголовки set-cook ie. На некоторых веб-сайтах это, кажется, работает, но на других веб-сайтах я не получаю куки, хотя, когда я go на Burp Suite и делаю тот же запрос, куки установлены.
Мой вопрос: почему повар ie заголовки возвращаются по некоторым запросам, но не по другим. Примером является tesla.com. Посетите этот сайт, и куки установлены, но если вы запустите скрипт, куки не возвращаются.
Любая помощь приветствуется.
мой код
import sys
import requests
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + "<url>")
sys.exit(1)
# get the banner
req = requests.get("https://"+sys.argv[1])
head = req.headers
print("\n" + " *** ALL RESPONSE HEADERS ***")
print("-----------------------------------------------------------------------------------")
for x, y in head.items():
print(x, ":", y)
print("-----------------------------------------------------------------------------------")
print("\n" + " *** ALL RESPONSE COOKIES ***")
print("-----------------------------------------------------------------------------------")
cook = req.cookies
for x, y in cook.items():
print(x, ":", y)
print("-----------------------------------------------------------------------------------")
print("\n" + " *** HTTP SECURITY HEADERS ***" )
print("-----------------------------------------------------------------------------------")
if "X-XSS-Protection" in head:
print("X-XSS-Protection : " + head["X-XSS-Protection"])
else:
print("The X-XSS-Protection header is currently not in use!")
if "X-XSS-Protection" in head:
print("X-Frame-Options : " + head["X-Frame-Options"])
else:
print("The X-Frame-Options header is currently not in use!")
if "X-XSS-Protection" in head:
print("Strict-Transport-Security : " + head["Strict-Transport-Security"])
else:
print("The Strict-Transport-Security header is currently not in use!")
if "X-Content-Type-Options" in head:
print("X-Content-Type-Options : " + head["X-Content-Type-Options"])
else:
print("The X-Content-Type-Options header is currently not in use!")