'start Access Point and settings plugins'

def Start_PumpAP(self):

    if (len(self.selectCard.currentText()) == 0):
        return QMessageBox.warning(self, 'Error    interface    ', 'Network    interface    is    not    found')
    if (not (type(self.SoftDependencies()) is bool)):
        return
    if self.FSettings.Settings.get_setting('accesspoint', 'check_support_ap_mode', format=bool):
        if (not ('AP' in Refactor.get_supported_interface(self.selectCard.currentText())['Supported'])):
            return QMessageBox.warning(self, 'No    Network    Supported    failed', '<strong>failed    AP    mode:    warning    interface    </strong>,    the    feature    Access    Point    Mode    is    Not    Supported    By    This    Device    -><strong>({})</strong>.<br><br>Your    adapter    does    not    support    for    create    Access    Point    Network.    '.format(self.selectCard.currentText()))
    self.interfacesLink = Refactor.get_interfaces()
    if (str(self.selectCard.currentText()) == self.interfacesLink['activated'][0]):
        iwconfig = Popen(['iwconfig'], stdout=PIPE, shell=False, stderr=PIPE)
        for line in iwconfig.stdout.readlines():
            if (str(self.selectCard.currentText()) in line):
                return QMessageBox.warning(self, 'Wireless    interface    is    busy', 'Connection    has    been    detected,    this    {}    is    joined    the    correct    Wi-Fi    network    :    Device    or    resource    busy\n{}\nYou    may    need    to    another    Wi-Fi    USB    Adapter    for    create    AP    or    try    use    with    local    connetion(Ethernet).'.format(str(self.selectCard.currentText()), line))
    (dh, gateway) = (self.PumpSettingsTAB.getPumpkinSettings()['router'], str(self.EditGateway.text()))
    if (dh[:(len(dh) - len(dh.split('.').pop()))] == gateway[:(len(gateway) - len(gateway.split('.').pop()))]):
        return QMessageBox.warning(self, 'DHCP    Server    settings', 'The    DHCP    server    check    if    range    ip    class    is    same.it    works,    but    not    share    internet    connection    in    some    case.\nfor    fix    this,    You    need    change    on    tab    (settings    ->    Class    Ranges)now    you    have    choose    the    Class    range    different    of    your    network.')
    if self.GroupApPassphrase.isChecked():
        if (1 <= self.WPAtype_spinbox.value() <= 2):
            if (not ((8 <= len(self.editPasswordAP.text()) <= 63) and self.is_ascii(str(self.editPasswordAP.text())))):
                return self.show_key_warning()
        if (self.WPAtype_spinbox.value() == 0):
            if ((not ((len(self.editPasswordAP.text()) == 5) or (len(self.editPasswordAP.text()) == 13))) and self.is_ascii(str(self.editPasswordAP.text())) and (not (((len(self.editPasswordAP.text()) == 10) or (len(self.editPasswordAP.text()) == 24)) and self.is_hexadecimal(str(self.editPasswordAP.text()))))):
                return self.show_key_warning()
    print '\n[*]    Loading    debugging    mode'
    self.currentSessionID = self.sessionGenerate()
    self.SessionsAP.update({self.currentSessionID: {'started': None, 'stoped': None}})
    self.SessionsAP[self.currentSessionID]['started'] = asctime()
    print '[*]    Current    Session::ID    [{}]'.format(self.currentSessionID)
    if hasattr(self, 'dockAreaList'):
        for dock in self.dockAreaList.keys():
            self.dockAreaList[dock].clear()
            self.dockAreaList[dock].stopProcess()
    self.PumpkinProxyTAB.tableLogging.clearContents()
    self.ImageCapTAB.TableImage.clear()
    self.ImageCapTAB.TableImage.setRowCount(0)
    print '[*]    Configuring    hostapd...'
    self.SettingsEnable['AP_iface'] = str(self.selectCard.currentText())
    set_monitor_mode(self.SettingsEnable['AP_iface']).setDisable()
    if ((self.interfacesLink['activated'][1] == 'ethernet') or (self.interfacesLink['activated'][1] == 'ppp') or (self.interfacesLink['activated'][0] == None)):
        Refactor.kill_procInterfaceBusy()
        try:
            check_output(['nmcli', 'radio', 'wifi', 'off'])
        except Exception:
            try:
                check_output(['nmcli', 'nm', 'wifi', 'off'])
            except Exception as error:
                return QMessageBox.warning(self, 'Error    nmcli', str(error))
        finally:
            call(['rfkill', 'unblock', 'wifi'])
    leases = '/var/lib/dhcp/dhcpd.leases'
    if (not path.exists(leases[:(-12)])):
        mkdir(leases[:(-12)])
    if (not path.isfile(leases)):
        with open(leases, 'wb') as leaconf:
            leaconf.close()
    uid = getpwnam('root').pw_uid
    gid = getgrnam('root').gr_gid
    chown(leases, uid, gid)
    self.CoreSettings()
    self.checkWirelessSecurity()
    ignore = ('interface=', 'ssid=', 'channel=')
    with open('core/config/hostapd/hostapd.conf', 'w') as apconf:
        for i in self.SettingsAP['hostapd']:
            apconf.write(i)
        for config in str(self.FSettings.ListHostapd.toPlainText()).split('\n'):
            if ((not config.startswith('#')) and (len(config) > 0)):
                if (not config.startswith(ignore)):
                    apconf.write((config + '\n'))
        apconf.close()
    self.Thread_hostapd = ProcessHostapd({self.hostapd_path: [(getcwd() + '/core/config/hostapd/hostapd.conf')]}, self.currentSessionID)
    self.Thread_hostapd.setObjectName('hostapd')
    self.Thread_hostapd.statusAP_connected.connect(self.GetHostapdStatus)
    self.Thread_hostapd.statusAPError.connect(self.GetErrorhostapdServices)
    self.Apthreads['RougeAP'].append(self.Thread_hostapd)
    self.btn_start_attack.setDisabled(True)
    self.EditApName.setEnabled(False)
    self.selectCard.setEnabled(False)
    self.EditChannel.setEnabled(False)
    self.GroupApPassphrase.setEnabled(False)
    self.PumpSettingsTAB.GroupDHCP.setEnabled(False)
    self.PopUpPlugins.tableplugins.setEnabled(False)
    self.PopUpPlugins.tableplugincheckbox.setEnabled(False)
    self.btn_cancelar.setEnabled(True)
    print '[*]    Configuring    dhcpd...'
    if self.FSettings.Settings.get_setting('accesspoint', 'dhcpd_server', format=bool):
        self.Thread_dhcp = ThRunDhcp(['dhcpd', '-d', '-f', '-lf', '/var/lib/dhcp/dhcpd.leases', '-cf', '/etc/dhcp/dhcpd_wp.conf', self.SettingsEnable['AP_iface']], self.currentSessionID)
        self.Thread_dhcp.sendRequest.connect(self.GetDHCPRequests)
        self.Thread_dhcp.setObjectName('DHCP')
        self.Apthreads['RougeAP'].append(self.Thread_dhcp)
        self.PopUpPlugins.checkGeneralOptions()
    elif self.FSettings.Settings.get_setting('accesspoint', 'pydhcp_server', format=bool):
        if self.FSettings.Settings.get_setting('accesspoint', 'pydns_server', format=bool):
            self.ThreadDNSServer = DNSServer(self.SettingsEnable['AP_iface'], self.DHCP['router'])
            self.ThreadDNSServer.setObjectName('DNSServer')
        elif self.FSettings.Settings.get_setting('accesspoint', 'dnsproxy_server', format=bool):
            self.ThreadDNSServer = ProcessThread({'python': ['plugins/external/dns2proxy/dns2proxy.py', '-i', str(self.selectCard.currentText()), '-k', self.currentSessionID]})
            self.ThreadDNSServer._ProcssOutput.connect(self.get_dns2proxy_output)
            self.ThreadDNSServer.setObjectName('DNSServer')
        if (not self.PopUpPlugins.check_dns2proy.isChecked()):
            self.Apthreads['RougeAP'].append(self.ThreadDNSServer)
        self.ThreadDHCPserver = DHCPServer(self.SettingsEnable['AP_iface'], self.DHCP)
        self.ThreadDHCPserver.sendConnetedClient.connect(self.GetDHCPDiscoverInfo)
        self.ThreadDHCPserver.setObjectName('DHCPServer')
        self.Apthreads['RougeAP'].append(self.ThreadDHCPserver)
    self.Started(True)
    self.ProxyPluginsTAB.GroupSettings.setEnabled(False)
    self.FSettings.Settings.set_setting('accesspoint', 'statusAP', True)
    self.FSettings.Settings.set_setting('accesspoint', 'interfaceAP', str(self.selectCard.currentText()))
    if (self.PopUpPlugins.check_dns2proy.isChecked() or self.PopUpPlugins.check_sergioProxy.isChecked()):
        self.plugin_classes = Plugin.PluginProxy.__subclasses__()
        self.plugins = {}
        for p in self.plugin_classes:
            self.plugins[p._name] = p()
        if (not self.THReactor.isRunning()):
            self.THReactor.start()
    setup_logger('pumpkinproxy', 'logs/AccessPoint/pumpkin-proxy.log', self.currentSessionID)
    setup_logger('urls_capture', 'logs/AccessPoint/urls.log', self.currentSessionID)
    setup_logger('creds_capture', 'logs/AccessPoint/credentials.log', self.currentSessionID)
    setup_logger('tcp_proxy', 'logs/AccessPoint/tcp-proxy.log', self.currentSessionID)
    self.LogPumpkinproxy = getLogger('pumpkinproxy')
    self.LogUrlMonitor = getLogger('urls_capture')
    self.LogCredsMonitor = getLogger('creds_capture')
    self.LogTcpproxy = getLogger('tcp_proxy')
    if self.PopUpPlugins.check_responder.isChecked():
        setup_logger('responder', 'logs/AccessPoint/responder.log', self.currentSessionID)
        self.responderlog = getLogger('responder')
        self.Thread_responder = ProcessThread({'python': ['plugins/external/Responder/Responder.py', '-I', str(self.selectCard.currentText()), '-wrFbv']})
        self.Thread_responder._ProcssOutput.connect(self.get_responder_output)
        self.Thread_responder.setObjectName('Responder')
        self.Apthreads['RougeAP'].append(self.Thread_responder)
    if self.PopUpPlugins.check_dns2proy.isChecked():
        self.Thread_dns2proxy = ProcessThread({'python': ['plugins/external/dns2proxy/dns2proxy.py', '-i', str(self.selectCard.currentText()), '-k', self.currentSessionID]})
        self.Thread_dns2proxy._ProcssOutput.connect(self.get_dns2proxy_output)
        self.Thread_dns2proxy.setObjectName('Dns2Proxy')
        self.Apthreads['RougeAP'].append(self.Thread_dns2proxy)
        self.Threadsslstrip = Thread_sslstrip(self.SettingsEnable['PortRedirect'], self.plugins, self.ProxyPluginsTAB._PluginsToLoader, self.currentSessionID)
        self.Threadsslstrip.setObjectName('sslstrip2')
        self.Apthreads['RougeAP'].append(self.Threadsslstrip)
    elif self.PopUpPlugins.check_sergioProxy.isChecked():
        self.Threadsslstrip = Thread_sergioProxy(self.SettingsEnable['PortRedirect'], self.plugins, self.ProxyPluginsTAB._PluginsToLoader, self.currentSessionID)
        self.Threadsslstrip.setObjectName('sslstrip')
        self.Apthreads['RougeAP'].append(self.Threadsslstrip)
    elif self.PopUpPlugins.check_bdfproxy.isChecked():
        self.Thread_bdfproxy = ProcessThread({'python': ['plugins/external/BDFProxy-ng/bdf_proxy.py', '-k', self.currentSessionID]})
        self.Thread_bdfproxy._ProcssOutput.connect(self.get_bdfproxy_output)
        self.Thread_bdfproxy.setObjectName('BDFProxy-ng')
        self.Apthreads['RougeAP'].append(self.Thread_bdfproxy)
    elif self.PopUpPlugins.check_pumpkinProxy.isChecked():
        self.Thread_PumpkinProxy = ThreadPumpkinProxy(self.currentSessionID)
        self.Thread_PumpkinProxy.send.connect(self.get_PumpkinProxy_output)
        self.Thread_PumpkinProxy.setObjectName('Pumpkin-Proxy')
        self.Apthreads['RougeAP'].append(self.Thread_PumpkinProxy)
    if self.PopUpPlugins.check_tcpproxy.isChecked():
        self.Thread_TCPproxy = ThreadSniffingPackets(str(self.selectCard.currentText()), self.currentSessionID)
        self.Thread_TCPproxy.setObjectName('TCPProxy')
        self.Thread_TCPproxy.output_plugins.connect(self.get_TCPproxy_output)
        self.Apthreads['RougeAP'].append(self.Thread_TCPproxy)
    if self.InternetShareWiFi:
        print '[*]    Sharing    Internet    Connections    with    NAT...'
    iptables = []
    for index in xrange(self.FSettings.ListRules.count()):
        iptables.append(str(self.FSettings.ListRules.item(index).text()))
    for rulesetfilter in iptables:
        if self.InternetShareWiFi:
            if ('$inet' in rulesetfilter):
                rulesetfilter = rulesetfilter.replace('$inet', str(self.interfacesLink['activated'][0]))
            if ('$wlan' in rulesetfilter):
                rulesetfilter = rulesetfilter.replace('$wlan', self.SettingsEnable['AP_iface'])
        if (('$inet' in rulesetfilter) or ('$wlan' in rulesetfilter)):
            continue
        popen(rulesetfilter)
    for thread in self.Apthreads['RougeAP']:
        self.progress.update_bar_simple(20)
        QThread.sleep(1)
        thread.start()
    self.progress.setValue(100)
    self.progress.hideProcessbar()
    if self.FSettings.Settings.get_setting('dockarea', 'advanced', format=bool):
        self.PumpSettingsTAB.doCheckAdvanced()
    print '-------------------------------'
    print 'AP::[{}]    Running...'.format(self.EditApName.text())
    print 'AP::BSSID::[{}]    CH    {}'.format(Refactor.get_interface_mac(self.selectCard.currentText()), self.EditChannel.value())
    self.FSettings.Settings.set_setting('accesspoint', 'ssid', str(self.EditApName.text()))
    self.FSettings.Settings.set_setting('accesspoint', 'channel', str(self.EditChannel.value()))
