This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
# Function/arguments: get_rdns(ip) | |
# Description: Perform a reverse DNS query for the passed-in IP address. | |
# Returns: String: the reverse DNS name, or ''. | |
def get_rdns(ip): | |
try: | |
result = socket.gethostbyaddr(ip)[0] | |
except socket.herror: | |
# print 'Unable to get rDNS for', ip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# Function/arguments: now() | |
# Description: Returns the current system time for the logfile. | |
# Returns: A string with the current time for the logfile. | |
def now(): | |
result = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function/arguments: decmactohexmac(decmac) | |
# Description: Convert Decimal MAC address to hex MAC address (123.123.123.123.123.123 -> 00AABBCCDDEE) | |
# Returns: MAC address in hex format without delimiters | |
def decmactohexmac(decmac): # | |
decmac = decmac.split(".") | |
hexmac = ''.join(str(hex(int(i)).lstrip('0x')).zfill(2) for i in decmac).upper() | |
return hexmac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function/arguments: hexmactodecmac(hexmac) | |
# Description: Convert hex MAC address to decimal MAC address (00AABBCCDDEE -> 123.123.123.123.123.123) | |
# Returns: MAC address in dec format with delimiters(".") | |
def hexmactodecmac(hexmac): | |
hexmac = re.findall(r'.{1,2}', hexmac, re.DOTALL) | |
decmac = '.'.join(str(int(i, 16)).zfill(1) for i in hexmac) | |
return decmac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dpkt | |
import socket | |
# Function/arguments: get_rdns(ip) | |
# Description: Perform a reverse DNS query for the passed-in IP address. | |
# Returns: String: the reverse DNS name, or ''. | |
def get_rdns(ip): | |
try: | |
result = socket.gethostbyaddr(ip)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print '\n'.join("%s: %s" % item for item in vars(x).items()) # replace 'x'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Download ALL attachments from GMail | |
# 1. Script needs to be run via console not in an IDE, getpass.getpass() will fail otherwise. | |
# https://docs.python.org/2/library/getpass.html | |
# 2. Make sure you have IMAP enabled in your GMail settings. | |
# https://support.google.com/mail/troubleshooter/1668960?hl=en | |
# 3. If you are using 2 step verification you may need an APP Password. | |
# https://support.google.com/accounts/answer/185833 | |
# 4. Reference information for GMail IMAP extension can be found here. | |
# https://developers.google.com/gmail/imap_extensions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pip | |
from subprocess import call | |
for dist in pip.get_installed_distributions(): | |
call("pip install --upgrade " + dist.project_name, shell=True) |