-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders.py
More file actions
29 lines (23 loc) · 869 Bytes
/
headers.py
File metadata and controls
29 lines (23 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
import re
import sys
from pprint import pprint
'''Simple CLI tool for securityheaders.com'''
# TODO:Rework formatting and Regex. Regex should output matches to a dictionary."
# Rudimentary Argument Parsing
pre = str('https://securityheaders.com/?q=')
arg = str(sys.argv[1])
suf = str('&followRedirects=on')
# Payload
r = requests.get(pre + arg + suf)
# Regex
rx_grade = re.findall(r"(?<=grade )\w+", r.text)
html_tags = re.compile(r"<(?!meta)[^>]*>") # Negative Look-Around for Non Meta tags
meta_tags = re.compile(r"<meta\s\w+\-?\w+=(.*)\scontent=(.*)\s/>") # Capture meta content
multi_space = re.compile(r"\s\s+") # Simple multi-space regex
# Removing regex matches
clean = html_tags.sub(" ", r.text)
clean = meta_tags.sub("\\1\\t\\2", clean)
clean = multi_space.sub("\n", clean)
for e in clean.split('\n')[29:-10]:
print(e)