def downloadCaptiveportals(self): ''' check interfaces on background ''' try: data_file = urlopen(C.EXTRACAPTIVETHEMES) with open(C.CAPTIVETHEMESZIP, 'wb') as output: output.write(data_file.read()) except Exception as e: self.btn_updateCaptive.setEnabled(True) self.btn_updateCaptive.setText('Update') return QtGui.QMessageBox.information(self, 'Error: Download data ', str(e)) zip_ref = ZipFile(C.CAPTIVETHEMESZIP, 'r') zip_ref.extractall(C.TEMPPATH) zip_ref.close() source_path_templates = C.CAPTIVEPATH_TMP_TEMPLATES source_path_plugins = C.CAPTIVEPATH_TMP_PLUGINS config_captive = SettingsINI(C.PATHCAPTIVEFINI) for plugin in config_captive.get_all_childname('plugins'): if (not plugin in self.config.get_all_childname('plugins')): system('cp -r {src} {dst}'.format( src=source_path_templates + plugin, dst=C.CAPTIVE_PATH_TEMPLATES)) self.config.set_setting('plugins', plugin, False) for subplugin in config_captive.get_all_childname( 'set_{}'.format(plugin)): if subplugin != 'Default': self.config.set_setting('set_{}'.format(plugin), subplugin, False) else: self.config.set_setting('set_{}'.format(plugin), subplugin, True) system('cp {src} {dst}'.format(src='{}{}.py'.format( source_path_plugins, plugin), dst=C.CAPTIVE_PATH_PLUGINS)) self.btn_updateCaptive.setEnabled(True) self.btn_updateCaptive.setText('Update') QtGui.QMessageBox.information( self, 'Update Captive-Portals', "Already up-to-date. Please restart WiFi-Pumpkin to apply this update." )
class PumpkinMitmproxy(QVBoxLayout): ''' settings Transparent Proxy ''' sendError = pyqtSignal(str) def __init__(self,main_method,parent = None): super(PumpkinMitmproxy, self).__init__(parent) self.mainLayout = QVBoxLayout() self.config = SettingsINI(C.PUMPPROXY_INI) self.plugins = [] self.main_method = main_method self.bt_SettingsDict = {} self.check_PluginDict = {} self.search_all_ProxyPlugins() #scroll area self.scrollwidget = QWidget() self.scrollwidget.setLayout(self.mainLayout) self.scroll = QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setWidget(self.scrollwidget) # create for add dock logging self.tabcontrol = QTabWidget() self.tab1 = QWidget() self.tab2 = QWidget() self.page_1 = QVBoxLayout(self.tab1) self.page_2 = QVBoxLayout(self.tab2) self.tableLogging = dockPumpkinProxy() self.tabcontrol.addTab(self.tab1, 'Plugins') self.tabcontrol.addTab(self.tab2, 'Logging') self.TabPlugins = QTableWidget() self.TabPlugins.setColumnCount(3) self.TabPlugins.setRowCount(len(self.plugins)) self.TabPlugins.resizeRowsToContents() self.TabPlugins.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.TabPlugins.horizontalHeader().setStretchLastSection(True) self.TabPlugins.setSelectionBehavior(QAbstractItemView.SelectRows) self.TabPlugins.setEditTriggers(QAbstractItemView.NoEditTriggers) self.TabPlugins.verticalHeader().setVisible(False) self.TabPlugins.verticalHeader().setDefaultSectionSize(27) self.TabPlugins.setSortingEnabled(True) self.THeaders = OrderedDict([ ('Plugins',[]),('Settings',[]),('Description',[])]) self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys()) self.TabPlugins.horizontalHeader().resizeSection(0,158) self.TabPlugins.horizontalHeader().resizeSection(1,80) # add on tab self.page_1.addWidget(self.TabPlugins) self.page_2.addWidget(self.tableLogging) # get all plugins and add into TabWidget Headers = [] for plugin in self.plugins: if plugin.ConfigParser: self.bt_SettingsDict[plugin.Name] = QPushButton('Settings') self.bt_SettingsDict[plugin.Name].clicked.connect(partial(self.setSettingsPlgins,plugin.Name)) else: self.bt_SettingsDict[plugin.Name] = QPushButton('None') self.check_PluginDict[plugin.Name] = QCheckBox(plugin.Name) self.check_PluginDict[plugin.Name].setObjectName(plugin.Name) self.check_PluginDict[plugin.Name].clicked.connect(partial(self.setPluginOption,plugin.Name)) self.THeaders['Plugins'].append(self.check_PluginDict[plugin.Name]) self.THeaders['Settings'].append({'name': plugin.Name}) self.THeaders['Description'].append(plugin.Description) for n, key in enumerate(self.THeaders.keys()): Headers.append(key) for m, item in enumerate(self.THeaders[key]): if type(item) == type(QCheckBox()): self.TabPlugins.setCellWidget(m,n,item) elif type(item) == type(dict()): self.TabPlugins.setCellWidget(m,n,self.bt_SettingsDict[item['name']]) else: item = QTableWidgetItem(item) self.TabPlugins.setItem(m, n, item) self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys()) # check status all checkbox plugins for box in self.check_PluginDict.keys(): self.check_PluginDict[box].setChecked(self.config.get_setting('plugins',box,format=bool)) self.mainLayout.addWidget(self.tabcontrol) self.layout = QHBoxLayout() self.layout.addWidget(self.scroll) self.addLayout(self.layout) def setPluginOption(self, name,status): ''' get each plugins status''' # enable realtime disable and enable plugin if self.main_method.PopUpPlugins.check_pumpkinProxy.isChecked() and \ self.main_method.FSettings.Settings.get_setting('accesspoint','statusAP',format=bool): self.main_method.Thread_PumpkinProxy.m.disablePlugin(name, status) self.config.set_setting('plugins',name,status) def setSettingsPlgins(self,plugin): ''' open settings options for each plugins''' key = 'set_{}'.format(plugin) self.widget = PumpkinProxySettings(key,self.config.get_all_childname(key)) self.widget.show() def search_all_ProxyPlugins(self): ''' load all plugins function ''' plugin_classes = plugin.PluginTemplate.__subclasses__() for p in plugin_classes: self.plugins.append(p())
class PumpkinMitmproxy(ProxyMode): ''' settings Transparent Proxy ''' Name = "Pumpkin Proxy" Author = "Pumpkin-Dev" Description = "Intercepting HTTP data, this proxy server that allows to intercept requests and response on the fly" Icon = "icons/pumpkinproxy.png" ModSettings = True Hidden = False ModType = "proxy" # proxy or server _cmd_array = [] sendError = QtCore.pyqtSignal(str) def __init__(self, parent, **kwargs): super(PumpkinMitmproxy, self).__init__(parent) self.mainLayout = QtGui.QVBoxLayout() self.config = SettingsINI(C.PUMPPROXY_INI) self.plugins = [] self.main_method = parent self.bt_SettingsDict = {} self.check_PluginDict = {} self.search_all_ProxyPlugins() #scroll area self.scrollwidget = QtGui.QWidget() self.scrollwidget.setLayout(self.mainLayout) self.scroll = QtGui.QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setWidget(self.scrollwidget) self.dockwidget = PumpkinProxyDock(None, title=self.Name) self.search[self.Name] = str( 'iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080' ) # create for add dock logging self.tabcontrol = QtGui.QTabWidget() self.tab1 = QtGui.QWidget() self.tab2 = QtGui.QWidget() self.page_1 = QtGui.QVBoxLayout(self.tab1) self.page_2 = QtGui.QVBoxLayout(self.tab2) self.tableLogging = dockPumpkinProxy() self.tabcontrol.addTab(self.tab1, 'Plugins') #self.tabcontrol.addTab(self.tab2, 'Logging') self.TabPlugins = QtGui.QTableWidget() self.TabPlugins.setColumnCount(3) self.TabPlugins.setRowCount(len(self.plugins)) self.TabPlugins.resizeRowsToContents() self.TabPlugins.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) self.TabPlugins.horizontalHeader().setStretchLastSection(True) self.TabPlugins.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.TabPlugins.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.TabPlugins.verticalHeader().setVisible(False) self.TabPlugins.verticalHeader().setDefaultSectionSize(27) self.TabPlugins.setSortingEnabled(True) self.THeaders = OrderedDict([('Plugins', []), ('Settings', []), ('Description', [])]) self.TabPlugins.setHorizontalHeaderLabels(list(self.THeaders.keys())) self.TabPlugins.horizontalHeader().resizeSection(0, 158) self.TabPlugins.horizontalHeader().resizeSection(1, 80) # add on tab self.page_1.addWidget(self.TabPlugins) self.page_2.addWidget(self.tableLogging) # get all plugins and add into TabWidget Headers = [] for plugin in self.plugins: if plugin.ConfigParser: self.bt_SettingsDict[plugin.Name] = QtGui.QPushButton( 'Settings') self.bt_SettingsDict[plugin.Name].clicked.connect( partial(self.setSettingsPlgins, plugin.Name)) else: self.bt_SettingsDict[plugin.Name] = QtGui.QPushButton('None') self.check_PluginDict[plugin.Name] = QtGui.QCheckBox(plugin.Name) self.check_PluginDict[plugin.Name].setObjectName(plugin.Name) self.check_PluginDict[plugin.Name].clicked.connect( partial(self.setPluginOption, plugin.Name)) self.THeaders['Plugins'].append(self.check_PluginDict[plugin.Name]) self.THeaders['Settings'].append({'name': plugin.Name}) self.THeaders['Description'].append(plugin.Description) for n, key in enumerate(self.THeaders.keys()): Headers.append(key) for m, item in enumerate(self.THeaders[key]): if type(item) == type(QtGui.QCheckBox()): self.TabPlugins.setCellWidget(m, n, item) elif type(item) == type(dict()): self.TabPlugins.setCellWidget( m, n, self.bt_SettingsDict[item['name']]) else: item = QtGui.QTableWidgetItem(item) self.TabPlugins.setItem(m, n, item) self.TabPlugins.setHorizontalHeaderLabels(list(self.THeaders.keys())) # check status all checkbox plugins for box in self.check_PluginDict.keys(): self.check_PluginDict[box].setChecked( self.config.get_setting('plugins', box, format=bool)) self.mainLayout.addWidget(self.tabcontrol) self.layout = QtGui.QHBoxLayout() self.layout.addWidget(self.scroll) self.setLayout(self.layout) def setPluginOption(self, name, status): ''' get each plugins status''' # enable realtime disable and enable plugin if self.FSettings.Settings.get_setting('accesspoint', 'statusAP', format=bool): self.reactor.ThreadPumpkinProxy.m.disablePlugin(name, status) self.config.set_setting('plugins', name, status) def setSettingsPlgins(self, plugin): ''' open settings options for each plugins''' key = 'set_{}'.format(plugin) self.widget = PumpkinProxySettings(key, self.config.get_all_childname(key)) self.widget.show() def search_all_ProxyPlugins(self): ''' load all plugins function ''' try: plugin_classes = plugin.PluginTemplate.__subclasses__() for p in plugin_classes: self.plugins.append(p()) except NameError: infoLabel = ServiceNotify(C.PUMPKINPROXY_notify, title='Package Requirement') self.mainLayout.addWidget(infoLabel) def boot(self): self.reactor = ThreadPumpkinProxy(self.parent.currentSessionID) self.reactor.send.connect(self.LogOutput) self.reactor.setObjectName(self.Name) self.SetRules("PumpkinProxy") def LogOutput(self, data): if self.FSettings.Settings.get_setting('accesspoint', 'statusAP', format=bool): self.dockwidget.writeModeData(data) self.logger.info(data) def Serve(self, on=True): if on: self.tableLogging.clearContents() plugin_classes = plugin.PluginTemplate.__subclasses__() for p in plugin_classes: self.plugins.append(p()) # pumpkinproxy not use reactor twistted #self.server.start() def onProxyEnabled(self): self.SetRules(self.Name)
class frm_Settings(QDialog): def __init__(self, parent=None): super(frm_Settings, self).__init__(parent) self.setWindowTitle('WiFi-Pompkin - Settings') self.Settings = SettingsINI(C.CONFIG_INI) self.loadtheme(self.get_theme_qss()) self.setGeometry(0, 0, 420, 440) self.center() self.Qui() def loadtheme(self, theme): ''' load theme widgets ''' sshFile = ("core/%s.qss" % (theme)) with open(sshFile, "r") as fh: self.setStyleSheet(fh.read()) def get_theme_qss(self): ''' get theme selected path''' return self.Settings.get_setting('settings', 'themes') def center(self): ''' set center widgets ''' frameGm = self.frameGeometry() centerPoint = QDesktopWidget().availableGeometry().center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) def save_settings(self): self.Settings.set_setting('settings', 'scapy_deauth', self.pageTab1.d_scapy.isChecked()) self.Settings.set_setting('settings', 'mdk3_deauth', self.pageTab1.d_mdk.isChecked()) self.Settings.set_setting('settings', 'scan_scapy', self.pageTab1.scan_scapy.isChecked()) self.Settings.set_setting('settings', 'scan_airodump', self.pageTab1.scan_airodump.isChecked()) self.Settings.set_setting('accesspoint', 'dhcpd_server', self.pageTab1.dhcpdserver.isChecked()) self.Settings.set_setting('accesspoint', 'pydhcp_server', self.pageTab1.pydhcpserver.isChecked()) self.Settings.set_setting('accesspoint', 'pydns_server', self.pageTab1.ch_pyDNS_server.isChecked()) self.Settings.set_setting('accesspoint', 'dnsproxy_server', self.pageTab1.ch_DNSproxy_server.isChecked()) if self.pageTab1.theme1.isChecked(): self.Settings.set_setting('settings', 'themes', str(self.pageTab1.theme1.objectName())) elif self.pageTab1.theme2.isChecked(): self.Settings.set_setting('settings', 'themes', str(self.pageTab1.theme2.objectName())) elif self.pageTab1.theme3.isChecked(): self.Settings.set_setting('settings', 'themes', str(self.pageTab1.theme3.objectName())) if self.pageTab1.AP_0.isChecked(): self.Settings.set_setting('accesspoint', 'hostapd_custom', False) elif self.pageTab1.AP_1.isChecked(): self.Settings.set_setting('accesspoint', 'hostapd_custom', True) self.Settings.set_setting('settings', 'mdk3', str(self.txt_arguments.text())) self.Settings.set_setting('settings', 'scanner_rangeIP', str(self.txt_ranger.text())) self.Settings.set_setting('accesspoint', 'ssid', str(self.pageTab1.Apname.text())) self.Settings.set_setting('accesspoint', 'channel', str(self.pageTab1.channel.value())) self.Settings.set_setting('accesspoint', 'persistNetwokManager', self.pageTab1.network_manager.isChecked()) self.Settings.set_setting( 'accesspoint', 'checkConnectionWifi', self.pageTab1.checkConnectionWifi.isChecked()) self.Settings.set_setting('accesspoint', 'check_support_ap_mode', self.check_interface_mode_AP.isChecked()) self.Settings.set_setting('settings', 'redirect_port', str(self.redirectport.text())) if not path.isfile(self.pageTab1.edit_hostapd_path.text()): return QMessageBox.warning(self, 'Path Hostapd Error', 'hostapd binary path is not found') self.Settings.set_setting('accesspoint', 'hostapd_path', self.pageTab1.edit_hostapd_path.text()) with open(C.HOSTAPDCONF_PATH2, 'w') as apconf: apconf.write(self.ListHostapd.toPlainText()) self.close() def listItemclicked(self, pos): ''' add,remove and edit rules iptables from WIFi-Pumpkin''' item = self.ListRules.selectedItems() self.listMenu = QMenu() menu = QMenu() additem = menu.addAction('Add') editem = menu.addAction('Edit') removeitem = menu.addAction('Remove ') clearitem = menu.addAction('clear') action = menu.exec_(self.ListRules.viewport().mapToGlobal(pos)) if action == removeitem: if item != []: self.ListRules.takeItem(self.ListRules.currentRow()) elif action == additem: text, resp = QInputDialog.getText(self, 'Add rules iptables', 'Enter the rules iptables:') if resp: try: itemsexits = [] for index in xrange(self.ListRules.count()): itemsexits.append( str(self.ListRules.item(index).text())) for i in itemsexits: if search(str(text), i): return QMessageBox.information( self, 'Rules exist', 'this rules already exist!') item = QListWidgetItem() item.setText(text) item.setSizeHint(QSize(30, 30)) self.ListRules.addItem(item) except Exception as e: return QMessageBox.information(self, 'error', str(e)) elif action == editem: text, resp = QInputDialog.getText( self, 'Add rules for iptables', 'Enter the rules iptables:', text=self.ListRules.item(self.ListRules.currentRow()).text()) if resp: try: itemsexits = [] for index in xrange(self.ListRules.count()): itemsexits.append( str(self.ListRules.item(index).text())) for i in itemsexits: if search(str(text), i): return QMessageBox.information( self, 'Rules exist', 'this rules already exist!') item = QListWidgetItem() item.setText(text) item.setSizeHint(QSize(30, 30)) self.ListRules.insertItem(self.ListRules.currentRow(), item) except Exception as e: return QMessageBox.information(self, 'error', str(e)) elif action == clearitem: self.ListRules.clear() def Qui(self): self.Main = QVBoxLayout() self.formGroupAd = QFormLayout() self.form = QFormLayout() self.tabcontrol = QTabWidget() # tabs self.tab1 = QWidget() self.tab2 = QWidget() self.tab3 = QWidget() self.tab4 = QWidget() self.page_1 = QVBoxLayout(self.tab1) self.page_2 = QFormLayout(self.tab2) self.page_3 = QFormLayout(self.tab3) self.page_4 = QFormLayout(self.tab4) self.tabcontrol.addTab(self.tab1, 'General') self.tabcontrol.addTab(self.tab2, 'Advanced') self.tabcontrol.addTab(self.tab3, 'Iptables') self.tabcontrol.addTab(self.tab4, 'Hostpad') self.pageTab1 = SettingsTabGeneral(self.Settings) self.page_1.addLayout(self.pageTab1) self.groupAdvanced = QGroupBox() self.groupAdvanced.setTitle('Advanced Settings:') self.groupAdvanced.setLayout(self.formGroupAd) self.btn_save = QPushButton('Save') self.btn_save.clicked.connect(self.save_settings) self.btn_save.setFixedWidth(80) self.btn_save.setIcon(QIcon('icons/Save.png')) #page Adavanced self.txt_ranger = QLineEdit(self) self.txt_arguments = QLineEdit(self) self.scan1 = QRadioButton('Ping Scan:: Very fast IP scan') self.scan2 = QRadioButton('Python-Nmap:: Get hostname from IP') self.redirectport = QLineEdit(self) self.check_interface_mode_AP = QCheckBox( 'Check if interface supports AP/Mode') self.check_interface_mode_AP.setChecked( self.Settings.get_setting('accesspoint', 'check_support_ap_mode', format=bool)) self.check_interface_mode_AP.setToolTip( 'if you disable this options in next time, the interface is not should ' 'checked if has support AP mode.') # page Iptables self.ListRules = QListWidget(self) self.ListRules.setFixedHeight(300) self.ListRules.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.ListRules.setContextMenuPolicy(Qt.CustomContextMenu) self.ListRules.connect(self.ListRules, SIGNAL('customContextMenuRequested(QPoint)'), self.listItemclicked) for ech in self.Settings.get_all_childname('iptables'): item = QListWidgetItem() item.setText( str(self.Settings.get_setting('iptables', ech, format=str))) item.setSizeHint(QSize(30, 30)) self.ListRules.addItem(item) # page hostpad self.ListHostapd = QTextEdit(self) self.ListHostapd.setFixedHeight(300) with open(C.HOSTAPDCONF_PATH2, 'r') as apconf: self.ListHostapd.setText(apconf.read()) # grup page 2 self.gruButtonPag2 = QButtonGroup() self.gruButtonPag2.addButton(self.scan1) self.gruButtonPag2.addButton(self.scan2) self.txt_ranger.setText( self.Settings.get_setting('settings', 'scanner_rangeIP')) self.txt_arguments.setText( self.Settings.get_setting('settings', 'mdk3')) self.scan2.setEnabled(False) self.scan1.setChecked(True) #settings tab Advanced self.redirectport.setText( self.Settings.get_setting('settings', 'redirect_port')) #add tab Advanced self.formGroupAd.addRow(QLabel('Thread Scan IP-Address:')) self.formGroupAd.addRow(self.scan1) self.formGroupAd.addRow(self.scan2) self.formGroupAd.addRow(self.check_interface_mode_AP) self.formGroupAd.addRow('Port sslstrip:', self.redirectport) self.formGroupAd.addRow(QLabel('mdk3 Args:'), self.txt_arguments) self.formGroupAd.addRow(QLabel('Range Scanner:'), self.txt_ranger) self.page_2.addRow(self.groupAdvanced) #add tab iptables self.page_3.addWidget(QLabel('Iptables:')) self.page_3.addRow(self.ListRules) #add tab hostpad self.page_4.addWidget(QLabel('settings hostapd:')) self.page_4.addRow(self.ListHostapd) self.form.addRow(self.tabcontrol) self.form.addRow(self.btn_save) self.Main.addLayout(self.form) self.setLayout(self.Main)
class frm_Settings(QDialog): def __init__(self, parent = None): super(frm_Settings, self).__init__(parent) self.setWindowTitle('settings WiFi-Pompkin') self.Settings = SettingsINI('core/config/app/config.ini') self.bdfproxyConf = SettingsINI(self.Settings.get_setting('plugins','bdfproxy_config')) self.loadtheme(self.XmlThemeSelected()) self.setGeometry(0, 0, 420, 440) self.center() self.Qui() def loadtheme(self,theme): ''' load theme widgets ''' sshFile=("core/%s.qss"%(theme)) with open(sshFile,"r") as fh: self.setStyleSheet(fh.read()) def XmlThemeSelected(self): ''' get theme selected path''' return self.Settings.get_setting('settings','themes') def center(self): ''' set center widgets ''' frameGm = self.frameGeometry() centerPoint = QDesktopWidget().availableGeometry().center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) def save_settings(self): self.Settings.set_setting('settings','scapy_deauth',self.pageTab1.d_scapy.isChecked()) self.Settings.set_setting('settings','mdk3_deauth',self.pageTab1.d_mdk.isChecked()) self.Settings.set_setting('settings','scan_scapy',self.pageTab1.scan_scapy.isChecked()) self.Settings.set_setting('settings','scan_airodump',self.pageTab1.scan_airodump.isChecked()) self.Settings.set_setting('accesspoint','dhcpd_server',self.pageTab1.dhcpdserver.isChecked()) self.Settings.set_setting('accesspoint','pydhcp_server',self.pageTab1.pydhcpserver.isChecked()) if self.pageTab1.theme1.isChecked(): self.Settings.set_setting('settings','themes',str(self.pageTab1.theme1.objectName())) elif self.pageTab1.theme2.isChecked(): self.Settings.set_setting('settings','themes',str(self.pageTab1.theme2.objectName())) elif self.pageTab1.theme3.isChecked(): self.Settings.set_setting('settings','themes',str(self.pageTab1.theme3.objectName())) if self.pageTab1.AP_0.isChecked(): self.Settings.set_setting('accesspoint','hostapd_custom',False) elif self.pageTab1.AP_1.isChecked(): self.Settings.set_setting('accesspoint','hostapd_custom',True) self.Settings.set_setting('settings','mdk3',str(self.txt_arguments.text())) self.Settings.set_setting('settings','scanner_rangeIP',str(self.txt_ranger.text())) self.Settings.set_setting('accesspoint','ssid', str(self.pageTab1.Apname.text())) self.Settings.set_setting('accesspoint','channel', str(self.pageTab1.channel.value())) self.Settings.set_setting('accesspoint','persistNetwokManager',self.pageTab1.network_manager.isChecked()) self.Settings.set_setting('accesspoint','check_support_ap_mode',self.check_interface_mode_AP.isChecked()) self.Settings.set_setting('settings','redirect_port', str(self.redirectport.text())) if not path.isfile(self.pageTab1.edit_hostapd_path.text()): return QMessageBox.warning(self,'Path Hostapd Error','hostapd binary path is not found') self.Settings.set_setting('accesspoint','hostapd_path',self.pageTab1.edit_hostapd_path.text()) with open('core/config/hostapd/hostapd+.conf','w') as apconf: apconf.write(self.ListHostapd.toPlainText()) self.close() def listItemclicked(self,pos): ''' add,remove and edit rules iptables from WIFi-Pumpkin''' item = self.ListRules.selectedItems() self.listMenu= QMenu() menu = QMenu() additem = menu.addAction('Add') editem = menu.addAction('Edit') removeitem = menu.addAction('Remove ') clearitem = menu.addAction('clear') action = menu.exec_(self.ListRules.viewport().mapToGlobal(pos)) if action == removeitem: if item != []: self.ListRules.takeItem(self.ListRules.currentRow()) elif action == additem: text, resp = QInputDialog.getText(self, 'Add rules iptables', 'Enter the rules iptables:') if resp: try: itemsexits = [] for index in xrange(self.ListRules.count()): itemsexits.append(str(self.ListRules.item(index).text())) for i in itemsexits: if search(str(text),i): return QMessageBox.information(self,'Rules exist','this rules already exist!') item = QListWidgetItem() item.setText(text) item.setSizeHint(QSize(30,30)) self.ListRules.addItem(item) except Exception as e: return QMessageBox.information(self,'error',str(e)) elif action == editem: text, resp = QInputDialog.getText(self, 'Add rules iptables', 'Enter the rules iptables:',text=self.ListRules.item(self.ListRules.currentRow()).text()) if resp: try: itemsexits = [] for index in xrange(self.ListRules.count()): itemsexits.append(str(self.ListRules.item(index).text())) for i in itemsexits: if search(str(text),i): return QMessageBox.information(self,'Rules exist','this rules already exist!') item = QListWidgetItem() item.setText(text) item.setSizeHint(QSize(30,30)) self.ListRules.insertItem(self.ListRules.currentRow(),item) except Exception as e: return QMessageBox.information(self,'error',str(e)) elif action == clearitem: self.ListRules.clear() def Qui(self): self.Main = QVBoxLayout() self.formGroupAd = QFormLayout() self.form = QFormLayout() self.tabcontrol = QTabWidget() # tabs self.tab1 = QWidget() self.tab2 = QWidget() self.tab3 = QWidget() self.tab4 = QWidget() self.page_1 = QVBoxLayout(self.tab1) self.page_2 = QFormLayout(self.tab2) self.page_3 = QFormLayout(self.tab3) self.page_4 = QFormLayout(self.tab4) self.tabcontrol.addTab(self.tab1, 'General') self.tabcontrol.addTab(self.tab2, 'Advanced') self.tabcontrol.addTab(self.tab3,'Iptables') self.tabcontrol.addTab(self.tab4,'hostpad') self.pageTab1 = SettingsTabGeneral(self.Settings) self.page_1.addLayout(self.pageTab1) self.groupAdvanced = QGroupBox() self.groupAdvanced.setTitle('Advanced settings:') self.groupAdvanced.setLayout(self.formGroupAd) self.btn_save = QPushButton('Save') self.btn_save.clicked.connect(self.save_settings) self.btn_save.setFixedWidth(80) self.btn_save.setIcon(QIcon('icons/Save.png')) #page Adavanced self.bdfProxy_port = QSpinBox() self.bdfProxy_port.setMaximum(10000) self.txt_ranger = QLineEdit(self) self.txt_arguments = QLineEdit(self) self.scan1 = QRadioButton('Ping Scan:: Very fast scan IP') self.scan2 = QRadioButton('Python-Nmap:: Get hostname from IP') self.redirectport = QLineEdit(self) self.check_interface_mode_AP = QCheckBox('Check if interface has been support AP/Mode') self.check_interface_mode_AP.setChecked(self.Settings.get_setting('accesspoint','check_support_ap_mode',format=bool)) self.check_interface_mode_AP.setToolTip('if you disable this options in next time, the interface is not should ' 'checked if has support AP mode.') # page Iptables self.ListRules = QListWidget(self) self.ListRules.setFixedHeight(300) self.ListRules.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.ListRules.setContextMenuPolicy(Qt.CustomContextMenu) self.ListRules.connect(self.ListRules, SIGNAL('customContextMenuRequested(QPoint)'), self.listItemclicked) for ech in self.Settings.get_all_childname('iptables'): item = QListWidgetItem() item.setText(str(self.Settings.get_setting('iptables',ech,format=str))) item.setSizeHint(QSize(30,30)) self.ListRules.addItem(item) # page hostpad self.ListHostapd = QTextEdit(self) self.ListHostapd.setFixedHeight(300) with open('core/config/hostapd/hostapd+.conf','r') as apconf: self.ListHostapd.setText(apconf.read()) # grup page 2 self.gruButtonPag2 = QButtonGroup() self.gruButtonPag2.addButton(self.scan1) self.gruButtonPag2.addButton(self.scan2) self.txt_ranger.setText(self.Settings.get_setting('settings','scanner_rangeIP')) self.txt_arguments.setText(self.Settings.get_setting('settings','mdk3')) self.bdfProxy_port.setValue(int(self.bdfproxyConf.get_setting('Overall','proxyPort'))) self.bdfProxy_port.setEnabled(False) self.scan2.setEnabled(False) self.scan1.setChecked(True) #settings tab Advanced self.redirectport.setText(self.Settings.get_setting('settings','redirect_port')) #add tab Advanced self.formGroupAd.addRow(QLabel('Thread Scan IP-Address:')) self.formGroupAd.addRow(self.scan1) self.formGroupAd.addRow(self.scan2) self.formGroupAd.addRow(self.check_interface_mode_AP) self.formGroupAd.addRow('Port BDFProxy-ng',self.bdfProxy_port) self.formGroupAd.addRow('Port sslstrip:',self.redirectport) self.formGroupAd.addRow(QLabel('mdk3 Args:'),self.txt_arguments) self.formGroupAd.addRow(QLabel('Range Scanner:'),self.txt_ranger) self.page_2.addRow(self.groupAdvanced) #add tab iptables self.page_3.addWidget(QLabel('Iptables:')) self.page_3.addRow(self.ListRules) #add tab hostpad self.page_4.addWidget(QLabel('settings hostapd:')) self.page_4.addRow(self.ListHostapd) self.form.addRow(self.tabcontrol) self.form.addRow(self.btn_save) self.Main.addLayout(self.form) self.setLayout(self.Main)
class CaptivePortal(ProxyMode): ''' settings Captive Portal Proxy ''' Name = "Captive Portal" Author = "Pumpkin-Dev" Description = "Captive-Portal allow the Attacker block Internet access for users until they open the page login page where a password is required before being allowed to browse the web." Icon = "icons/captive_portal.png" ModSettings = True Hidden = False ModType = "proxy" # proxy or server _cmd_array = [] sendError = QtCore.pyqtSignal(str) def __init__(self, parent, **kwargs): super(CaptivePortal, self).__init__(parent) self.mainLayout = QtGui.QVBoxLayout() self.config = SettingsINI(C.CAPTIVEPORTAL_INI) self.plugins = [] self.plugin_activated = None self.main_method = parent self.bt_SettingsDict = {} self.check_PluginDict = {} self.ClientsLogged = {} self.btn_previewSettings = {} self.search_all_ProxyPlugins() #scroll area self.scrollwidget = QtGui.QWidget() self.scrollwidget.setLayout(self.mainLayout) self.scroll = QtGui.QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setWidget(self.scrollwidget) self.dockwidget = CaptivePortalDock(None, title=self.Name) # create for add dock logging self.tabcontrol = QtGui.QTabWidget() self.tab1 = QtGui.QWidget() self.tab2 = QtGui.QWidget() self.page_1 = QtGui.QVBoxLayout(self.tab1) self.page_2 = QtGui.QVBoxLayout(self.tab2) self.tabcontrol.addTab(self.tab1, 'Plugins') self.tabcontrol.addTab(self.tab2, 'Manager') self.TabCtrlClients = QtGui.QTableWidget() self.TabCtrlClients.setColumnCount(3) #self.TabCtrlClients.setRowCount(len(self.plugins)) self.TabCtrlClients.resizeRowsToContents() self.TabCtrlClients.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) self.TabCtrlClients.horizontalHeader().setStretchLastSection(True) self.TabCtrlClients.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.TabCtrlClients.setEditTriggers( QtGui.QAbstractItemView.NoEditTriggers) self.TabCtrlClients.verticalHeader().setVisible(False) self.TabCtrlClients.verticalHeader().setDefaultSectionSize(27) self.TabCtrlClients.setSortingEnabled(True) self.THeadersCtrlClients = OrderedDict([('IpAddress', []), ('MacAddress', []), ('Status Internet', [])]) self.TabCtrlClients.setHorizontalHeaderLabels( self.THeadersCtrlClients.keys()) self.mainLayout_settings = QtGui.QVBoxLayout() #scroll area self.scrollwidget_settings = QtGui.QWidget() self.scrollwidget_settings.setLayout(self.mainLayout_settings) self.scroll_settings = QtGui.QScrollArea() self.scroll_settings.setWidgetResizable(True) self.scroll_settings.setWidget(self.scrollwidget_settings) # create widgets self.argsLabel = QtGui.QLabel('') self.hBox = QtGui.QHBoxLayout() self.btnEnable = QtGui.QPushButton('Allow') self.btncancel = QtGui.QPushButton('Deny') # size buttons self.btnEnable.setFixedWidth(100) self.btncancel.setFixedWidth(100) self.comboxBoxIPAddress = QtGui.QComboBox() self.btncancel.setIcon(QtGui.QIcon('icons/cancel.png')) self.btnEnable.setIcon(QtGui.QIcon('icons/accept.png')) # group settings self.GroupSettings = QtGui.QGroupBox() self.GroupSettings.setTitle('Manage clients access:') self.SettingsLayout = QtGui.QFormLayout() self.hBox.addWidget(self.comboxBoxIPAddress) self.hBox.addWidget(self.btnEnable) self.hBox.addWidget(self.btncancel) self.SettingsLayout.addRow(self.hBox) self.GroupSettings.setLayout(self.SettingsLayout) #self.GroupSettings.setFixedWidth(450) #group logger self.GroupLogger = QtGui.QGroupBox() self.logger_portal = QtGui.QListWidget() self.GroupLogger.setTitle('Logger events:') self.LoggerLayout = QtGui.QVBoxLayout() self.LoggerLayout.addWidget(self.logger_portal) self.GroupLogger.setLayout(self.LoggerLayout) #self.GroupLogger.setFixedWidth(450) #connections # self.btnLoader.clicked.connect(self.SearchProxyPlugins) self.connect(self.comboxBoxIPAddress, QtCore.SIGNAL('currentIndexChanged(QString)'), self.checkStatusClient) self.btnEnable.clicked.connect(self.enableInternetConnection) self.btncancel.clicked.connect(self.disableInternetConnection) # self.btnbrownser.clicked.connect(self.get_filenameToInjection) # add widgets self.mainLayout_settings.addWidget(self.GroupSettings) self.mainLayout_settings.addWidget(self.GroupLogger) self.TabPlugins = QtGui.QTableWidget() self.TabPlugins.setColumnCount(5) self.TabPlugins.setRowCount(len(self.plugins)) self.TabPlugins.resizeRowsToContents() self.TabPlugins.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) self.TabPlugins.horizontalHeader().setStretchLastSection(True) self.TabPlugins.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.TabPlugins.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.TabPlugins.verticalHeader().setVisible(False) self.TabPlugins.verticalHeader().setDefaultSectionSize(27) self.TabPlugins.setSortingEnabled(True) self.THeaders = OrderedDict([('Captive Name', []), ('Preview', []), ('Author', []), ('Settings', []), ('Description', [])]) self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys()) self.TabPlugins.horizontalHeader().resizeSection(0, 158) self.TabPlugins.horizontalHeader().resizeSection(1, 80) # add on tab self.page_1.addWidget(self.TabPlugins) self.page_2.addWidget(self.scroll_settings) # get all plugins and add into TabWidget Headers = [] for plugin in self.plugins: if plugin.ConfigParser: self.bt_SettingsDict[plugin.Name] = QtGui.QPushButton( 'Settings') self.bt_SettingsDict[plugin.Name].clicked.connect( partial(self.setSettingsPlgins, plugin.Name)) else: self.bt_SettingsDict[plugin.Name] = QtGui.QPushButton('None') if (path.isfile(plugin.Preview)): self.btn_previewSettings[plugin.Name] = QtGui.QPushButton( 'Preview') self.btn_previewSettings[plugin.Name].setObjectName( plugin.Preview) self.btn_previewSettings[plugin.Name].clicked.connect( partial(self.showPreviewCaptivePortal, plugin.Name)) else: self.btn_previewSettings[plugin.Name] = QtGui.QPushButton( 'Not found') self.check_PluginDict[plugin.Name] = QtGui.QRadioButton( plugin.Name) self.check_PluginDict[plugin.Name].setObjectName(plugin.Name) self.check_PluginDict[plugin.Name].clicked.connect( partial(self.setPluginOption, plugin.Name)) self.THeaders['Captive Name'].append( self.check_PluginDict[plugin.Name]) self.THeaders['Preview'].append( self.btn_previewSettings[plugin.Name]) self.THeaders['Author'].append(plugin.Author) self.THeaders['Settings'].append({'name': plugin.Name}) self.THeaders['Description'].append(plugin.Description) for n, key in enumerate(self.THeaders.keys()): Headers.append(key) for m, item in enumerate(self.THeaders[key]): if type(item) == type(QtGui.QRadioButton()): self.TabPlugins.setCellWidget(m, n, item) elif type(item) == type(dict()): self.TabPlugins.setCellWidget( m, n, self.bt_SettingsDict[item['name']]) elif type(item) == type(QtGui.QPushButton()): self.TabPlugins.setCellWidget(m, n, item) else: item = QtGui.QTableWidgetItem(item) self.TabPlugins.setItem(m, n, item) self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys()) # check status all checkbox plugins for box in self.check_PluginDict.keys(): self.check_PluginDict[box].setChecked( self.config.get_setting('plugins', box, format=bool)) self.btn_updateCaptive = QtGui.QPushButton("Update") self.btn_updateCaptive.setIcon(QtGui.QIcon('icons/updates_.png')) self.btn_updateCaptive.setFixedWidth(130) self.btn_updateCaptive.clicked.connect(self.disableBtnForUpdates) self.mainLayout.addWidget(self.tabcontrol) self.mainLayout.addWidget(self.btn_updateCaptive) self.layout = QtGui.QHBoxLayout() self.layout.addWidget(self.scroll) self.setLayout(self.layout) def disableBtnForUpdates(self): ''' update captive portals from github ''' self.btn_updateCaptive.setEnabled(False) self.btn_updateCaptive.setText('Downloading...') QtCore.QTimer.singleShot(3000, lambda: self.downloadCaptiveportals()) def downloadCaptiveportals(self): ''' check interfaces on background ''' try: data_file = urlopen(C.EXTRACAPTIVETHEMES) with open(C.CAPTIVETHEMESZIP, 'wb') as output: output.write(data_file.read()) except Exception as e: self.btn_updateCaptive.setEnabled(True) self.btn_updateCaptive.setText('Update') return QtGui.QMessageBox.information(self, 'Error: Download data ', str(e)) zip_ref = ZipFile(C.CAPTIVETHEMESZIP, 'r') zip_ref.extractall(C.TEMPPATH) zip_ref.close() source_path_templates = C.CAPTIVEPATH_TMP_TEMPLATES source_path_plugins = C.CAPTIVEPATH_TMP_PLUGINS config_captive = SettingsINI(C.PATHCAPTIVEFINI) for plugin in config_captive.get_all_childname('plugins'): if (not plugin in self.config.get_all_childname('plugins')): system('cp -r {src} {dst}'.format( src=source_path_templates + plugin, dst=C.CAPTIVE_PATH_TEMPLATES)) self.config.set_setting('plugins', plugin, False) for subplugin in config_captive.get_all_childname( 'set_{}'.format(plugin)): if subplugin != 'Default': self.config.set_setting('set_{}'.format(plugin), subplugin, False) else: self.config.set_setting('set_{}'.format(plugin), subplugin, True) system('cp {src} {dst}'.format(src='{}{}.py'.format( source_path_plugins, plugin), dst=C.CAPTIVE_PATH_PLUGINS)) self.btn_updateCaptive.setEnabled(True) self.btn_updateCaptive.setText('Update') QtGui.QMessageBox.information( self, 'Update Captive-Portals', "Already up-to-date. Please restart WiFi-Pumpkin to apply this update." ) def enableInternetConnection(self): ipaddress = str(self.comboxBoxIPAddress.currentText()) exec_bash('iptables -D FORWARD -s {ip} -j REJECT'.format(ip=ipaddress)) exec_bash('iptables -I FORWARD -s {ip} -j ACCEPT'.format(ip=ipaddress)) self.btnEnable.setEnabled(False) self.btncancel.setEnabled(True) self.ClientsLogged[ipaddress]['Status'] = True self.logger_portal.addItem( 'Allow access the internet to {}'.format(ipaddress)) def disableInternetConnection(self): ipaddress = str(self.comboxBoxIPAddress.currentText()) exec_bash('iptables -D FORWARD -s {ip} -j ACCEPT'.format(ip=ipaddress)) exec_bash('iptables -I FORWARD -s {ip} -j REJECT'.format(ip=ipaddress)) self.btnEnable.setEnabled(True) self.btncancel.setEnabled(False) self.ClientsLogged[ipaddress]['Status'] = False self.logger_portal.addItem( 'Deny access the internet to {}'.format(ipaddress)) def checkStatusClient(self): if (str(self.comboxBoxIPAddress.currentText()) != ''): if (self.ClientsLogged[str( self.comboxBoxIPAddress.currentText())]['Status']): self.btnEnable.setEnabled(False) self.btncancel.setEnabled(True) return None self.btnEnable.setEnabled(True) self.btncancel.setEnabled(False) def showPreviewCaptivePortal(self, plugin, status): self.preview_form = CaptivePortalPreviewImage( plugin, self.btn_previewSettings[plugin].objectName()) self.preview_form.show() def search_all_ProxyPlugins(self): ''' load all plugins function ''' plugin_classes = plugin.CaptiveTemplatePlugin.__subclasses__() for p in plugin_classes: self.plugins.append(p()) def setSettingsPlgins(self, plugin): ''' open settings options for each plugins''' key = 'set_{}'.format(plugin) self.widget = CaptivePortalSettings(key, self.config.get_all_childname(key)) self.widget.show() def getPluginActivated(self): for plugin in self.plugins: if (self.config.get_setting('plugins', plugin.Name, format=bool)): self.plugin_activated = plugin self.plugin_activated.initialize() # change language if exist return self.plugin_activated def shutdown(self): self.logger_portal.clear() self.comboxBoxIPAddress.clear() self.ClearRules() self.ClientsLogged = {} def boot(self): # self.reactor = ThreadCaptivePortalHTTPServer('0.0.0.0',80,plugin_activated,self.parent.currentSessionID) # self.reactor.requestCredentails.connect(self.LogOutput) # self.reactor.requestLogin.connect(self.allowAccessLogin) # self.reactor.setObjectName(self.Name) self.reactor = ProcessThread( { 'python': [ "server.py", '-t', self.getPluginActivated().TemplatePath, '-r', self.parent.SessionConfig.DHCP.conf['router'], '-s', self.getPluginActivated().StaticPath ] }, "plugins/captivePortal/") self.reactor._ProcssOutput.connect(self.LogOutput) self.reactor.setObjectName(self.Name) # settings iptables for add support captive portal IFACE = self.parent.SessionConfig.Wireless.WLANCard.currentText() IP_ADDRESS = self.parent.SessionConfig.DHCP.conf['router'] PORT = 80 print('[*] Settings for captive portal:') print(" -> Allow FORWARD UDP DNS") self.search[self.Name + "_forward"] = str( 'iptables -A FORWARD -i {iface} -p tcp --dport 53 -j ACCEPT'. format(iface=IFACE)) print(" -> Allow traffic to captive portal") self.search[self.Name + "_allow"] = str( 'iptables -A FORWARD -i {iface} -p tcp --dport {port} -d {ip} -j ACCEPT' .format(iface=IFACE, port=PORT, ip=IP_ADDRESS)) print(" -> Block all other traffic in access point") self.search[self.Name + "_block"] = str( 'iptables -A FORWARD -i {iface} -j DROP '.format(iface=IFACE)) print(" -> Redirecting HTTP traffic to captive portal") self.search[self.Name + "redirect"] = str( 'iptables -t nat -A PREROUTING -i {iface} -p tcp --dport 80 -j DNAT --to-destination {ip}:{port}' .format(iface=IFACE, ip=IP_ADDRESS, port=PORT)) self.SetRules(self.Name + "_forward") self.SetRules(self.Name + "_allow") self.SetRules(self.Name + "_block") self.SetRules(self.Name + "redirect") # print('[*] Settings for captive portal:') # print(" -> Allow FORWARD UDP DNS") # call(["iptables", "-A", "FORWARD", "-i", IFACE, "-p", "udp", "--dport", "53", "-j" ,"ACCEPT"]) # print(" -> Allow traffic to captive portal") # call(["iptables", "-A", "FORWARD", "-i", IFACE, "-p", "tcp", "--dport", str(PORT),"-d", IP_ADDRESS, "-j" ,"ACCEPT"]) # print(" -> Block all other traffic in access point") # call(["iptables", "-A", "FORWARD", "-i", IFACE, "-j" ,"DROP"]) # print(" -> Redirecting HTTP traffic to captive portal") # call(["iptables", "-t", "nat", "-A", "PREROUTING", "-i", IFACE, "-p", "tcp", "--dport", "80", "-j" ,"DNAT", "--to-destination", "{}:{}".format(IP_ADDRESS, PORT)]) def addClientCtrlManager(self, IPADDRESS): ''' get data output and add on QtableWidgets''' #for name in self.pluginsName: clientsTabHome = self.parent.Home.DHCP.ClientTable.APclients self.ClientsLogged[IPADDRESS] = {'MAC': 'unknow', 'Status': True} for mac_address in clientsTabHome.keys(): if (clientsTabHome[mac_address]['IP'] == IPADDRESS): self.ClientsLogged[IPADDRESS]['MAC'] = clientsTabHome[ mac_address]['MAC'] self.comboxBoxIPAddress.addItems([IPADDRESS]) self.logger_portal.addItem( 'Authorized user: [ IP: {} MAC: {} ]'.format( IPADDRESS, self.ClientsLogged[IPADDRESS]['MAC'])) def LogOutput(self, data): if self.FSettings.Settings.get_setting('accesspoint', 'statusAP', format=bool): self.dockwidget.writeModeData(data, self.plugin_activated.Name) self.logger.info(data) try: dict_data = literal_eval(data) self.addClientCtrlManager(dict_data.keys()[0]) except Exception: pass def setPluginOption(self, name, status): ''' get each plugins status''' self.config.set_setting('plugins', name, status) for plugin in self.plugins: if (plugin.Name != name): self.config.set_setting('plugins', plugin.Name, False) def Serve(self, on=True): pass def onProxyEnabled(self): self.SetRules(self.Name)
class frm_Settings(QDialog): def __init__(self, parent = None): super(frm_Settings, self).__init__(parent) self.setWindowTitle('settings WiFi-Pompkin') self.Settings = SettingsINI('core/config/app/config.ini') self.bdfproxyConf = SettingsINI(self.Settings.get_setting('plugins','bdfproxy_patch_config')) self.loadtheme(self.XmlThemeSelected()) self.setGeometry(0, 0, 420, 440) self.center() self.Qui() def loadtheme(self,theme): sshFile=("core/%s.qss"%(theme)) with open(sshFile,"r") as fh: self.setStyleSheet(fh.read()) def XmlThemeSelected(self): return self.Settings.get_setting('settings','themes') def center(self): frameGm = self.frameGeometry() centerPoint = QDesktopWidget().availableGeometry().center() frameGm.moveCenter(centerPoint) self.move(frameGm.topLeft()) def save_settings(self): if self.pageTab1.d_scapy.isChecked(): self.Settings.set_setting('settings','deauth','packets_scapy') elif self.pageTab1.d_mdk.isChecked(): self.Settings.set_setting('settings','deauth','packets_mdk3') if self.pageTab1.scan_scapy.isChecked(): self.Settings.set_setting('settings','scanner_AP','scan_scapy') elif self.pageTab1.scan_airodump.isChecked(): self.Settings.set_setting('settings','scanner_AP','scan_airodump') if self.pageTab1.dhcp1.isChecked(): self.Settings.set_setting('accesspoint','dhcp_server','iscdhcpserver') if self.pageTab1.theme1.isChecked(): self.Settings.set_setting('settings','themes',str(self.pageTab1.theme1.objectName())) elif self.pageTab1.theme2.isChecked(): self.Settings.set_setting('settings','themes',str(self.pageTab1.theme2.objectName())) elif self.pageTab1.theme3.isChecked(): self.Settings.set_setting('settings','themes',str(self.pageTab1.theme3.objectName())) if self.scan1.isChecked(): self.Settings.set_setting('settings','Function_scan','Ping') elif self.scan2.isChecked(): self.Settings.set_setting('settings','Function_scan','Nmap') self.Settings.set_setting('settings','mdk3',str(self.txt_arguments.text())) self.Settings.set_setting('settings','scanner_rangeIP',str(self.txt_ranger.text())) self.Settings.set_setting('accesspoint','APname', str(self.pageTab1.Apname.text())) self.Settings.set_setting('accesspoint','channel', str(self.pageTab1.channel.value())) self.Settings.set_setting('accesspoint','persistNetwokManager',self.pageTab1.network_manager.isChecked()) self.Settings.set_setting('settings','redirect_port', str(self.redirectport.text())) with open('core/config/hostapd/hostapd+.conf','w') as apconf: apconf.write(self.ListHostapd.toPlainText()) self.close() def listItemclicked(self,pos): item = self.ListRules.selectedItems() self.listMenu= QMenu() menu = QMenu() additem = menu.addAction('Add') editem = menu.addAction('Edit') removeitem = menu.addAction('Remove ') clearitem = menu.addAction('clear') action = menu.exec_(self.ListRules.viewport().mapToGlobal(pos)) if action == removeitem: if item != []: self.ListRules.takeItem(self.ListRules.currentRow()) elif action == additem: text, resp = QInputDialog.getText(self, 'Add rules iptables', 'Enter the rules iptables:') if resp: try: itemsexits = [] for index in xrange(self.ListRules.count()): itemsexits.append(str(self.ListRules.item(index).text())) for i in itemsexits: if search(str(text),i): QMessageBox.information(self,'Rules exist','this rules already exist!') return item = QListWidgetItem() item.setText(text) item.setSizeHint(QSize(30,30)) self.ListRules.addItem(item) except Exception as e: QMessageBox.information(self,'error',str(e)) return elif action == editem: text, resp = QInputDialog.getText(self, 'Add rules iptables', 'Enter the rules iptables:',text=self.ListRules.item(self.ListRules.currentRow()).text()) if resp: try: itemsexits = [] for index in xrange(self.ListRules.count()): itemsexits.append(str(self.ListRules.item(index).text())) for i in itemsexits: if search(str(text),i): QMessageBox.information(self,'Rules exist','this rules already exist!') return item = QListWidgetItem() item.setText(text) item.setSizeHint(QSize(30,30)) self.ListRules.insertItem(self.ListRules.currentRow(),item) except Exception as e: QMessageBox.information(self,'error',str(e)) return elif action == clearitem: self.ListRules.clear() def redirectAP(self): item = QListWidgetItem() if self.check_redirect.isChecked(): item.setText('iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 10.0.0.1:80') item.setSizeHint(QSize(30,30)) self.ListRules.addItem(item) return rules = [] for index in xrange(self.ListRules.count()): rules.append(str(self.ListRules.item(index).text())) for i,j in enumerate(rules): if search('--to-destination 10.0.0.1:80',j): self.ListRules.takeItem(i) def Qui(self): self.Main = QVBoxLayout() self.formGroupAd = QFormLayout() self.form = QFormLayout() self.tabcontrol = QTabWidget() # tabs self.tab1 = QWidget() self.tab2 = QWidget() self.tab3 = QWidget() self.tab4 = QWidget() self.page_1 = QVBoxLayout(self.tab1) self.page_2 = QFormLayout(self.tab2) self.page_3 = QFormLayout(self.tab3) self.page_4 = QFormLayout(self.tab4) self.tabcontrol.addTab(self.tab1, 'General') self.tabcontrol.addTab(self.tab2, 'Advanced') self.tabcontrol.addTab(self.tab3,'Iptables') self.tabcontrol.addTab(self.tab4,'hostpad') self.pageTab1 = SettingsTabGeneral(self.Settings) self.page_1.addLayout(self.pageTab1) self.groupAdvanced = QGroupBox() self.groupAdvanced.setTitle('Advanced settings:') self.groupAdvanced.setLayout(self.formGroupAd) self.btn_save = QPushButton('Save') self.btn_save.clicked.connect(self.save_settings) self.btn_save.setFixedWidth(80) self.btn_save.setIcon(QIcon('icons/Save.png')) #page Adavanced self.bdfProxy_port = QSpinBox() self.bdfProxy_port.setMaximum(10000) self.txt_ranger = QLineEdit(self) self.txt_arguments = QLineEdit(self) self.scan1 = QRadioButton('Ping Scan:: Very fast scan IP') self.scan2 = QRadioButton('Python-Nmap:: Get hostname from IP') self.redirectport = QLineEdit(self) # page Iptables self.ListRules = QListWidget(self) self.ListRules.setFixedHeight(300) self.ListRules.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.ListRules.setContextMenuPolicy(Qt.CustomContextMenu) self.ListRules.connect(self.ListRules, SIGNAL('customContextMenuRequested(QPoint)'), self.listItemclicked) for ech in self.Settings.get_all_childname('iptables'): item = QListWidgetItem() item.setText(str(self.Settings.get_setting('iptables',ech,format=str))) item.setSizeHint(QSize(30,30)) self.ListRules.addItem(item) # page hostpad self.ListHostapd = QTextEdit(self) self.ListHostapd.setFixedHeight(300) with open('core/config/hostapd/hostapd+.conf','r') as apconf: self.ListHostapd.setText(apconf.read()) # grup page 2 self.gruButtonPag2 = QButtonGroup() self.gruButtonPag2.addButton(self.scan1) self.gruButtonPag2.addButton(self.scan2) self.txt_ranger.setText(self.Settings.get_setting('settings','scanner_rangeIP')) self.txt_arguments.setText(self.Settings.get_setting('settings','mdk3')) self.scanIP_selected = self.Settings.get_setting('settings','Function_scan') self.bdfProxy_port.setValue(int(self.bdfproxyConf.get_setting('Overall','proxyPort'))) self.bdfProxy_port.setEnabled(False) if self.scanIP_selected == 'Ping': self.scan1.setChecked(True) self.scan2.setEnabled(False) #settings tab Advanced self.redirectport.setText(self.Settings.get_setting('settings','redirect_port')) #add tab Advanced self.formGroupAd.addRow(QLabel('Thread Scan IP-Address:')) self.formGroupAd.addRow(self.scan1) self.formGroupAd.addRow(self.scan2) self.formGroupAd.addRow('Port BDFProxy-ng',self.bdfProxy_port) self.formGroupAd.addRow('Port sslstrip:',self.redirectport) self.formGroupAd.addRow(QLabel('mdk3 Args:'),self.txt_arguments) self.formGroupAd.addRow(QLabel('Range Scanner:'),self.txt_ranger) self.page_2.addRow(self.groupAdvanced) #add tab iptables self.page_3.addWidget(QLabel('Iptables:')) self.page_3.addRow(self.ListRules) #add tab hostpad self.page_4.addWidget(QLabel('settings hostapd:')) self.page_4.addRow(self.ListHostapd) self.form.addRow(self.tabcontrol) self.form.addRow(self.btn_save) self.Main.addLayout(self.form) self.setLayout(self.Main)
class PumpkinMitmproxy(QVBoxLayout): ''' settings Transparent Proxy ''' sendError = pyqtSignal(str) def __init__(self,main_method,parent = None): super(PumpkinMitmproxy, self).__init__(parent) self.mainLayout = QVBoxLayout() self.config = SettingsINI('core/config/app/proxy.ini') self.plugins = [] self.main_method = main_method self.bt_SettingsDict = {} self.check_PluginDict = {} self.search_all_ProxyPlugins() #scroll area self.scrollwidget = QWidget() self.scrollwidget.setLayout(self.mainLayout) self.scroll = QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setWidget(self.scrollwidget) self.TabPlugins = QTableWidget() self.TabPlugins.setColumnCount(3) self.TabPlugins.setRowCount(len(self.plugins)) self.TabPlugins.resizeRowsToContents() self.TabPlugins.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) self.TabPlugins.horizontalHeader().setStretchLastSection(True) self.TabPlugins.setSelectionBehavior(QAbstractItemView.SelectRows) self.TabPlugins.setEditTriggers(QAbstractItemView.NoEditTriggers) self.TabPlugins.verticalHeader().setVisible(False) self.TabPlugins.verticalHeader().setDefaultSectionSize(27) self.TabPlugins.setSortingEnabled(True) self.THeaders = OrderedDict([ ('Plugins',[]),('Settings',[]),('Description',[])]) self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys()) self.TabPlugins.horizontalHeader().resizeSection(0,158) self.TabPlugins.horizontalHeader().resizeSection(1,80) # get all plugins and add into TabWidget Headers = [] for plugin in self.plugins: if plugin.ConfigParser: self.bt_SettingsDict[plugin.Name] = QPushButton('Settings') self.bt_SettingsDict[plugin.Name].clicked.connect(partial(self.setSettingsPlgins,plugin.Name)) else: self.bt_SettingsDict[plugin.Name] = QPushButton('None') self.check_PluginDict[plugin.Name] = QCheckBox(plugin.Name) self.check_PluginDict[plugin.Name].setObjectName(plugin.Name) self.check_PluginDict[plugin.Name].clicked.connect(partial(self.setPluginOption,plugin.Name)) self.THeaders['Plugins'].append(self.check_PluginDict[plugin.Name]) self.THeaders['Settings'].append({'name': plugin.Name}) self.THeaders['Description'].append(plugin.Description) for n, key in enumerate(self.THeaders.keys()): Headers.append(key) for m, item in enumerate(self.THeaders[key]): if type(item) == type(QCheckBox()): self.TabPlugins.setCellWidget(m,n,item) elif type(item) == type(dict()): self.TabPlugins.setCellWidget(m,n,self.bt_SettingsDict[item['name']]) else: item = QTableWidgetItem(item) self.TabPlugins.setItem(m, n, item) self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys()) # check status all checkbox plugins for box in self.check_PluginDict.keys(): self.check_PluginDict[box].setChecked(self.config.get_setting('plugins',box,format=bool)) self.mainLayout.addWidget(self.TabPlugins) self.layout = QHBoxLayout() self.layout.addWidget(self.scroll) self.addLayout(self.layout) def setPluginOption(self, name,status): ''' get each plugins status''' # enable realtime disable and enable plugin if self.main_method.PopUpPlugins.check_pumpkinProxy.isChecked() and \ self.main_method.FSettings.Settings.get_setting('accesspoint','statusAP',format=bool): self.main_method.Thread_PumpkinProxy.m.disablePlugin(name, status) self.config.set_setting('plugins',name,status) def setSettingsPlgins(self,plugin): ''' open settings options for each plugins''' key = 'set_{}'.format(plugin) self.widget = PumpkinProxySettings(key,self.config.get_all_childname(key)) self.widget.show() def search_all_ProxyPlugins(self): ''' load all plugins function ''' plugin_classes = plugin.PluginTemplate.__subclasses__() for p in plugin_classes: self.plugins.append(p())