예제 #1
0
파일: table.py 프로젝트: maximerobin/Ufwi
    def entry_form(self, entry):
        """ We transform IP form to a string
            @param entry [tuple]
            @return [tuple]

            username, [ip_saddr_str, os_sysname], start_time[, end_time] """

        result = ((anonymizer.anon_username(self.ctx, entry[0])),)

        if self.args['extra']:
            # On *usersstats* table, ip endian is not the same than other tables, so we reverse all bits.
            if self.database.ip_type == 4 and (isinstance(entry[1], int) or isinstance(entry[1], long)
                                              or isinstance(entry[1], str) and entry[2].isdigit()):
                ip = struct.unpack("<I", struct.pack(">I", int(entry[1])))[0]
            else:
                ip = entry[1]

            result += (anonymizer.anon_ipaddr(self.ctx, self.ip2str(ip)),)
            result += entry[2:3]

        result += (entry[3],)
        if not self.args['currents']:
            result += (entry[4],)

        return result
예제 #2
0
파일: table.py 프로젝트: maximerobin/Ufwi
    def entry_form(self, entry):
        """ We transform IP form to a string
            @param entry [tuple]
            @return [list of tuple]
        """

        # ip, packts
        result = (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[0])),)
        result += entry[1:]
        return result
예제 #3
0
파일: squid.py 프로젝트: maximerobin/Ufwi
    def entry_form(self, entry):
        """ We transform IP form to a string
            @param entry [tuple]
            @return [list of tuple]
        """

        # ip, requests, start_time, volume, start_time, end_time
        result = (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[0])),)
        result += entry[1:]
        return result
예제 #4
0
파일: info.py 프로젝트: maximerobin/Ufwi
    def entry_form(self, entry):
        """ We transform IP form to a string
            @param entry [tuple]
            @return [tuple]

            id, username, oob_time_sec, oob_time_usec, oob_in, oob_out, oob_prefix, oob_mark, ip_saddr_str,
            ip_daddr_str, ...
        """
        result = (entry[0],)
        result += (anonymizer.anon_username(self.ctx, entry[1]),)

        result += entry[2:8]
        result += (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[8])),)
        result += (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[9])),)
        result += entry[10:16]
        result += (self.proto2str(entry[16]),)
        result += (1 if entry[17] else 0,)
        result += entry[18:34]
        result += (anonymizer.anon_appname(self.ctx, entry[34]),)
        result += entry[35:]

        return result
예제 #5
0
 def service_getUsers(self, context):
     """Get the list of connected NuFW users"""
     users = []
     for user in self._command("users"):
         users.append({
             'name': anonymizer.anon_username(context, unicode(user.name)),
             'uid': anonymizer.anon_userid(context, int(user.uid)),
             'addr': anonymizer.anon_ipaddr(context, unicode(user.addr)),
             'sock': int(user.socket),
             'sport': int(user.sport),
             'groups': [unicode(group) for group in user.groups],
             'connect_timestamp': unicode(user.connect_timestamp),
             'uptime': unicode(user.uptime),
             'expire': user.expire or '', # it can be None
             'sysname': unicode(user.sysname),
             'release': unicode(user.release),
             'version': unicode(user.version),
             'activated': unicode(user.activated),
             'client_version': unicode(user.client_version),
         })
     return users
예제 #6
0
파일: table.py 프로젝트: maximerobin/Ufwi
 def entry_form(self, result):
     return (anonymizer.anon_ipaddr(self.ctx, self.ip2str(result[0])),) + result[1:]
예제 #7
0
파일: table.py 프로젝트: maximerobin/Ufwi
    def entry_form(self, entry):
        """ We transform IP form to a string
            @param entry [tuple]
            @return [tuple]

            packet_id, username, ip_saddr_str, ip_daddr_str, protocol, sport, dport, oob_time_sec, oob_prefix, raw_label """

        if entry[1]:
            _id = '1'
        else:
            _id = '0'
        result = ((_id, entry[0]),)

        if entry[1] and (not 'source' in self.filters or
                    not isinstance(self.filters['source'], (int,long)) and
                    (not isinstance(self.filters['source'], (str,unicode)) or not self.filters['source'].isdigit())):
            result += ((anonymizer.anon_username(self.ctx, entry[1])),)
        else:
            result += (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[2])),)
        result += (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[3])),)
        result += (self.proto2str(entry[4]),)

        if self.args['tiny']:
            result += entry[5:7]
        else:
            result += entry[5:8]

            # Stock ACL number, if exists, in 'acl' field
            # Parse "F42A:bla bla": acl type=FORWARD, acl id=42, decision=ACCEPT, comment="bla bla"
            match = entry[8] and re.match("([FIO])([0-9]+)([adrADRU]):(.*)", entry[8])
            if match:
                # Add column if doesn't exit
                try:
                    # If doesn't exist it will raise an exception
                    self.columns.index('acl')
                except ValueError:
                    self._add_column('acl')

                target = match.group(1)
                acl_id = match.group(2)
                decision = match.group(3)
                comment = match.group(4)

                #decision = {'a': 'ACCEPT',
                #            'd': 'DROP',
                #            'r': 'REJECT',
                #            'A': 'ACCEPT NUFW',
                #            'D': 'DROP NUFW',
                #            'R': 'REJECT NUFW',
                #            'U': 'UNAUTHENTICATED DROP'
                #           }.get(decision, decision)
                if decision == 'U' and entry[1] == None:
                    comment = comment + tr("(Missing authentication)")
                result += ((comment, entry[8]),)
                ip = IP(self.ip2str(entry[3]))
                result += ('%s:%s:acls-ipv%d' % (target, acl_id, ip.version()),)
            else:
                if entry[8] == "Drop " and entry[1] == None:
                     result += (entry[8] + tr("(Missing authentication)"),)
                else:
                    result += (entry[8],)

        self.states['%s' % entry[0]] = 1 if entry[9] else 0
        return result
예제 #8
0
파일: squid.py 프로젝트: maximerobin/Ufwi
 def entry_form(self, entry):
     result = (anonymizer.anon_ipaddr(self.ctx, self.ip2str(entry[0])),)
     result += entry[1:]
     return result