Update Network Security Notes, Add word of the day script

This commit is contained in:
Orien Vandenbergh 2016-12-22 18:26:26 -07:00
parent 2b0ec41e9b
commit 04f8e19eb9
2 changed files with 109 additions and 0 deletions

View File

@ -42,3 +42,25 @@ Game plan:
connection services, synchronizing transmissions connection services, synchronizing transmissions
Homework: Homework:
Read through remainder of chapter 2, chapter 3 (specifically the Network Infrastruction Devices) Read through remainder of chapter 2, chapter 3 (specifically the Network Infrastruction Devices)
12/01
Discussion on Gen1 firewalls, (routers) filter based on macs, ips, networks, ports
Gen3 firewalls - stateful packet inspecting, much better but can be circumnavigated
IDS (&NIDS/HIDS)
Way too much time spent on binary math (subnetting)
12/06
Nothing worth noting...
Primarily a 3 hour discussion covering how bit math on addresses and routes is used for security.
12/08 - Cancelled
12/13
Policies, Standards, Governance and Guidelines. Guidelines are last in line.
How important is remote access to your customer?
SSL/TLS, -> TLS Ephemeral keys are the way to go

87
python/wod.py Executable file
View File

@ -0,0 +1,87 @@
#!/usr/bin/env python
"""
Simply display the word of the day, with meaning sourced from merriam-webster
"""
import os
import argparse
from datetime import date
import requests
from lxml import html
RED = "\033[1;33m"
PURPLE = "\033[0;35m"
NC = "\033[0m"
def cache_directory():
return os.path.join(os.environ['HOME'],'.wod')
def cache_filename():
filename = date.today().strftime('%Y%m%d.cache.html')
return os.path.join(cache_directory(),filename)
def is_cached():
if not os.path.exists(cache_directory()):
os.mkdir(cache_directory(),0755)
if os.path.exists(cache_filename()):
return True
return False
def parse_and_display(content):
tree = html.fromstring(content)
word = tree.xpath('//h1/text()')[0]
attribute = tree.xpath('//span[@class="main-attr"]/text()')[0]
syllables = tree.xpath('//span[@class="word-syllables"]/text()')[0]
definition = tree.xpath('//div[@class="wod-definition-container"]/p[1]')[0].text_content().replace(': ','',1).capitalize()
try:
alternate = tree.xpath('//div[@class="wod-definition-container"]/p[1]/a[1]/text()')[0]
except IndexError:
alternate = ""
print "Word of the Day: %s%s : %s (%s)%s" % (RED, word, attribute, syllables, NC)
if alternate:
print " Meaning: %s%s : %s%s" % (PURPLE, definition, alternate, NC)
else:
print " Meaning: %s%s%s" % (PURPLE, definition, NC)
def read_cached(filename):
return open(filename, "r").read()
def fetch_content():
url = 'http://www.merriam-webster.com/word-of-the-day'
response = requests.get(url)
content = ""
if response.status_code == 200:
content = response.content
f = open(cache_filename(),'w')
f.write(content)
f.close()
else:
print "No word of the day, %s" % (response.content)
return content
def main():
parser = argparse.ArgumentParser(description="Grab and display the current word of the day")
parser.add_argument("--debug", type=str, help="Grab a local file for iterative testing, rather than the actual site content")
args = parser.parse_args()
content = ""
if args.debug:
content = read_cached(args.debug)
elif is_cached():
content = read_cached(cache_filename())
else:
content = fetch_content()
if content:
parse_and_display(content)
print
if __name__ == "__main__":
main()