Beispiel #1
0
    def start(self):
        """
        Start the softAP
        :param self: An AccessPoint object
        :type self: AccessPoint
        :return: None
        :rtype: None
        """

        # create the configuration for roguehostapd
        hostapd_config = {
            "ssid": self.essid,
            "interface": self.interface,
            "channel": self.channel,
            "karma_enable": 1
        }
        if self.psk:
            hostapd_config['wpa_passphrase'] = self.psk

        # create the option dictionary
        hostapd_options = {
            'debug_level': hostapd_constants.HOSTAPD_DEBUG_OFF,
            'mute': True,
            "eloop_term_disable": True
        }

        try:
            self.hostapd_object = hostapd_controller.Hostapd()
            self.hostapd_object.start(hostapd_config, hostapd_options)
        except KeyboardInterrupt:
            raise Exception
        # when roguehostapd fail to start rollback to use the hostapd
        # on the system
        except BaseException:
            hostapd_config.pop("karma_enable", None)
            hostapd_options = {}
            hostapd_config_obj = hostapd_controller.HostapdConfig()
            hostapd_config_obj.write_configs(hostapd_config, hostapd_options)
            self.update_black_macs()

            # handle exception if hostapd is not installed in system
            try:
                self.hostapd_object = subprocess.Popen(
                    ['hostapd', hostapd_constants.HOSTAPD_CONF_PATH],
                    stdout=constants.DN,
                    stderr=constants.DN)
            except OSError:
                print("[" + constants.R + "!" + constants.W + "] " +
                      "hostapd is not installed!")
                # just raise exception when hostapd is not installed
                raise Exception

            time.sleep(2)
            if self.hostapd_object.poll() is not None:
                print("[" + constants.R + "!" + constants.W + "] " +
                      "hostapd failed to lunch!")
                raise Exception
Beispiel #2
0
def run():
    """
    Run the hostapd
    """

    args = parse_args()
    check_args(args)
    hostapd_dict, options = get_configuration_dicts(vars(args))
    options['eloop_term_disable'] = True
    hostapd_obj = hostapd_controller.Hostapd()
    hostapd_obj.start(hostapd_dict, options)

    while True:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            hostapd_obj.stop()
            break
Beispiel #3
0
"""
Example for lunching the TKIP Access Point
"""
from roguehostapd import hostapd_controller

if __name__ == "__main__":
    HOSTAPD_CONFIG = {
        'ssid': 'test',
        'interface': 'wlan12',
        'wpa': '1',
        'wpa_passphrase': '12345678',
    }
    HOSTAPD_OBJ = hostapd_controller.Hostapd()
    HOSTAPD_OBJ.start(HOSTAPD_CONFIG, {})