from milenage import Milenage import binascii import base64 import logging import logtool import os import sys sys.path.append(os.path.realpath('../')) import yaml with open("config.yaml", 'r') as stream: yaml_config = (yaml.safe_load(stream)) logtool.setup_logger('CryptoLogger', 'log/crypto.log', level=yaml_config['logging']['level']) CryptoLogger = logging.getLogger('CryptoLogger') CryptoLogger.info("Initialised Diameter Logger, importing database") #The EUTRAN Authentication Vector generator is based on the one used in [Facebook Magma](https://github.com/facebookincubator/magma), which in turn is based off [OAI-CN](https://github.com/OPENAIRINTERFACE/openair-cn). def generate_eutran_vector(key, op_c, amf, sqn, plmn): CryptoLogger.debug("Generating EUTRAN Vectors") key = key.encode('utf-8') CryptoLogger.debug("Input K: " + str(key)) key = binascii.unhexlify(key) op_c = op_c.encode('utf-8') CryptoLogger.debug("Input OPc: " + str(op_c)) op_c = binascii.unhexlify(op_c)
#PyHSS #This serves as a basic 3GPP Home Subscriber Server implimenting a EIR & IMS HSS functionality import logging import yaml with open("config.yaml", 'r') as stream: yaml_config = (yaml.safe_load(stream)) import os import sys sys.path.append(os.path.realpath('lib')) #Setup Logging import logtool logtool.setup_logger('HSS_Logger', yaml_config['logging']['logfiles']['hss_logging_file'], level=yaml_config['logging']['level']) HSS_Logger = logging.getLogger('HSS_Logger') if yaml_config['logging']['log_to_terminal'] == True: logging.getLogger().addHandler( logging.StreamHandler()) #Log to Stdout as well import socket import socketserver import binascii import time import _thread from threading import Thread, Lock import sctp import traceback
##Features classes for different DB backends normalised to each return the same data ##Data is always provided by the function as a Dictionary of the Subscriber's data import yaml import logging import threading import os import sys sys.path.append(os.path.realpath('lib')) import S6a_crypt with open("config.yaml", 'r') as stream: yaml_config = (yaml.safe_load(stream)) import logtool logtool.setup_logger('DBLogger', yaml_config['logging']['logfiles']['database_logging_file'], level=yaml_config['logging']['level']) DBLogger = logging.getLogger('DBLogger') DBLogger.info("DB Log Initialised.") ##Data Output Format ###Get Subscriber Info #Outputs a dictionary with the format: #subscriber_details = {'K': '465B5CE8B199B49FAA5F0A2EE238A6BC', 'OPc': 'E8ED289DEBA952E4283B54E88E6183CA', 'AMF': '8000', 'RAND': '', 'SQN': 22, \ # 'APN_list': 'internet', 'pdn': [{'apn': 'internet', '_id': ObjectId('5fe2815ce601d905f8c597b3'), 'pcc_rule': [], 'qos': {'qci': 9, 'arp': {'priority_level': 8, 'pre_emption_vulnerability': 1, 'pre_emption_capability': 1}}, 'type': 2}]} class MongoDB: import mongo import pymongo