Skip to content

Instantly share code, notes, and snippets.

from datetime import datetime
def validate_workday(date_to_check):
# valid work days
# Monday = 1
# Tuesday = 2
# Wednesday = 3
# Thursday = 4
#!/usr/bin/env python3
"""
This Python script is designed to colorize specific words in a string of
text. The colorized text is written to the console.
"""
__author__ = 'John Bumgarner'
__date__ = 'June 25, 2021'
__status__ = 'Production'
__license__ = 'MIT'
#!/usr/bin/env python3
"""
This Python script is designed to colorize specific words in a string of
text. The colorized text is written to an HTML file.
"""
__author__ = 'John Bumgarner'
__date__ = 'June 24, 2021'
__status__ = 'Production'
__license__ = 'MIT'
@johnbumgarner
johnbumgarner / parse_email_message.py
Created January 2, 2021 17:02
This function is designed to parse an email message using the built-in Python module email.
######################################################################################
# The re module is part of the standard Python library which regular expression
# matching operations similar to those found in Perl.
######################################################################################
import re as regex
######################################################################################
# The email module is part of the standard Python library which provides
# functions for reading, writing, and sending simple email messages.
#
@johnbumgarner
johnbumgarner / comparison_scores_skimage.py
Last active January 2, 2021 13:20
This function is designed to generate comparison scores between two image using ssim from skimage.
######################################################################################
# The concurrent.futures module is part of the standard Python library which provides
# a high level API for launching asynchronous tasks.
######################################################################################
import concurrent.futures
#############################################################################################
# The OS module in provides functions for interacting with the operating system.
#
# os.path() provides various functions to handle pathnames.
@johnbumgarner
johnbumgarner / comparison_scores_ahash.py
Last active August 25, 2022 04:41
This function is designed to generate comparison scores between two image using aHash from ImageHash.
######################################################################################
# The concurrent.futures module is part of the standard Python library which provides
# a high level API for launching asynchronous tasks.
######################################################################################
import concurrent.futures
######################################################################################
# The Python module Pillow is the folk of PIL, the Python Imaging Library
# reference: https://pillow.readthedocs.io/en/3.0.x/index.html
######################################################################################
@johnbumgarner
johnbumgarner / extract_http_information.py
Created December 2, 2020 16:24
This function is designed to extract the HTTP information from IPv4 and ICMPv6 packets.
def extract_http_information(packet):
"""
This function is designed to extract the HTTP information from IPv4 and ICMPv6 packets.
:param packet: PCAP packet
:return:
"""
try:
if 'IPv4' in str(packet.layers[0]) and 'HTTP' in str(packet.layers):
source_address = packet.ip.src
destination_address = packet.ip.dst
@johnbumgarner
johnbumgarner / extract_dns_information.py
Created December 2, 2020 16:21
This function is designed to extract DNS elements from a PCAP packet.
# use with pyshark
def extract_dns_information(packet):
"""
This function is designed to extract DNS elements from a PCAP packet.
:param packet: PCAP packet
:return:
"""
if hasattr(packet, 'udp') and packet[packet.transport_layer].dstport == '53':
try:
@johnbumgarner
johnbumgarner / extract_ipv6_information.py
Created December 2, 2020 16:18
This function is designed to extract specific IPv6 elements from a PCAP packet.
# use with pyshark
def extract_ipv6_information(packet):
"""
This function is designed to extract specific IPv6 elements from a PCAP packet.
:param packet: PCAP packet
:return:
"""
try:
if 'IPV6' in str(packet.layers):
@johnbumgarner
johnbumgarner / extract_conversation_header.py
Last active December 2, 2020 16:25
This function is designed to extract the conversation header information from IPv4 or ICMPv6 packets.
# use with pyshark
import re as regex
def extract_conversation_header(packet):
"""
This function is designed to extract the conversation header information
from IPv4 or ICMPv6 packets.
:param packet: PCAP packet
:return: {protocol} {source_address}:{source_port} --> {destination_address}:{destination_port}