Example #1
0
    def setEncryption(self, mode="none", username="", password="", channel="", ssid="", auth="", inner="", anon="",\
            ca_cert="", client_cert="", private_key="", private_key_passwd=""):
        have_supplicant = True
        try:
            import wpa_supplicant
        except ImportError:
            have_supplicant = False

        ifc = self.ifc

        # Disable all auth. mechanisms before try to authenticate another methods
        os.system("/usr/sbin/iwconfig %s enc off" % (ifc.name))
        if have_supplicant and wpa_supplicant.isWpaServiceUsable():
            # Stop WPA authentication
            wpa_supplicant.disableAuthentication(ifc.name)

        if mode == "wep":
            os.system("/usr/sbin/iwconfig '%s' enc restricted '%s'" %
                      (ifc.name, password))
            if channel:
                os.system("/usr/sbin/iwconfig '%s' channel %s" %
                          (ifc.name, channel))
        elif mode == "wepascii":
            os.system("/usr/sbin/iwconfig '%s' enc restricted 's:%s'" %
                      (ifc.name, password))
            if channel:
                os.system("/usr/sbin/iwconfig '%s' channel %s" %
                          (ifc.name, channel))
        elif mode == "wpa-psk":
            if not have_supplicant:
                return _(no_supplicant_msg)
            if not wpa_supplicant.startWpaService():
                fail("Unable to start WPA service")
            ret = wpa_supplicant.setWpaAuthentication(ifc.name, ssid, password)
            if not ret:
                return _(wpa_fail_msg)
        elif mode == "802.1x":
            if not have_supplicant:
                return _(no_supplicant_msg)
            if not wpa_supplicant.startWpaService():
                fail("Unable to start WPA service")

            ieee = wpa_supplicant.Wpa_EAP(ifc.name)
            ieee.ssid = ssid
            ieee.anonymous_identity = anon
            ieee.key_mgmt = "IEEE8021X"
            ieee.eap = auth
            ieee.phase2 = inner
            ieee.ca_cert = ca_cert
            ieee.client_cert = client_cert
            ieee.private_key = private_key
            ieee.private_key_passwd = private_key_passwd

            ret = ieee.authenticate(username, password)
            if not ret:
                return _(wpa_fail_msg)
        return ""
Example #2
0
    def setEncryption(self, mode="none", username="", password="", channel="", ssid="", auth="", inner="", anon="",\
            ca_cert="", client_cert="", private_key="", private_key_passwd=""):
        have_supplicant = True
        try:
            import wpa_supplicant
        except ImportError:
            have_supplicant = False

        ifc = self.ifc

        # Disable all auth. mechanisms before try to authenticate another methods
        os.system("/usr/sbin/iwconfig %s enc off" % (ifc.name))
        if have_supplicant and wpa_supplicant.isWpaServiceUsable():
            # Stop WPA authentication
            wpa_supplicant.disableAuthentication(ifc.name)

        if mode == "wep":
            os.system("/usr/sbin/iwconfig '%s' enc restricted '%s'" % (ifc.name, password))
            if channel:
                os.system("/usr/sbin/iwconfig '%s' channel %s" % (ifc.name, channel))
        elif mode == "wepascii":
            os.system("/usr/sbin/iwconfig '%s' enc restricted 's:%s'" % (ifc.name, password))
            if channel:
                os.system("/usr/sbin/iwconfig '%s' channel %s" % (ifc.name, channel))
        elif mode == "wpa-psk":
            if not have_supplicant:
                return _(no_supplicant_msg)
            if not wpa_supplicant.startWpaService():
                fail("Unable to start WPA service")
            ret = wpa_supplicant.setWpaAuthentication(ifc.name, ssid, password)
            if not ret:
                return _(wpa_fail_msg)
        elif mode == "802.1x":
            if not have_supplicant:
                return _(no_supplicant_msg)
            if not wpa_supplicant.startWpaService():
                fail("Unable to start WPA service")

            ieee = wpa_supplicant.Wpa_EAP(ifc.name)
            ieee.ssid = ssid
            ieee.anonymous_identity = anon
            ieee.key_mgmt = "IEEE8021X"
            ieee.eap = auth
            ieee.phase2 = inner
            ieee.ca_cert = ca_cert
            ieee.client_cert = client_cert
            ieee.private_key = private_key
            ieee.private_key_passwd = private_key_passwd

            ret = ieee.authenticate(username, password)
            if not ret:
                return _(wpa_fail_msg)
        return ""
Example #3
0
    def setEncryption(self, mode=None, parameters=None):
        supplicant = True
        try:
            import wpa_supplicant
        except ImportError:
            supplicant = False

        os.system("/usr/sbin/iwconfig %s enc off" % self.ifc.name)

        if supplicant and wpa_supplicant.isWpaServiceUsable():
            wpa_supplicant.disableAuthentication(self.ifc.name)

        # TODO a guessEncryption() function to determine if its wep or wepascii or open (no enc)
        # TODO check returning data from iwconfig, these calls dont work most of the time but we simply pass
        if mode == "wep":
            os.system("/usr/sbin/iwconfig '%s' enc restricted '%s'" % (self.ifc.name, parameters["password"]))
        elif mode == "wepascii":
            os.system("/usr/sbin/iwconfig '%s' enc restricted 's:%s'" % (self.ifc.name, parameters["password"]))
        elif mode == "wpa-psk":
            if not supplicant:
                fail(_(MSG_NO_SUPPLICANT))
            if not wpa_supplicant.startWpaService():
                fail(_(MSG_NO_SUPPLICANT_SERVICE))
            try:
                ret = wpa_supplicant.setWpaAuthentication(self.ifc.name, self.ssid, parameters["password"])
            except:
                return
            if not ret:
                fail(_(MSG_WPA_FAILED))
        elif mode == "802.1x":
            pass
Example #4
0
    def setEncryption(self, mode="none", password=None):
        have_supplicant = True
        try:
            import wpa_supplicant
        except ImportError:
            have_supplicant = False

        ifc = self.ifc

        # Disable all auth. mechanisms before try to authenticate another methods
        os.system("/usr/sbin/iwconfig %s enc off" % (ifc.name))
        if have_supplicant and wpa_supplicant.isWpaServiceUsable():
            # Stop WPA authentication
            wpa_supplicant.disableAuthentication(ifc.name)

        if mode == "wep":
            os.system("/usr/sbin/iwconfig '%s' enc restricted '%s'" %
                      (ifc.name, password))
        elif mode == "wepascii":
            os.system("/usr/sbin/iwconfig '%s' enc restricted 's:%s'" %
                      (ifc.name, password))
        elif mode == "wpa-psk":
            if not have_supplicant:
                return _(no_supplicant_msg)
            if not wpa_supplicant.startWpaService():
                fail("Unable to start WPA service")
            ret = wpa_supplicant.setWpaAuthentication(ifc.name, self.getSSID(),
                                                      password)
            if not ret:
                return _(wpa_fail_msg)
        return None
Example #5
0
    def setEncryption(self, mode="none", password=None):
        have_supplicant = True
        try:
            import wpa_supplicant
        except ImportError:
            have_supplicant = False

        ifc = self.ifc

        # Disable all auth. mechanisms before try to authenticate another methods
        os.system("/usr/sbin/iwconfig %s enc off" % (ifc.name))
        if have_supplicant and wpa_supplicant.isWpaServiceUsable():
            # Stop WPA authentication
            wpa_supplicant.disableAuthentication(ifc.name)

        if mode == "wep":
            os.system("/usr/sbin/iwconfig '%s' enc restricted '%s'" % (ifc.name, password))
        elif mode == "wepascii":
            os.system("/usr/sbin/iwconfig '%s' enc restricted 's:%s'" % (ifc.name, password))
        elif mode == "wpa-psk":
            if not have_supplicant:
                return _(no_supplicant_msg)
            if not wpa_supplicant.startWpaService():
                fail("Unable to start WPA service")
            ret = wpa_supplicant.setWpaAuthentication(ifc.name, self.getSSID(), password)
            if not ret:
                return _(wpa_fail_msg)
        return None