forked from jamct/agsi-data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpheader1.py
56 lines (40 loc) · 2.06 KB
/
httpheader1.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/python3
#######################################################################
################### FREE OCSAF HTTP Header FUNCTION ###################
#######################################################################
################################################################################################
# FROM THE FREECYBERSECURITY.ORG TESTING-PROJECT (GNU-GPLv3) - https://freecybersecurity.org #
# With this script the HTTP Header can be fetched. #
# #
# Use only with legal authorization and at your own risk! ANY LIABILITY WILL BE REJECTED! #
# #
# Script programming by Mathias Gut, Netchange Informatik GmbH under GNU-GPLv3 #
# Special thanks to the community and also for your personal project support. #
################################################################################################
############## Libraries ###############
import urllib.request
import argparse
############# HTTP Header ##############
def funcHTTPHeader(url):
agent = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:62.0) Gecko/20100101 Firefox/62.0' }
#agent = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0'}
req = urllib.request.Request(
url,
data=None,
headers=agent
)
try:http = urllib.request.urlopen(req)
except urllib.error.URLError as err:
print("ERROR: {} {}".format(err.code,err.reason))
#print(http.headers)
return http.headers
"""
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--url", required=True,
help="Full URL - http://www.freecybersecurity.org")
args = vars(parser.parse_args())
url = args["url"]
print(funcHTTPHeader(url))
#"""
############# END #############