8.25. platformids.net.pfsense

Module pfSense [doc].

8.25.1. Source

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""pfSense releases.
"""
from __future__ import absolute_import

import re

from pythonids import PYV35Plus
from platformids import rte2num, num2rte, num2pretty, custom_dist, \
    decode_version_str_to_segments, RTE_BSD, PlatformIDsFileCheck

__author__ = 'Arno-Can Uestuensoez'
__license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
__copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \
                " @Ingenieurbuero Arno-Can Uestuensoez"
__version__ = '0.1.2'
__uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"



RTE_PFSENSE      = RTE_BSD   + custom_dist.add_enum()   #: Registration of the *dist* value
RTE_PFSENSE244   = RTE_PFSENSE            + 0x00006181  #: pfSense-2.4.4 
    
    
#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
    {
        'pfsense':   RTE_PFSENSE,
        RTE_PFSENSE: RTE_PFSENSE,
    }
)


#: mapping of the rte numeric representation to the string value
num2rte.update(
    {
        RTE_PFSENSE: 'pfsense',
   }
)


#: mapping of the rte numeric representation to the pretty string value
num2pretty.update(
    {
        RTE_PFSENSE: 'pfsense',
   }
)


dist = ['', '', '', 'pfSense', '', '']

try:
    # same as defaults:
    with open("/etc/platform", 'r') as f:
        for l in f:  # one entry only
            dist[2] = dist[3] = l
            dist[5] = l.lower()
    
    if dist[5] == 'pfsense':
        with open("/etc/version", 'r') as f:
            for l in f:  # one entry only
                dist[1] = re.sub(r'^\([0-9.]+).*', r'\1', l)
                dist[2] += 'pfSense-' + dist[1]
                dist[4] = decode_version_str_to_segments(dist[1])
                dist[0] = 'pfsense%d%d%d' % (dist[4][0], dist[4][1], dist[4][2], ) 

except PlatformIDsFileCheck:
    # not on pfSense platform, so scan will fail
    pass    

if dist[5] != 'pfsense':
    # does not actually match pfSense
    dist = ['pfsense', '0.0.0', 'pfSense-0.0.0', 'pfSense', (0, 0, 0,), 'pfsense']

8.25.2. Download

pfsense.py