from time import localtime, strftime from Crypto.Random import random import re import string import base64 import binascii import sys import os import socket import sqlite3 import iptools """ Misc. helper functions used in EmPyre. Includes the Python functions that generate the randomized stagers. """ ############################################################### # # Validation methods # ############################################################### def validate_hostname(hostname): """ Tries to validate a hostname. """ if len(hostname) > 255: return False if hostname[-1:] == ".": hostname = hostname[:-1] allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?