Ejemplo n.º 1
0
    def __init__(self, action):
        TLSRelay.action = action
        self.path = os.environ['HOME_DIR']

        with open(f'{self.path}/data/config.json', 'r') as settings:
            self.setting = json.load(settings)

        self.lan_int = self.setting['Settings']['Interface']['Inside']
        TLSRelay.wan_int = self.setting['Settings']['Interface']['Outside']
        self.dnsserver = self.setting['Settings']['DNSServers']

        Int = Interface()
        self.lan_ip = Int.IP(self.lan_int)
        self.wan_ip = Int.IP(self.wan_int)
        dfg = Int.DefaultGateway()
        dfg_mac = Int.IPtoMAC(dfg)
        self.wan_mac = Int.MAC(self.wan_int)
        self.lan_mac = Int.MAC(self.lan_int)
        wan_subnet = Int.WANSubnet(self.wan_int, dfg)
        self.wan_info = [dfg_mac, wan_subnet]

        TLSRelay.connections = {'Clients': {}}
        TLSRelay.active_connections = {'Clients': {}}
        TLSRelay.tcp_handshakes = {'Clients': {}}
        self.nat_ports = {}

        ## RAW Sockets which actually handle the traffic.
        TLSRelay.lan_sock = socket(AF_PACKET, SOCK_RAW)
        self.lan_sock.bind((self.lan_int, 3))
        self.wan_sock = socket(AF_PACKET, SOCK_RAW)
        self.wan_sock.bind((self.wan_int, 3))

        self.tls_ports = {443}
        TLSRelay.tcp_info = []
Ejemplo n.º 2
0
    def __init__(self):
        self.path = os.environ['HOME_DIR']

        with open('{}/data/config.json'.format(self.path), 'r') as settings:
            self.setting = json.load(settings)
                                
        self.iface = self.setting['Settings']['Interface']['Inside']
        self.wface = self.setting['Settings']['Interface']['Outside']
    
        Int = Interface()
        self.insideip = Int.IP(self.iface)
        self.wanip = Int.IP(self.wface)
        self.DEVNULL = open(os.devnull, 'wb')
        self.dns_sigs = {}

        self.session_tracker = {'Clients': {}}
Ejemplo n.º 3
0
    def ShowIPAddress(self, initial_load=False):
        Inter = Int()
        with open(f'{HOME_DIR}/data/config.json', 'r') as settings:
            setting = json.load(settings)
        interface_settings = setting['settings']['interface']
        default_wan_mac = interface_settings['wan']['default_mac']
        configured_wan_mac = interface_settings['wan']['configured_mac']
        dhcp = interface_settings['wan']['dhcp']
        wan_int = interface_settings['outside']
        if (not configured_wan_mac):
            configured_wan_mac = default_wan_mac
        if (dhcp):
            wan_mode = 'dhcp'
        else:
            wan_mode = 'static'

        wan_ip = Inter.IP(wan_int)
        wan_netmask = Inter.Netmask(wan_int)
        wan_dfg = Inter.DefaultGateway(wan_int)
        if (initial_load):
            self.interface_settings_pending['mode'].update(
                {'setting': wan_mode})
        else:
            self.Standard.ShowSend('ip-address', wan_ip)
            self.Standard.ShowSend('netmask', wan_netmask)
            self.Standard.ShowSend('default-gateway', wan_dfg)
            self.Standard.ShowSend('mode', wan_mode)
Ejemplo n.º 4
0
 def AssignValues(self):
     self.l2pro = 0x0800
     Int = Interface()
     self.smac = Int.MAC(self.wan_int)
     self.dmac = self.packet.src_mac
     self.src_ip = Int.IP(self.wan_int)
     self.dst_ip = self.packet.src_ip
     self.icmp_payload = self.packet.ipv4_header + self.packet.udp_header
Ejemplo n.º 5
0
 def InterfaceInfo(self):
     Int = Interface()
     insideip = Int.IP(self.insideint)
     netmask = Int.Netmask(self.insideint)
     broadcast = Int.Broadcast(self.insideint)
     mtu = Int.MTU(self.insideint)
     
     return(insideip, netmask, broadcast, mtu)
Ejemplo n.º 6
0
    def __init__(self):
        self.path = os.environ['HOME_DIR']

        with open(f'{self.path}/data/config.json', 'r') as settings:
            self.setting = json.load(settings)

        self.iniface = self.setting['Settings']['Interface']['Inside']
        self.waniface = self.setting['Settings']['Interface']['Outside']
        self.dnsserver = self.setting['Settings']['DNSServers']

        Int = Interface()
        self.laddr = Int.IP(self.iniface)
        self.qaddr = Int.IP(self.waniface)
        self.dns1 = [self.dnsserver['Server1']['IP Address'], True]
        self.dns2 = [self.dnsserver['Server2']['IP Address'], True]
        self.dnsList = [self.dns1, self.dns2]
        self.lport = 53
Ejemplo n.º 7
0
    def InterfaceInfo(self):
        Interface = Int()
        insideip = Interface.IP(self.lan_int)
        netmask = Interface.Netmask(self.lan_int)
        broadcast = Interface.Broadcast(self.lan_int)
        mtu = Interface.MTU(self.lan_int)

        return(insideip, netmask, broadcast, mtu)
Ejemplo n.º 8
0
    def LoadInterfaces(self):
        with open(f'{HOME_DIR}/data/config.json', 'r') as settings:
            self.setting = json.load(settings)

        self.lan_int = self.setting['settings']['interface']['inside']
        self.wan_int = self.setting['settings']['interface']['outside']

        Int = Interface()
        self.wan_ip = Int.IP(self.wan_int)
        self.broadcast = Int.Broadcast(self.wan_int)
Ejemplo n.º 9
0
    def AssignValues(self):
        self.l2pro = 0x0800
        Int = Interface()
        self.smac = Int.MAC(self.wan_int)
        self.dmac = self.packet.src_mac
        self.src_ip = Int.IP(self.wan_int)
        self.dst_ip = self.packet.src_ip
        self.src_port = self.packet.dst_port
        self.dst_port = self.packet.src_port

        self.sport = struct.pack('!H', self.src_port)
        #        print(self.packet.seq_number)
        self.ack_number = self.packet.seq_number + 1
Ejemplo n.º 10
0
    def __init__(self, insideint, xid, mac, ciaddr, chaddr, options, Leases):
        Int = Interface()
        self.insideip = Int.IP(insideint)

        self.Leases = Leases

        self.xID = xid
        self.chaddr = chaddr
        self.ciaddr = ciaddr
        self.serveroptions = options

        self.yiaddr = self.Leases.Handout(mac)
        print('Handing Out: {}'.format(self.yiaddr))
Ejemplo n.º 11
0
    def __init__(self):
        with open(f'{HOME_DIR}/data/config.json', 'r') as configs:
            config = json.load(configs)
        lan_int = config['settings']['interface']['inside']

        Interface = Int()
        self.lan_ip = Interface.IP(lan_int)

        self.syslog_queue = deque()
        self.tls_retry = 0
        self.tcp_retry = 0
        self.tcp_fallback = False
        self.tcp_fallback = False

        self.queue_lock = threading.Lock()
Ejemplo n.º 12
0
    def __init__(self):
        self.path = os.environ['HOME_DIR']
        #        self.System = Sys()
        #        self.Syslog = SyslogService()

        with open(f'{self.path}/data/config.json', 'r') as settings:
            self.setting = json.load(settings)

        self.lan_int = self.setting['Settings']['Interface']['Inside']
        self.wan_int = self.setting['Settings']['Interface']['Outside']

        Int = Interface()
        self.laddr = Int.IP(self.lan_int)
        self.qaddr = Int.IP(self.wan_int)

        self.dns_connection_tracker = {}
        self.dns_tls_queue = []
Ejemplo n.º 13
0
    def __init__(self):
        self.path = os.environ['HOME_DIR']

        with open('{}/data/config.json'.format(self.path), 'r') as settings:
            self.setting = json.load(settings)

        self.iface = self.setting['Settings']['Interface']['Inside']

        Int = Interface()
        self.insideip = Int.IP(self.iface)
        self.DEVNULL = open(os.devnull, 'wb')
        self.dns_sigs = {}
        self.b_list = {}
        self.ent_logging = True
        self.ent_full = False

        self.log_supress = set()
Ejemplo n.º 14
0
    def __init__(self):
        self.path = os.environ['HOME_DIR']
#        self.Syslog = SyslogService()

        with open(f'{self.path}/data/config.json', 'r') as settings:
            setting = json.load(settings)
        self.lan_int = setting['Settings']['Interface']['Inside']

        Int = Interface()
        self.lan_ip = Int.IP(self.lan_int)
        self.DEVNULL = open(os.devnull, 'wb')
        self.full_logging = None
        self.ip_whitelist = None
        self.dns_whitelist = None
        self.dns_blacklist = None
        self.dns_sigs = {}
        self.dns_records = {}

        self.flagged_traffic = {}
Ejemplo n.º 15
0
    def __init__(self):
        self.path = os.environ['HOME_DIR']

        with open(f'{self.path}/data/config.json', 'r') as settings:
            self.setting = json.load(settings)

        self.lan_int = self.setting['Settings']['Interface']['Inside']
        self.wan_int = self.setting['Settings']['Interface']['Outside']

        Int = Interface()
        self.wan_ip = Int.IP(self.wan_int)
        self.broadcast = Int.Broadcast(self.wan_int)

        self.udp_scan_tracker = {}
        self.tcp_scan_tracker = {}
        self.udp_scan_drop = {}
        self.tcp_scan_drop = {}

        self.scan_mitigation = {}
        self.ddos_tracker = {self.wan_ip: {'TCP': {}, 'UDP': {}, 'ICMP': {}}}
        self.active_ddos = False