Beispiel #1
0
 def setServerurl(self):
     """ Set or edit the server URL used for updates """
     logging.debugv("menu/config.py->setServerurl(self)", [])
     url = self.c.getServerurl()
     input = self.d.inputbox("Full URL of IDS server:", init=url, width=100)
     if input[0] == 1: return
     if t.urlCheck(input[1]):
         url = input[1]
         logging.info("Setting serverurl to: %s" + str(url))
         self.changed = True
         self.c.setServerurl(url)
     else:
         self.d.msgbox("You entered an invalid URL. Make sure it ends with a forward slash.")
         self.setServerurl()
Beispiel #2
0
 def setServerurl(self):
     """ Set or edit the server URL used for updates """
     logging.debugv("menu/config.py->setServerurl(self)", [])
     url = self.c.getServerurl()
     input = self.d.inputbox("Full URL of IDS server:", init=url, width=100)
     if input[0] == 1: return
     if t.urlCheck(input[1]):
         url = input[1]
         logging.info("Setting serverurl to: %s" + str(url))
         self.changed = True
         self.c.setServerurl(url)
     else:
         self.d.msgbox(
             "You entered an invalid URL. Make sure it ends with a forward slash."
         )
         self.setServerurl()
Beispiel #3
0
def saveConf():
    """ Send the configuration to the server

        mainConf = 	"dhcp" | "ip|tap_ip|nm|bc|gw"
        vlanDesc = 	<description of vlan. May not contain comma's.>
        vlanConf = 	VLAN_ID , MAINCONF , VLANDESC
        trunkConf = 	VLANCONF ! VLANCONF ! VLANCONF ! ...

        request:        	save_config.php

	    required arguments:
                strip_html_escape_interfacedev=<eth-device>
				strip_html_escape_trunkdev=<eth-device>
				strip_html_escape_keyname=<sensorN>
				strip_html_escape_method=(vlan|normal)
				strip_html_escape_interface=<mainConf>
				strip_html_escape_trunk=<trunkConf>
				int_rev=<revision number>

	    optional arguments:
                ip_dns1=<ip>
				ip_dns2=<ip>
				strip_html_escape_version=<string identifying sensor>
    """
    logging.debugv("client.py->saveConf()", [])

    if not t.urlCheck(c.getServerurl()):
        logging.warning("Server URL invalid. Could not save configuration!")
        c.changed = True
        return

    method = c.netconf['sensortype']

    mainIf = c.getMainIf()
    trunkIf = c.getTrunkIf()

    mainInfConf = c.getIf(mainIf)
    if mainInfConf["type"] == "static":
        mainConf = mainInfConf["address"] + "|" + mainInfConf[
            "tunnel"] + "|" + mainInfConf["netmask"] + "|"
        mainConf += mainInfConf["broadcast"] + "|" + mainInfConf["gateway"]
    elif mainInfConf["type"] == "dhcp":
        mainConf = "dhcp"

    trunkConf = ""
    if method == "vlan":
        for (vlan, vlanConf) in c.getVlans().items():
            desc = vlanConf["description"]
            tunnel = vlanConf["tunnel"]
            vlanid = vlanConf["vlanid"]
            vlanType = vlanConf["type"]
            logging.debug(vlanid + " - " + vlanType)
            if vlanType == "static":
                nm = vlanConf["netmask"]
                gw = vlanConf["gateway"]
                bc = vlanConf["broadcast"]
                vlanIf = "|" + tunnel + "|" + nm + "|" + bc + "|" + gw
            else:
                vlanIf = "dhcp"
            trunkConf += vlanid + "," + vlanIf + "," + desc + "!"
        trunkConf = trunkConf.rstrip("!")

    sensor = c.getSensorID()
    (dnstype, dns1, dns2) = c.getDNS()
    (os, version, nr) = platform.dist()
    osv = os + "-" + version + "-" + nr
    req = "save_config.php"
    rev = c.getRev()
    args = urllib.urlencode(
        (('strip_html_escape_method', method), ('strip_html_escape_interface',
                                                str(mainConf)),
         ('strip_html_escape_interfacedev',
          str(mainIf)), ('strip_html_escape_keyname',
                         sensor), ('strip_html_escape_trunk', str(trunkConf)),
         ('strip_html_escape_trunkdev', str(trunkIf)),
         ('strip_html_escape_version', str(osv)), ('ip_dns1', str(dns1)),
         ('ip_dns2', str(dns2)), ('int_rev', str(rev))))

    logging.debug(str(args))
    try:
        x = makeRequest(req, args)
        for line in x.readlines():
            logging.debug(line[:-1])
        c.changed = False
    except excepts.NetworkException:
        c.changed = True
Beispiel #4
0
def saveConf():
    """ Send the configuration to the server

        mainConf = 	"dhcp" | "ip|tap_ip|nm|bc|gw"
        vlanDesc = 	<description of vlan. May not contain comma's.>
        vlanConf = 	VLAN_ID , MAINCONF , VLANDESC
        trunkConf = 	VLANCONF ! VLANCONF ! VLANCONF ! ...

        request:        	save_config.php

	    required arguments:
                strip_html_escape_interfacedev=<eth-device>
				strip_html_escape_trunkdev=<eth-device>
				strip_html_escape_keyname=<sensorN>
				strip_html_escape_method=(vlan|normal)
				strip_html_escape_interface=<mainConf>
				strip_html_escape_trunk=<trunkConf>
				int_rev=<revision number>

	    optional arguments:
                ip_dns1=<ip>
				ip_dns2=<ip>
				strip_html_escape_version=<string identifying sensor>
    """
    logging.debugv("client.py->saveConf()", [])

    if not t.urlCheck(c.getServerurl()):
        logging.warning("Server URL invalid. Could not save configuration!")
        c.changed = True
        return

    method = c.netconf['sensortype']

    mainIf = c.getMainIf()
    trunkIf = c.getTrunkIf()

    mainInfConf = c.getIf(mainIf)
    if mainInfConf["type"] == "static":
        mainConf = mainInfConf["address"] + "|" + mainInfConf["tunnel"] + "|" + mainInfConf["netmask"] + "|"
        mainConf += mainInfConf["broadcast"] + "|" + mainInfConf["gateway"]
    elif mainInfConf["type"] == "dhcp":
        mainConf = "dhcp"

    trunkConf = ""
    if method == "vlan":
        for (vlan, vlanConf) in c.getVlans().items():
           desc = vlanConf["description"]
           tunnel = vlanConf["tunnel"]
           vlanid = vlanConf["vlanid"]
           vlanType = vlanConf["type"]
           logging.debug(vlanid + " - " + vlanType)
           if vlanType == "static":
               nm = vlanConf["netmask"]
               gw = vlanConf["gateway"]
               bc = vlanConf["broadcast"]
               vlanIf = "|" + tunnel + "|" + nm + "|" + bc + "|" + gw
           else:
               vlanIf = "dhcp"
           trunkConf += vlanid + "," + vlanIf + "," + desc + "!"
        trunkConf = trunkConf.rstrip("!")

    sensor = c.getSensorID()
    (dnstype, dns1, dns2) = c.getDNS()
    (os, version, nr) = platform.dist()
    osv = os + "-" + version + "-" + nr
    req = "save_config.php"
    rev = c.getRev()
    args = urllib.urlencode((
        ('strip_html_escape_method', method),
        ('strip_html_escape_interface', str(mainConf)),
        ('strip_html_escape_interfacedev', str(mainIf)),
        ('strip_html_escape_keyname', sensor),
        ('strip_html_escape_trunk', str(trunkConf)),
        ('strip_html_escape_trunkdev', str(trunkIf)),
    	('strip_html_escape_version', str(osv)),
    	('ip_dns1', str(dns1)),
        ('ip_dns2', str(dns2)),
    	('int_rev', str(rev)))
    )

    logging.debug(str(args))
    try:
        x = makeRequest(req, args)
        for line in x.readlines(): logging.debug(line[:-1])
        c.changed = False
    except excepts.NetworkException:
        c.changed = True