Exemplo n.º 1
0
class PopUpPlugins(QtGui.QVBoxLayout):
    ''' this module control all plugins to MITM attack'''
    sendSingal_disable = QtCore.pyqtSignal(object)

    def __init__(self, FSettings, main, parent=None):
        super(PopUpPlugins, self).__init__(parent)
        self.main_method = main
        self.FSettings = FSettings
        self.layout = QtGui.QVBoxLayout()
        self.layoutform = QtGui.QFormLayout()
        self.GroupPlugins = QtGui.QGroupBox()
        self.GroupPlugins.setTitle('Activity Monitor:')

        self.layoutproxy = QtGui.QVBoxLayout()
        self.GroupPluginsProxy = QtGui.QGroupBox()
        self.GroupPluginsProxy.setTitle('Enable proxy server:')
        self.GroupPluginsProxy.setCheckable(True)
        #self.GroupPluginsProxy.toggled.connect(self.get_disable_proxyserver)
        self.GroupPluginsProxy.setLayout(self.layoutproxy)
        self.GroupPlugins.setLayout(self.layoutform)
        self.proxyGroup = QtGui.QButtonGroup()

        self.check_netcreds = QtGui.QCheckBox('net-creds ')
        self.check_responder = QtGui.QCheckBox('Firelamb')
        self.check_tcpproxy = QtGui.QCheckBox('TCP-Proxy')
        self.check_pumpkinProxy = QtGui.QRadioButton('Pumpkin-Proxy')
        self.check_dns2proy = QtGui.QRadioButton('SSLstrip+|Dns2proxy')
        self.check_sergioProxy = QtGui.QRadioButton('SSLstrip|Sergio-proxy')
        self.check_bdfproxy = QtGui.QRadioButton('BDFProxy-ng')
        self.check_noproxy = QtGui.QRadioButton('No Proxy')

        self.btnBDFSettings = QtGui.QPushButton('Change')
        self.btnResponderSettings = QtGui.QPushButton('Change')
        self.btnBDFSettings.setIcon(QtGui.QIcon('icons/config.png'))
        self.btnResponderSettings.setIcon(QtGui.QIcon('icons/config.png'))

        self.proxyGroup.addButton(self.check_pumpkinProxy)
        self.proxyGroup.addButton(self.check_dns2proy)
        self.proxyGroup.addButton(self.check_sergioProxy)

        self.proxyGroup.addButton(self.check_bdfproxy)

        self.check_tcpproxy.clicked.connect(self.checkBoxTCPproxy)
        self.check_pumpkinProxy.clicked.connect(self.checkGeneralOptions)
        self.check_dns2proy.clicked.connect(self.checkGeneralOptions)
        self.check_sergioProxy.clicked.connect(self.checkGeneralOptions)
        self.check_bdfproxy.clicked.connect(self.checkGeneralOptions)
        self.check_noproxy.clicked.connect(self.checkGeneralOptions)

        # set text description plugins
        self.check_dns2proy.setObjectName(
            'This tools offer a different features '
            'for post-explotation once you change the DNS server to a Victim. coded by: LeonardoNve'
        )
        self.check_sergioProxy.setObjectName(
            'Sergio proxy is an HTTP proxy that was written '
            'in Python for the Twisted framework. coded by: LeonardoNve')
        self.check_bdfproxy.setObjectName(
            'Patch Binaries via MITM: BackdoorFactory + mitmProxy, '
            'bdfproxy-ng is a fork and review of the original BDFProxy. coded by: secretsquirrel.'
        )
        self.check_pumpkinProxy.setObjectName(
            'Transparent proxy - intercepting HTTP data, '
            'this proxy server that allows to intercept requests and response on the fly'
        )

        # desction plugin checkbox
        self.check_netcreds.setObjectName(
            'Sniff passwords and hashes from an interface or pcap file.'
            ' coded by: Dan McInerney')
        self.check_tcpproxy.setObjectName(
            'sniff for isntercept network traffic on UDP,TCP protocol.'
            ' get password,hash,image,etc...')
        self.check_responder.setObjectName(
            'Firelamb an LLMNR, NBT-NS and MDNS poisoner. '
            'By default, the tool will only answer to File Server Service request, which is for SMB.'
        )

        #self.layoutproxy.addWidget(self.tableplugins)
        #self.layoutproxy.addWidget(self.tableplugincheckbox)
        self.layout.addWidget(self.GroupPluginsProxy)
        self.layout.addWidget(self.GroupPlugins)
        self.addLayout(self.layout)

    def get_disable_proxyserver(self):
        ''' set disable or activate plugin proxy '''
        self.check_noproxy.setChecked(True)
        self.tableplugincheckbox.setEnabled(True)
        self.sendSingal_disable.emit(self.check_noproxy.isChecked())
        self.checkBoxTCPproxy()

    # control checkbox plugins
    def checkGeneralOptions(self):
        ''' settings plugins proxy options and rules iptables '''
        self.unset_Rules('dns2proxy')
        self.unset_Rules('sslstrip')
        self.unset_Rules('bdfproxy')
        self.FSettings.Settings.set_setting(
            'plugins', 'pumpkinproxy_plugin',
            self.check_pumpkinProxy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'sergioproxy_plugin',
                                            self.check_sergioProxy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'dns2proxy_plugin',
                                            self.check_dns2proy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'bdfproxy_plugin',
                                            self.check_bdfproxy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'noproxy',
                                            self.check_noproxy.isChecked())
        if self.check_sergioProxy.isChecked():
            self.main_method.set_proxy_statusbar('SSLstrip|Sergio-proxy')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(
                False)  # disable ProxyPumpkinTAB
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(
                True)  # enable SSLSTRIP Proxy TAB
            self.set_sslStripRule()
        elif self.check_dns2proy.isChecked():
            self.main_method.set_proxy_statusbar('SSLstrip+|Dns2-proxy')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(False)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(True)
            self.set_sslStripRule()
            self.set_Dns2proxyRule()
        elif self.check_bdfproxy.isChecked():
            self.main_method.set_proxy_statusbar('BDF-proxy-ng')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(False)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(False)
            self.unset_Rules('dns2proxy')
            self.unset_Rules('sslstrip')
            self.set_BDFproxyRule()
        elif self.check_pumpkinProxy.isChecked():
            self.main_method.set_proxy_statusbar('Pumpkin-Proxy')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(True)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(False)
            self.unset_Rules('dns2proxy')
            self.unset_Rules('sslstrip')
            self.set_PumpkinProxy()
        elif self.check_noproxy.isChecked():
            #self.main_method.set_proxy_statusbar('',disabled=True)
            #self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(False)
            #self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(False)
            self.unset_Rules('dns2proxy')
            self.unset_Rules('sslstrip')
            self.unset_Rules('bdfproxy')

    #TODO Routine relates with TCP Proxy
    def checkBoxTCPproxy(self):
        if self.check_tcpproxy.isChecked():
            self.FSettings.Settings.set_setting('plugins', 'tcpproxy_plugin',
                                                True)
            self.main_method.PacketSnifferTAB.tabcontrol.setEnabled(True)
            self.main_method.ImageCapTAB.TableImage.setEnabled(True)
        else:
            self.FSettings.Settings.set_setting('plugins', 'tcpproxy_plugin',
                                                False)
            self.main_method.PacketSnifferTAB.tabcontrol.setEnabled(False)
            self.main_method.ImageCapTAB.TableImage.setEnabled(False)

    def optionsRules(self, type):
        ''' add rules iptable by type plugins'''
        search = {
            'sslstrip':
            str('iptables -t nat -A PREROUTING -p tcp' +
                ' --destination-port 80 -j REDIRECT --to-port ' +
                self.FSettings.redirectport.text()),
            'dns2proxy':
            str('iptables -t nat -A PREROUTING -p udp --destination-port 53 -j REDIRECT --to-port 53'
                ),
            'bdfproxy':
            str('iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080'
                ),
            'PumpkinProxy':
            str('iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080'
                )
        }
        return search[type]

    # set rules to sslstrip
    def set_sslStripRule(self):
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        if self.optionsRules('sslstrip') in items:
            return
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('sslstrip'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    # set redirect port rules dns2proy
    def set_Dns2proxyRule(self):
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('dns2proxy'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    # set redirect port rules bdfproxy
    def set_BDFproxyRule(self):
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        if self.optionsRules('bdfproxy') in items:
            return
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('bdfproxy'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    def set_PumpkinProxy(self):
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        if self.optionsRules('PumpkinProxy') in items:
            return
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('PumpkinProxy'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    def unset_Rules(self, type):
        ''' remove rules from Listwidget in settings widget'''
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        for position, line in enumerate(items):
            if self.optionsRules(type) == line:
                self.FSettings.ListRules.takeItem(position)
Exemplo n.º 2
0
class PopUpPlugins(QtGui.QVBoxLayout):
    ''' this module control all plugins to MITM attack'''
    sendSingal_disable = QtCore.pyqtSignal(object)
    def __init__(self,FSettings,main,parent=None):
        super(PopUpPlugins, self).__init__(parent)
        self.main_method = main
        self.FSettings = FSettings
        self.layout = QtGui.QVBoxLayout()
        self.layoutform = QtGui.QFormLayout()
        self.layoutproxy = QtGui.QVBoxLayout()
        self.GroupPlugins = QtGui.QGroupBox()
        self.GroupPluginsProxy = QtGui.QGroupBox()
        self.GroupPlugins.setTitle('plugins:')
        self.GroupPluginsProxy.setLayout(self.layoutproxy)
        self.GroupPlugins.setLayout(self.layoutform)

        self.check_netcreds     = QtGui.QCheckBox('net-creds ')
        self.check_responder    = QtGui.QCheckBox('Responder')
        self.check_tcpproxy     = QtGui.QCheckBox('TCP-Proxy')
        self.check_noproxy      = QtGui.QRadioButton('No Proxy')
        self.check_mitmproxy    = QtGui.QRadioButton('MITM Proxy (HTTP)')
        self.check_mitmproxyssl   = QtGui.QRadioButton('MITM Proxy (HTTP/HTTPS) + SSL-Strip')

        self.btnResponderSettings = QtGui.QPushButton('Change')
        self.btnResponderSettings.setIcon(QtGui.QIcon('icons/config.png'))
        #self.btnResponderSettings.clicked.connect(self.ConfigOBJBResponder)

        # set text description plugins
        self.check_mitmproxy.setObjectName('MITM Proxy 4.0.4. Forward HTTP only')
        self.check_mitmproxyssl.setObjectName('MITM Proxy 4.0.4. Forward HTTP + HTTPS and run SSLStrip')
        self.check_noproxy.setObjectName('No HTTP / HTTPS proxying')

        # desction plugin checkbox
        self.check_netcreds.setObjectName('Sniff passwords and hashes from an interface or pcap file.'
        ' coded by: Dan McInerney')
        self.check_tcpproxy.setObjectName('sniff for isntercept network traffic on UDP,TCP protocol.'
        ' get password,hash,image,etc...')
        self.check_responder.setObjectName('Responder an LLMNR, NBT-NS and MDNS poisoner. '
        'By default, the tool will only answer to File Server Service request, which is for SMB.')


        # table 1 for add plugins with QradioBtton
        self.THeadersPluginsProxy  = OrderedDict(
        [   ('Plugins',[self.check_noproxy, self.check_mitmproxy, self.check_mitmproxyssl]),
            ('Settings',[QtGui.QPushButton('None'), QtGui.QPushButton('None'), QtGui.QPushButton('None')]),
            ('Description',[self.check_noproxy.objectName(), self.check_mitmproxy.objectName(), self.check_mitmproxyssl.objectName()])
        ])

        # table 2 for add plugins with checkbox
        self.THeadersPlugins  = OrderedDict(
        [   ('Plugins',[self.check_tcpproxy, self.check_responder]),
            ('Settings',[QtGui.QPushButton('None'), self.btnResponderSettings]),
            ('Description',[self.check_tcpproxy.objectName(), self.check_responder.objectName()])
        ])

        self.tableplugins = QtGui.QTableWidget()
        self.tableplugins.setColumnCount(3)
        self.tableplugins.setRowCount(len(self.THeadersPluginsProxy['Plugins']))
        self.tableplugins.resizeRowsToContents()
        self.tableplugins.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        self.tableplugins.horizontalHeader().setStretchLastSection(True)
        self.tableplugins.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.tableplugins.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.tableplugins.verticalHeader().setVisible(False)
        self.tableplugins.verticalHeader().setDefaultSectionSize(23)
        self.tableplugins.setSortingEnabled(True)
        self.tableplugins.setHorizontalHeaderLabels(list(sorted(dict(self.THeadersPluginsProxy).keys())))
        self.tableplugins.horizontalHeader().resizeSection(0, 400)
        self.tableplugins.horizontalHeader().resizeSection(1, 290)
        self.tableplugins.resizeRowsToContents()

        self.tableplugincheckbox = QtGui.QTableWidget()
        self.tableplugincheckbox.setColumnCount(3)
        self.tableplugincheckbox.setRowCount(len(self.THeadersPlugins['Plugins']))
        self.tableplugincheckbox.resizeRowsToContents()
        self.tableplugincheckbox.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        self.tableplugincheckbox.horizontalHeader().setStretchLastSection(True)
        self.tableplugincheckbox.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
        self.tableplugincheckbox.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.tableplugincheckbox.verticalHeader().setVisible(False)
        self.tableplugincheckbox.verticalHeader().setDefaultSectionSize(23)
        self.tableplugincheckbox.setSortingEnabled(True)
        self.tableplugincheckbox.setHorizontalHeaderLabels(list(sorted(dict(self.THeadersPlugins).keys())))
        self.tableplugincheckbox.horizontalHeader().resizeSection(0, 400)
        self.tableplugincheckbox.horizontalHeader().resizeSection(1, 290)
        self.tableplugincheckbox.resizeRowsToContents()

        # add all widgets in Qtable 1 plgins
        Headers = []
        for n, key in enumerate(list(sorted(dict(self.THeadersPluginsProxy).keys()))):
            Headers.append(key)
            for m, item in enumerate(self.THeadersPluginsProxy[key]):
                if type(item) == type(QtGui.QRadioButton()) or type(item) == type(QtGui.QPushButton()):
                    self.tableplugins.setCellWidget(m,n,item)
                else:
                    item = QtGui.QTableWidgetItem(item)
                    self.tableplugins.setItem(m, n, item)
        self.tableplugins.setHorizontalHeaderLabels(list(sorted(dict(self.THeadersPluginsProxy).keys())))

        # add all widgets in Qtable 2 plugin
        Headers = []
        for n, key in enumerate(list(sorted(dict(self.THeadersPlugins).keys()))):
            Headers.append(key)
            for m, item in enumerate(self.THeadersPlugins[key]):
                if type(item) == type(QtGui.QCheckBox()) or type(item) == type(QtGui.QPushButton()):
                    self.tableplugincheckbox.setCellWidget(m,n,item)
                else:
                    item = QtGui.QTableWidgetItem(item)
                    self.tableplugincheckbox.setItem(m, n, item)
        self.tableplugins.setHorizontalHeaderLabels(list(sorted(dict(self.THeadersPlugins).keys())))

        self.proxyGroup = QtGui.QButtonGroup()
        self.proxyGroup.addButton(self.check_mitmproxy)
        self.proxyGroup.addButton(self.check_mitmproxyssl)
        self.proxyGroup.addButton(self.check_noproxy)

        self.check_tcpproxy.clicked.connect(self.checkBoxTCPproxy)
        self.check_mitmproxy.clicked.connect(self.checkGeneralOptions)
        self.check_mitmproxyssl.clicked.connect(self.checkGeneralOptions)
        self.check_noproxy.clicked.connect(self.checkGeneralOptions)
        self.check_responder.clicked.connect(self.checkBoxResponder)

        self.layoutproxy.addWidget(self.tableplugins)
        self.layoutproxy.addWidget(self.tableplugincheckbox)
        self.layout.addWidget(self.GroupPluginsProxy)
        self.addLayout(self.layout)

    def get_disable_proxyserver(self):
        ''' set disable or activate plugin proxy '''
        self.check_noproxy.setChecked(True)
        self.tableplugincheckbox.setEnabled(True)
        self.sendSingal_disable.emit(self.check_noproxy.isChecked())
        self.checkBoxTCPproxy()

    # control checkbox plugins
    def checkGeneralOptions(self):
        ''' settings plugins proxy options and rules iptables '''
        self.unsetRules('mitmproxy')
        self.unsetRules('mitmproxyssl')
        self.FSettings.Settings.set_setting('plugins','mitmproxy_plugin',self.check_mitmproxy.isChecked())
        self.FSettings.Settings.set_setting('plugins','mitmproxyssl_plugin',self.check_mitmproxyssl.isChecked())
        self.FSettings.Settings.set_setting('plugins','noproxy',self.check_noproxy.isChecked())
        if self.check_mitmproxy.isChecked():
            self.main_method.set_proxy_statusbar('MITM-Proxy')
            self.main_method.MitmProxyTAB.tabcontrol.setEnabled(True)
            self.set_MitmProxyRule()
        elif self.check_mitmproxyssl.isChecked():
            self.main_method.set_proxy_statusbar('MITM-Proxy-SSL')
            self.main_method.MitmProxyTAB.tabcontrol.setEnabled(True)
            self.set_MitmProxySSLRule()
        elif self.check_noproxy.isChecked():
            self.main_method.set_proxy_statusbar('',disabled=True)
            self.main_method.MitmProxyTAB.tabcontrol.setEnabled(False)
            self.unsetRules('mitmproxy') 
            self.unsetRules('mitmproxyssl')
            self.tableplugincheckbox.setEnabled(True)
            self.checkBoxTCPproxy()

    def checkBoxTCPproxy(self):
        if self.check_tcpproxy.isChecked():
            self.FSettings.Settings.set_setting('plugins','tcpproxy_plugin',True)
            self.main_method.PacketSnifferTAB.tabcontrol.setEnabled(True)
            self.main_method.ImageCapTAB.TableImage.setEnabled(True)
        else:
            self.FSettings.Settings.set_setting('plugins','tcpproxy_plugin',False)
            self.main_method.PacketSnifferTAB.tabcontrol.setEnabled(False)
            self.main_method.ImageCapTAB.TableImage.setEnabled(False)

    def checkBoxResponder(self):
        if self.check_responder.isChecked():
            self.FSettings.Settings.set_setting('plugins','responder_plugin',True)
        else:
            self.FSettings.Settings.set_setting('plugins','responder_plugin',False)

    def optionsRules(self, serviceName):
        ''' add rules iptable by type plugins'''
        search = {
        'mitmproxy':
                    [
                        str('iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080'),
                    ],
        'mitmproxyssl':
                    [
                        str('iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080'),
                        str('iptables -t nat -A PREROUTING -p tcp --destination-port 443 -j REDIRECT --to-port 8080')
                    ],
        'meatgluednsproxy':
                    [
                        str('iptables -t nat -A PREROUTING -p udp --destination-port 53 -j REDIRECT --to-port 53'),
                    ]
        }
        return search[serviceName]

    def setRules(self, serviceName, includeStockRules = True):
        items = []
        optionRulesResults = self.optionsRules(serviceName)
        if includeStockRules:
            for index in xrange(self.FSettings.ListRules.count()):
                items.append(str(self.FSettings.ListRules.item(index).text()))
        for rule in optionRulesResults:
            if rule in items:
                continue
            item = QtGui.QListWidgetItem()
            item.setText(rule)
            item.setSizeHint(QtCore.QSize(30,30))
            self.FSettings.ListRules.addItem(item) 

    def set_MitmProxyRule(self):
        self.setRules(serviceName = 'mitmproxy')

    def set_MitmProxySSLRule(self):
        self.setRules(serviceName = 'mitmproxyssl')

    def set_MeatGlueProxyRule(self):
        self.setRules(serviceName = 'meatgluednsproxy')

    def unsetRules(self, serviceName):
        ''' remove rules from Listwidget in settings widget'''
        optionRulesResults = self.optionsRules(serviceName)
        for index in xrange(self.FSettings.ListRules.count()):
            try:
                ruleData = str(self.FSettings.ListRules.item(index).text())
            except:
                self.FSettings.ListRules.takeItem(index)
                ruleData = '~' 
            if ruleData in str(optionRulesResults) or ruleData == '~':
                self.FSettings.ListRules.takeItem(index)
                continue
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
class PopUpPlugins(QtGui.QVBoxLayout):
    ''' this module control all plugins to MITM attack'''
    sendSingal_disable = QtCore.pyqtSignal(object)

    def __init__(self, FSettings, main, parent=None):
        super(PopUpPlugins, self).__init__(parent)
        self.main_method = main
        self.FSettings = FSettings
        self.layout = QtGui.QVBoxLayout()
        self.layoutform = QtGui.QFormLayout()
        self.layoutproxy = QtGui.QVBoxLayout()
        self.GroupPlugins = QtGui.QGroupBox()
        self.GroupPluginsProxy = QtGui.QGroupBox()
        self.GroupPlugins.setTitle('plugins:')
        self.GroupPluginsProxy.setTitle('Enable proxy server:')
        self.GroupPluginsProxy.setCheckable(True)
        self.GroupPluginsProxy.clicked.connect(self.get_disable_proxyserver)
        self.GroupPluginsProxy.setLayout(self.layoutproxy)
        self.GroupPlugins.setLayout(self.layoutform)

        self.check_netcreds = QtGui.QCheckBox('net-creds ')
        self.check_responder = QtGui.QCheckBox('Responder')
        self.check_tcpproxy = QtGui.QCheckBox('TCP-Proxy')
        self.check_pumpkinProxy = QtGui.QRadioButton('Pumpkin-Proxy')
        self.check_dns2proy = QtGui.QRadioButton('SSLstrip+|Dns2proxy')
        self.check_sergioProxy = QtGui.QRadioButton('SSLstrip|Sergio-proxy')
        self.check_bdfproxy = QtGui.QRadioButton('BDFProxy-ng')
        self.check_noproxy = QtGui.QRadioButton('No Proxy')

        self.btnBDFSettings = QtGui.QPushButton('Change')
        self.btnResponderSettings = QtGui.QPushButton('Change')
        self.btnBDFSettings.setIcon(QtGui.QIcon('icons/config.png'))
        self.btnResponderSettings.setIcon(QtGui.QIcon('icons/config.png'))
        self.btnBDFSettings.clicked.connect(self.ConfigOBJBDFproxy)
        self.btnResponderSettings.clicked.connect(self.ConfigOBJBResponder)

        # set text description plugins
        self.check_dns2proy.setObjectName(
            'This tools offer a different features '
            'for post-explotation once you change the DNS server to a Victim. coded by: LeonardoNve'
        )
        self.check_sergioProxy.setObjectName(
            'Sergio proxy is an HTTP proxy that was written '
            'in Python for the Twisted framework. coded by: LeonardoNve')
        self.check_bdfproxy.setObjectName(
            'Patch Binaries via MITM: BackdoorFactory + mitmProxy, '
            'bdfproxy-ng is a fork and review of the original BDFProxy. coded by: secretsquirrel.'
        )
        self.check_pumpkinProxy.setObjectName(
            'Transparent proxy - intercepting HTTP data, '
            'this proxy server that allows to intercept requests and response on the fly'
        )

        # desction plugin checkbox
        self.check_netcreds.setObjectName(
            'Sniff passwords and hashes from an interface or pcap file.'
            ' coded by: Dan McInerney')
        self.check_tcpproxy.setObjectName(
            'sniff for isntercept network traffic on UDP,TCP protocol.'
            ' get password,hash,image,etc...')
        self.check_responder.setObjectName(
            'Responder an LLMNR, NBT-NS and MDNS poisoner. '
            'By default, the tool will only answer to File Server Service request, which is for SMB.'
        )

        # table 1 for add plugins with QradioBtton
        self.THeadersPluginsProxy = OrderedDict([
            ('Plugins', [
                self.check_pumpkinProxy, self.check_dns2proy,
                self.check_sergioProxy, self.check_bdfproxy
            ]),
            ('Settings', [
                QtGui.QPushButton('None'),
                QtGui.QPushButton('None'),
                QtGui.QPushButton('None'), self.btnBDFSettings
            ]),
            ('Description', [
                self.check_pumpkinProxy.objectName(),
                self.check_dns2proy.objectName(),
                self.check_sergioProxy.objectName(),
                self.check_bdfproxy.objectName()
            ])
        ])

        # table 2 for add plugins with checkbox
        self.THeadersPlugins = OrderedDict([
            ('Plugins', [self.check_tcpproxy, self.check_responder]),
            ('Settings',
             [QtGui.QPushButton('None'), self.btnResponderSettings]),
            ('Description', [
                self.check_tcpproxy.objectName(),
                self.check_responder.objectName(),
            ])
        ])

        self.tableplugins = QtGui.QTableWidget()
        self.tableplugins.setColumnCount(3)
        self.tableplugins.setRowCount(len(
            self.THeadersPluginsProxy['Plugins']))
        self.tableplugins.resizeRowsToContents()
        self.tableplugins.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                        QtGui.QSizePolicy.Preferred)
        self.tableplugins.horizontalHeader().setStretchLastSection(True)
        self.tableplugins.setSelectionBehavior(
            QtGui.QAbstractItemView.SelectRows)
        self.tableplugins.setEditTriggers(
            QtGui.QAbstractItemView.NoEditTriggers)
        self.tableplugins.verticalHeader().setVisible(False)
        self.tableplugins.verticalHeader().setDefaultSectionSize(23)
        self.tableplugins.setSortingEnabled(True)
        self.tableplugins.setHorizontalHeaderLabels(
            self.THeadersPluginsProxy.keys())
        self.tableplugins.horizontalHeader().resizeSection(0, 158)
        self.tableplugins.horizontalHeader().resizeSection(1, 80)
        self.tableplugins.resizeRowsToContents()

        self.tableplugincheckbox = QtGui.QTableWidget()
        self.tableplugincheckbox.setColumnCount(3)
        self.tableplugincheckbox.setRowCount(
            len(self.THeadersPlugins['Plugins']))
        self.tableplugincheckbox.resizeRowsToContents()
        self.tableplugincheckbox.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                               QtGui.QSizePolicy.Preferred)
        self.tableplugincheckbox.horizontalHeader().setStretchLastSection(True)
        self.tableplugincheckbox.setSelectionBehavior(
            QtGui.QAbstractItemView.SelectRows)
        self.tableplugincheckbox.setEditTriggers(
            QtGui.QAbstractItemView.NoEditTriggers)
        self.tableplugincheckbox.verticalHeader().setVisible(False)
        self.tableplugincheckbox.verticalHeader().setDefaultSectionSize(23)
        self.tableplugincheckbox.setSortingEnabled(True)
        self.tableplugincheckbox.setHorizontalHeaderLabels(
            self.THeadersPlugins.keys())
        self.tableplugincheckbox.horizontalHeader().resizeSection(0, 158)
        self.tableplugincheckbox.horizontalHeader().resizeSection(1, 80)
        self.tableplugincheckbox.resizeRowsToContents()

        # add all widgets in Qtable 1 plgins
        Headers = []
        for n, key in enumerate(self.THeadersPluginsProxy.keys()):
            Headers.append(key)
            for m, item in enumerate(self.THeadersPluginsProxy[key]):
                if type(item) == type(
                        QtGui.QRadioButton()) or type(item) == type(
                            QtGui.QPushButton()):
                    self.tableplugins.setCellWidget(m, n, item)
                else:
                    item = QtGui.QTableWidgetItem(item)
                    self.tableplugins.setItem(m, n, item)
        self.tableplugins.setHorizontalHeaderLabels(
            self.THeadersPluginsProxy.keys())
        # add all widgets in Qtable 2 plugin
        Headers = []
        for n, key in enumerate(self.THeadersPlugins.keys()):
            Headers.append(key)
            for m, item in enumerate(self.THeadersPlugins[key]):
                if type(item) == type(QtGui.QCheckBox()) or type(item) == type(
                        QtGui.QPushButton()):
                    self.tableplugincheckbox.setCellWidget(m, n, item)
                else:
                    item = QtGui.QTableWidgetItem(item)
                    self.tableplugincheckbox.setItem(m, n, item)
        self.tableplugins.setHorizontalHeaderLabels(
            self.THeadersPlugins.keys())

        self.proxyGroup = QtGui.QButtonGroup()
        self.proxyGroup.addButton(self.check_pumpkinProxy)
        self.proxyGroup.addButton(self.check_dns2proy)
        self.proxyGroup.addButton(self.check_sergioProxy)
        self.proxyGroup.addButton(self.check_noproxy)
        self.proxyGroup.addButton(self.check_bdfproxy)

        self.check_tcpproxy.clicked.connect(self.checkBoxTCPproxy)
        self.check_pumpkinProxy.clicked.connect(self.checkGeneralOptions)
        self.check_dns2proy.clicked.connect(self.checkGeneralOptions)
        self.check_sergioProxy.clicked.connect(self.checkGeneralOptions)
        self.check_bdfproxy.clicked.connect(self.checkGeneralOptions)
        self.check_noproxy.clicked.connect(self.checkGeneralOptions)
        self.check_responder.clicked.connect(self.checkBoxResponder)

        self.layoutproxy.addWidget(self.tableplugins)
        self.layoutproxy.addWidget(self.tableplugincheckbox)
        self.layout.addWidget(self.GroupPluginsProxy)
        self.addLayout(self.layout)

    def get_disable_proxyserver(self):
        ''' set disable or activate plugin proxy '''
        self.check_noproxy.setChecked(True)
        self.tableplugincheckbox.setEnabled(True)
        self.sendSingal_disable.emit(self.check_noproxy.isChecked())
        self.checkBoxTCPproxy()

    # control checkbox plugins
    def checkGeneralOptions(self):
        ''' settings plugins proxy options and rules iptables '''
        self.unset_Rules('dns2proxy')
        self.unset_Rules('sslstrip')
        self.unset_Rules('bdfproxy')
        self.FSettings.Settings.set_setting(
            'plugins', 'pumpkinproxy_plugin',
            self.check_pumpkinProxy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'sergioproxy_plugin',
                                            self.check_sergioProxy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'dns2proxy_plugin',
                                            self.check_dns2proy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'bdfproxy_plugin',
                                            self.check_bdfproxy.isChecked())
        self.FSettings.Settings.set_setting('plugins', 'noproxy',
                                            self.check_noproxy.isChecked())
        if self.check_sergioProxy.isChecked():
            self.main_method.set_proxy_statusbar('SSLstrip|Sergio-proxy')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(
                False)  # disable ProxyPumpkinTAB
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(
                True)  # enable SSLSTRIP Proxy TAB
            self.set_sslStripRule()
        elif self.check_dns2proy.isChecked():
            self.main_method.set_proxy_statusbar('SSLstrip+|Dns2-proxy')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(False)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(True)
            self.set_sslStripRule()
            self.set_Dns2proxyRule()
        elif self.check_bdfproxy.isChecked():
            self.main_method.set_proxy_statusbar('BDF-proxy-ng')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(False)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(False)
            self.unset_Rules('dns2proxy')
            self.unset_Rules('sslstrip')
            self.set_BDFproxyRule()
        elif self.check_pumpkinProxy.isChecked():
            self.main_method.set_proxy_statusbar('Pumpkin-Proxy')
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(True)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(False)
            self.unset_Rules('dns2proxy')
            self.unset_Rules('sslstrip')
            self.set_PumpkinProxy()
        elif self.check_noproxy.isChecked():
            self.main_method.set_proxy_statusbar('', disabled=True)
            self.main_method.PumpkinProxyTAB.tabcontrol.setEnabled(False)
            self.main_method.ProxyPluginsTAB.scrollwidget.setEnabled(False)
            self.unset_Rules('dns2proxy')
            self.unset_Rules('sslstrip')
            self.unset_Rules('bdfproxy')

    def ConfigOBJBDFproxy(self):
        ''' show BDFproxy settings page '''
        self.SettingsBDFProxy = BDFProxySettings()
        self.SettingsBDFProxy.show()

    def ConfigOBJBResponder(self):
        ''' show REsponder settings page '''
        self.SettingsResponder = ResponderSettings()
        self.SettingsResponder.show()

    def checkBoxTCPproxy(self):
        if self.check_tcpproxy.isChecked():
            self.FSettings.Settings.set_setting('plugins', 'tcpproxy_plugin',
                                                True)
            self.main_method.PacketSnifferTAB.tabcontrol.setEnabled(True)
            self.main_method.ImageCapTAB.TableImage.setEnabled(True)
        else:
            self.FSettings.Settings.set_setting('plugins', 'tcpproxy_plugin',
                                                False)
            self.main_method.PacketSnifferTAB.tabcontrol.setEnabled(False)
            self.main_method.ImageCapTAB.TableImage.setEnabled(False)

    def checkBoxResponder(self):
        if self.check_responder.isChecked():
            self.FSettings.Settings.set_setting('plugins', 'responder_plugin',
                                                True)
        else:
            self.FSettings.Settings.set_setting('plugins', 'responder_plugin',
                                                False)

    def optionsRules(self, type):
        ''' add rules iptable by type plugins'''
        search = {
            'sslstrip':
            str('iptables -t nat -A PREROUTING -p tcp' +
                ' --destination-port 80 -j REDIRECT --to-port ' +
                self.FSettings.redirectport.text()),
            'dns2proxy':
            str('iptables -t nat -A PREROUTING -p udp --destination-port 53 -j REDIRECT --to-port 53'
                ),
            'bdfproxy':
            str('iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080'
                ),
            'PumpkinProxy':
            str('iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080'
                )
        }
        return search[type]

    # set rules to sslstrip
    def set_sslStripRule(self):
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        if self.optionsRules('sslstrip') in items:
            return
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('sslstrip'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    # set redirect port rules dns2proy
    def set_Dns2proxyRule(self):
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('dns2proxy'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    # set redirect port rules bdfproxy
    def set_BDFproxyRule(self):
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        if self.optionsRules('bdfproxy') in items:
            return
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('bdfproxy'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    def set_PumpkinProxy(self):
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        if self.optionsRules('PumpkinProxy') in items:
            return
        item = QtGui.QListWidgetItem()
        item.setText(self.optionsRules('PumpkinProxy'))
        item.setSizeHint(QtCore.QSize(30, 30))
        self.FSettings.ListRules.addItem(item)

    def unset_Rules(self, type):
        ''' remove rules from Listwidget in settings widget'''
        items = []
        for index in xrange(self.FSettings.ListRules.count()):
            items.append(str(self.FSettings.ListRules.item(index).text()))
        for position, line in enumerate(items):
            if self.optionsRules(type) == line:
                self.FSettings.ListRules.takeItem(position)
Exemplo n.º 5
0
class ProxySSLstrip(QtGui.QVBoxLayout):
    ''' settings  Transparent Proxy '''
    sendError = QtCore.pyqtSignal(str)
    _PluginsToLoader = {'plugins': None, 'Content': ''}

    def __init__(self, popup, main_method, FsettingsUI=None, parent=None):
        super(ProxySSLstrip, self).__init__(parent)
        self.main_method = main_method
        self.popup = popup
        self.urlinjected = []
        self.FSettings = FsettingsUI
        self.mainLayout = QtGui.QVBoxLayout()

        #scroll area
        self.scrollwidget = QtGui.QWidget()
        self.scrollwidget.setLayout(self.mainLayout)
        self.scroll = QtGui.QScrollArea()
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.scrollwidget)

        # create widgets
        self.argsLabel = QtGui.QLabel('')
        self.hBox = QtGui.QHBoxLayout()
        self.hBoxargs = QtGui.QHBoxLayout()
        self.btnLoader = QtGui.QPushButton('Reload')
        self.btnEnable = QtGui.QPushButton('Enable')
        self.btncancel = QtGui.QPushButton('Cancel')
        self.btnbrownser = QtGui.QPushButton('Browser')

        # size buttons
        self.btnLoader.setFixedWidth(100)
        self.btnEnable.setFixedWidth(100)
        self.btncancel.setFixedWidth(100)
        self.btnbrownser.setFixedWidth(100)

        self.comboxBox = QtGui.QComboBox()
        self.log_inject = QtGui.QListWidget()
        self.docScripts = QtGui.QTextEdit()
        self.argsScripts = QtGui.QLineEdit()
        self.btncancel.setIcon(QtGui.QIcon('icons/cancel.png'))
        self.btnLoader.setIcon(QtGui.QIcon('icons/search.png'))
        self.btnEnable.setIcon(QtGui.QIcon('icons/accept.png'))
        self.btnbrownser.setIcon(QtGui.QIcon("icons/open.png"))
        self.argsScripts.setEnabled(False)
        self.btnbrownser.setEnabled(False)

        # group settings
        self.GroupSettings = QtGui.QGroupBox()
        self.GroupSettings.setTitle('settings:')
        self.SettingsLayout = QtGui.QFormLayout()
        self.hBox.addWidget(self.comboxBox)
        self.hBox.addWidget(self.btnLoader)
        self.hBox.addWidget(self.btnEnable)
        self.hBox.addWidget(self.btncancel)
        self.hBoxargs.addWidget(self.argsLabel)
        self.hBoxargs.addWidget(self.argsScripts)
        self.hBoxargs.addWidget(self.btnbrownser)
        self.SettingsLayout.addRow(self.hBox)
        self.SettingsLayout.addRow(self.hBoxargs)
        self.GroupSettings.setLayout(self.SettingsLayout)
        #self.GroupSettings.setFixedWidth(450)
        #group logger
        self.GroupLogger = QtGui.QGroupBox()
        self.GroupLogger.setTitle('Logger Injection:')
        self.LoggerLayout = QtGui.QVBoxLayout()
        self.LoggerLayout.addWidget(self.log_inject)
        self.GroupLogger.setLayout(self.LoggerLayout)
        #self.GroupLogger.setFixedWidth(450)

        #group descriptions
        self.GroupDoc = QtGui.QGroupBox()
        self.GroupDoc.setTitle('Description:')
        self.DocLayout = QtGui.QFormLayout()
        self.DocLayout.addRow(self.docScripts)
        self.GroupDoc.setLayout(self.DocLayout)
        self.GroupDoc.setFixedHeight(100)

        #connections
        self.SearchProxyPlugins()
        self.readDocScripts('html_injector')
        self.btnLoader.clicked.connect(self.SearchProxyPlugins)
        self.connect(self.comboxBox,
                     QtCore.SIGNAL('currentIndexChanged(QString)'),
                     self.readDocScripts)
        self.btnEnable.clicked.connect(self.setPluginsActivated)
        self.btncancel.clicked.connect(self.unsetPluginsConf)
        self.btnbrownser.clicked.connect(self.get_filenameToInjection)
        # add widgets
        self.mainLayout.addWidget(self.GroupSettings)
        self.mainLayout.addWidget(self.GroupDoc)
        self.mainLayout.addWidget(self.GroupLogger)
        self.layout = QtGui.QHBoxLayout()
        self.layout.addWidget(self.scroll)
        self.addLayout(self.layout)

    def get_filenameToInjection(self):
        ''' open file for injection plugin '''
        filename = QtGui.QFileDialog.getOpenFileName(
            None, 'load File', '', 'HTML (*.html);;js (*.js);;css (*.css)')
        if len(filename) > 0:
            self.argsScripts.setText(filename)
            QtGui.QMessageBox.information(
                None, 'Scripts Loaders', 'file has been loaded with success.')

    def setPluginsActivated(self):
        ''' check arguments for plugins '''
        item = str(self.comboxBox.currentText())
        if self.popup.check_dns2proy.isChecked(
        ) or self.popup.check_sergioProxy.isChecked():
            if self.plugins[str(item)]._requiresArgs:
                if len(self.argsScripts.text()) != 0:
                    self._PluginsToLoader['plugins'] = item
                    self._PluginsToLoader['Content'] = str(
                        self.argsScripts.text())
                else:
                    return self.sendError.emit(
                        'this module proxy requires {} args'.format(
                            self.argsLabel.text()))
            else:
                self._PluginsToLoader['plugins'] = item
            self.btnEnable.setEnabled(False)
            self.ProcessReadLogger()
            return self.main_method.set_proxy_scripts(True)
        self.sendError.emit(
            'plugins::Proxy is not enabled.'
            '\n\nthis module need a proxy server(sslstrip) to work,'
            '\nchoice the plugin options with sslstrip enabled.'.format(
                self.argsLabel.text()))

    def ProcessReadLogger(self):
        '''function for read log injection proxy '''
        if path.exists(C.LOG_SSLSTRIP):
            with open(C.LOG_SSLSTRIP, 'w') as bufferlog:
                bufferlog.write(''), bufferlog.close()
            self.injectionThread = ThreadPopen(['tail', '-f', C.LOG_SSLSTRIP])
            self.connect(self.injectionThread,
                         QtCore.SIGNAL('Activated ( QString ) '),
                         self.GetloggerInjection)
            self.injectionThread.setObjectName('Pump-Proxy::Capture')
            return self.injectionThread.start()
        QtGui.QMessageBox.warning(self, 'error proxy logger',
                                  'Pump-Proxy::capture is not found')

    def GetloggerInjection(self, data):
        ''' read load file and add in Qlistwidget '''
        if Refactor.getSize(C.LOG_SSLSTRIP) > 255790:
            with open(C.LOG_SSLSTRIP, 'w') as bufferlog:
                bufferlog.write(''), bufferlog.close()
        if data not in self.urlinjected:
            self.log_inject.addItem(data)
            self.urlinjected.append(data)
        self.log_inject.scrollToBottom()

    def readDocScripts(self, item):
        ''' check type args for all plugins '''
        try:
            self.docScripts.setText(self.plugins[str(item)].__doc__)
            if self.plugins[str(item)]._requiresArgs:
                if 'FilePath' in self.plugins[str(item)]._argsname:
                    self.btnbrownser.setEnabled(True)
                else:
                    self.btnbrownser.setEnabled(False)
                self.argsScripts.setEnabled(True)
                self.argsLabel.setText(self.plugins[str(item)]._argsname)
            else:
                self.argsScripts.setEnabled(False)
                self.btnbrownser.setEnabled(False)
                self.argsLabel.setText('')
        except Exception:
            pass

    def unsetPluginsConf(self):
        ''' reset config for all plugins '''
        if hasattr(self, 'injectionThread'): self.injectionThread.stop()
        self._PluginsToLoader = {'plugins': None, 'args': ''}
        self.btnEnable.setEnabled(True)
        self.main_method.set_proxy_scripts(False)
        self.argsScripts.clear()
        self.log_inject.clear()
        self.urlinjected = []

    def SearchProxyPlugins(self):
        ''' search all plugins in directory plugins/external/proxy'''
        self.comboxBox.clear()
        self.plugin_classes = Plugin.PluginProxy.__subclasses__()
        self.plugins = {}
        for p in self.plugin_classes:
            self.plugins[p._name] = p()
        self.comboxBox.addItems(self.plugins.keys())
Exemplo n.º 6
0
class PumpkinSettings(QtGui.QVBoxLayout):
    ''' settings DHCP options'''
    sendMensage = QtCore.pyqtSignal(str)
    checkDockArea = QtCore.pyqtSignal(dict)

    def __init__(self, parent=None, widgets=None):
        super(PumpkinSettings, self).__init__(parent)
        self.SettingsAp = widgets['SettingsAP']
        self.Tab_Dock = widgets['Tab_dock']
        self.dockInfo = widgets['DockInfo']
        self.FSettings = widgets['Settings']
        self.NetworkGroup = widgets['Network']
        self.mainLayout = QtGui.QFormLayout()
        self.SettingsDHCP = {}

        #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.GroupDHCP = QtGui.QGroupBox()
        self.GroupArea = QtGui.QGroupBox()
        self.layoutDHCP = QtGui.QFormLayout()
        self.layoutArea = QtGui.QFormLayout()
        self.layoutbuttons = QtGui.QHBoxLayout()
        self.btnDefault = QtGui.QPushButton('Default')
        self.btnSave = QtGui.QPushButton('save settings')
        self.btnSave.setIcon(QtGui.QIcon('icons/export.png'))
        self.btnDefault.setIcon(QtGui.QIcon('icons/settings.png'))
        self.dhcpClassIP = QtGui.QComboBox()
        # dhcp class
        self.classtypes = [
            'Class-A-Address', 'Class-B-Address', 'Class-C-Address',
            'Class-Custom-Address'
        ]
        for types in self.classtypes:
            if 'Class-{}-Address'.format(
                    self.FSettings.Settings.get_setting('dhcp',
                                                        'classtype')) in types:
                self.classtypes.remove(types), self.classtypes.insert(0, types)
        self.dhcpClassIP.addItems(self.classtypes)

        self.leaseTime_def = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'leasetimeDef'))
        self.leaseTime_Max = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'leasetimeMax'))
        self.netmask = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'netmask'))
        self.range_dhcp = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'range'))
        self.route = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'router'))
        self.subnet = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'subnet'))
        self.broadcast = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'broadcast'))
        self.dhcpClassIP.currentIndexChanged.connect(self.dhcpClassIPClicked)
        self.GroupDHCP.setTitle('DHCP-Settings')
        self.GroupDHCP.setLayout(self.layoutDHCP)
        self.layoutDHCP.addRow('Class Ranges', self.dhcpClassIP)
        self.layoutDHCP.addRow('default-lease-time', self.leaseTime_def)
        self.layoutDHCP.addRow('max-lease-time', self.leaseTime_Max)
        self.layoutDHCP.addRow('subnet', self.subnet)
        self.layoutDHCP.addRow('router', self.route)
        self.layoutDHCP.addRow('netmask', self.netmask)
        self.layoutDHCP.addRow('broadcast-address', self.broadcast)
        self.layoutDHCP.addRow('range-dhcp', self.range_dhcp)
        self.GroupDHCP.setFixedWidth(350)
        # layout add
        self.layoutbuttons.addWidget(self.btnSave)
        self.layoutbuttons.addWidget(self.btnDefault)
        self.layoutDHCP.addRow(self.layoutbuttons)

        # Area Group
        self.gridArea = QtGui.QGridLayout()
        self.CB_ActiveMode = QtGui.QCheckBox(
            '::Advanced Mode:: Monitor MITM Attack')
        self.CB_ActiveMode.setHidden(True)
        self.CB_Cread = QtGui.QCheckBox('HTTP-Authentication')
        self.CB_monitorURL = QtGui.QCheckBox('HTTP-Requests')
        self.CB_bdfproxy = QtGui.QCheckBox('BDFProxy-ng')
        self.CB_dns2proxy = QtGui.QCheckBox('Dns2Proxy')
        self.CB_responder = QtGui.QCheckBox('Responder')
        self.CB_pumpkinPro = QtGui.QCheckBox('Pumpkin-Proxy')
        self.CB_ActiveMode.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'advanced',
                                                format=bool))
        self.CB_Cread.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_credencials',
                                                format=bool))
        self.CB_monitorURL.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_urlmonitor',
                                                format=bool))
        self.CB_bdfproxy.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_bdfproxy',
                                                format=bool))
        self.CB_dns2proxy.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_dns2proxy',
                                                format=bool))
        self.CB_responder.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_responder',
                                                format=bool))
        self.CB_pumpkinPro.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_PumpkinProxy',
                                                format=bool))

        #connect
        self.doCheckAdvanced()
        self.CB_ActiveMode.clicked.connect(self.doCheckAdvanced)
        self.CB_monitorURL.clicked.connect(self.doCheckAdvanced)
        self.CB_Cread.clicked.connect(self.doCheckAdvanced)
        self.CB_bdfproxy.clicked.connect(self.doCheckAdvanced)
        self.CB_dns2proxy.clicked.connect(self.doCheckAdvanced)
        self.CB_responder.clicked.connect(self.doCheckAdvanced)
        self.CB_pumpkinPro.clicked.connect(self.doCheckAdvanced)
        # group
        self.layoutArea.addRow(self.CB_ActiveMode)
        self.gridArea.addWidget(
            self.CB_monitorURL,
            0,
            0,
        )
        self.gridArea.addWidget(self.CB_Cread, 0, 1)
        self.gridArea.addWidget(self.CB_responder, 0, 2)
        self.gridArea.addWidget(self.CB_bdfproxy, 1, 0)
        self.gridArea.addWidget(self.CB_bdfproxy, 1, 0)
        self.gridArea.addWidget(self.CB_dns2proxy, 1, 1)
        #self.gridArea.addWidget(self.CB_pumpkinPro,0,2) disable tab plugin
        self.layoutArea.addRow(self.gridArea)
        self.GroupArea.setTitle('Activity Monitor settings')
        self.GroupArea.setLayout(self.layoutArea)

        # connects
        self.btnDefault.clicked.connect(self.setdefaultSettings)
        self.btnSave.clicked.connect(self.savesettingsDHCP)
        self.mainLayout.addRow(self.SettingsAp)
        self.mainLayout.addRow(self.NetworkGroup)
        self.mainLayout.addRow(self.GroupArea)
        self.mainLayout.addRow(self.GroupDHCP)
        self.layout = QtGui.QHBoxLayout()
        self.layout.addWidget(self.scroll)
        self.addLayout(self.layout)

    def dhcpClassIPClicked(self, classIP):
        self.selected = str(self.dhcpClassIP.currentText())
        if 'class-Custom-Address' in self.selected: self.selected = 'dhcp'
        self.leaseTime_def.setText(
            self.FSettings.Settings.get_setting(self.selected, 'leasetimeDef'))
        self.leaseTime_Max.setText(
            self.FSettings.Settings.get_setting(self.selected, 'leasetimeMax'))
        self.netmask.setText(
            self.FSettings.Settings.get_setting(self.selected, 'netmask'))
        self.range_dhcp.setText(
            self.FSettings.Settings.get_setting(self.selected, 'range'))
        self.route.setText(
            self.FSettings.Settings.get_setting(self.selected, 'router'))
        self.subnet.setText(
            self.FSettings.Settings.get_setting(self.selected, 'subnet'))
        self.broadcast.setText(
            self.FSettings.Settings.get_setting(self.selected, 'broadcast'))

    def AreaWidgetLoader(self, DockInfo):
        if hasattr(self, 'dockList'):
            for dock in self.dockList:
                dock.close()
        self.AllDockArea = {}
        if self.FSettings.Settings.get_setting('dockarea',
                                               'advanced',
                                               format=bool):
            self.dockList = []
            for key in DockInfo.keys():
                if DockInfo[key]['active']:
                    self.dock = QtGui.QDockWidget(key)
                    if key == 'HTTP-Authentication':
                        self.AllDockArea[key] = dockCredsMonitor(
                            None, DockInfo[key])
                    elif key == 'HTTP-Requests':
                        self.AllDockArea[key] = dockUrlMonitor(
                            None, DockInfo[key])
                    elif key == 'PumpkinProxy':
                        self.AllDockArea[key] = dockPumpkinProxy(
                            None, DockInfo[key])
                    else:
                        self.AllDockArea[key] = dockAreaAPI(
                            None, DockInfo[key])
                    self.dock.setWidget(self.AllDockArea[key])
                    self.dock.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                            QtGui.QSizePolicy.Expanding)
                    self.dock.setAllowedAreas(QtCore.Qt.AllDockWidgetAreas)
                    self.dock.setFeatures(
                        QtGui.QDockWidget.DockWidgetMovable
                        | QtGui.QDockWidget.DockWidgetFloatable)
                    self.Tab_Dock.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
                                                self.dock)
                    self.dockList.insert(0, self.dock)
            if len(self.dockList) > 1:
                for index in range(1, len(self.dockList) - 1):
                    if self.dockList[index].objectName() != 'HTTP-Requests':
                        self.Tab_Dock.tabifyDockWidget(
                            self.dockList[index], self.dockList[index + 1])
            try:
                self.dockList[0].raise_()
            except IndexError:
                pass
            self.checkDockArea.emit(self.AllDockArea)

    def doCheckAdvanced(self):
        if self.CB_ActiveMode.isChecked():
            self.CB_monitorURL.setEnabled(True)
            self.CB_Cread.setEnabled(True)
            self.CB_bdfproxy.setEnabled(True)
            self.CB_dns2proxy.setEnabled(True)
            self.CB_responder.setEnabled(True)
            self.CB_pumpkinPro.setEnabled(True)
        else:
            self.CB_monitorURL.setEnabled(False)
            self.CB_Cread.setEnabled(False)
            self.CB_bdfproxy.setEnabled(False)
            self.CB_dns2proxy.setEnabled(False)
            self.CB_responder.setEnabled(False)
            self.CB_pumpkinPro.setEnabled(False)
        self.FSettings.Settings.set_setting('dockarea', 'dock_credencials',
                                            self.CB_Cread.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_urlmonitor',
                                            self.CB_monitorURL.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_bdfproxy',
                                            self.CB_bdfproxy.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_dns2proxy',
                                            self.CB_dns2proxy.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_responder',
                                            self.CB_responder.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_PumpkinProxy',
                                            self.CB_pumpkinPro.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'advanced',
                                            self.CB_ActiveMode.isChecked())
        self.dockInfo['HTTP-Requests'][
            'active'] = self.CB_monitorURL.isChecked()
        self.dockInfo['HTTP-Authentication'][
            'active'] = self.CB_Cread.isChecked()
        self.dockInfo['BDFProxy']['active'] = self.CB_bdfproxy.isChecked()
        self.dockInfo['Dns2Proxy']['active'] = self.CB_dns2proxy.isChecked()
        self.dockInfo['Responder']['active'] = self.CB_responder.isChecked()
        self.dockInfo['PumpkinProxy']['active'] = self.CB_pumpkinPro.isChecked(
        )
        if self.CB_ActiveMode.isChecked():
            self.AreaWidgetLoader(self.dockInfo)
            self.checkDockArea.emit(self.AllDockArea)
            if hasattr(self.Tab_Dock, 'form_widget'):
                if hasattr(self.Tab_Dock.form_widget, 'Apthreads'):
                    if self.Tab_Dock.form_widget.Apthreads['RougeAP'] != []:
                        for dock in self.Tab_Dock.form_widget.dockAreaList.keys(
                        ):
                            self.Tab_Dock.form_widget.dockAreaList[
                                dock].RunThread()
        else:
            if hasattr(self, 'dockList'):
                for dock in self.dockList:
                    dock.close()

    def setdefaultSettings(self):
        self.dhcpClassIP.setCurrentIndex(
            self.classtypes.index('Class-A-Address'))
        self.leaseTime_def.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'leasetimeDef'))
        self.leaseTime_Max.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'leasetimeMax'))
        self.netmask.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'netmask'))
        self.range_dhcp.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'range'))
        self.route.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'router'))
        self.subnet.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'subnet'))
        self.broadcast.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'broadcast'))

    def savesettingsDHCP(self):
        self.all_geteway_check = []
        for types in self.classtypes:
            if not 'Class-Custom-Address' in types:
                self.all_geteway_check.append(
                    self.FSettings.Settings.get_by_index_key(5, types))
        self.FSettings.Settings.set_setting(
            'dhcp', 'classtype',
            str(self.dhcpClassIP.currentText()).split('-')[1])
        self.FSettings.Settings.set_setting('dhcp', 'leasetimeDef',
                                            str(self.leaseTime_def.text()))
        self.FSettings.Settings.set_setting('dhcp', 'leasetimeMax',
                                            str(self.leaseTime_Max.text()))
        self.FSettings.Settings.set_setting('dhcp', 'netmask',
                                            str(self.netmask.text()))
        self.FSettings.Settings.set_setting('dhcp', 'range',
                                            str(self.range_dhcp.text()))
        self.FSettings.Settings.set_setting('dhcp', 'router',
                                            str(self.route.text()))
        self.FSettings.Settings.set_setting('dhcp', 'subnet',
                                            str(self.subnet.text()))
        self.FSettings.Settings.set_setting('dhcp', 'broadcast',
                                            str(self.broadcast.text()))
        if not str(self.route.text()) in self.all_geteway_check:
            self.FSettings.Settings.set_setting('dhcp', 'classtype', 'Custom')
        self.btnSave.setEnabled(False)
        self.sendMensage.emit('settings DHCP saved with success...')
        self.btnSave.setEnabled(True)

    def getPumpkinSettings(self):
        self.SettingsDHCP['leasetimeDef'] = str(self.leaseTime_def.text())
        self.SettingsDHCP['leasetimeMax'] = str(self.leaseTime_Max.text())
        self.SettingsDHCP['subnet'] = str(self.subnet.text())
        self.SettingsDHCP['router'] = str(self.route.text())
        self.SettingsDHCP['netmask'] = str(self.netmask.text())
        self.SettingsDHCP['broadcast'] = str(self.broadcast.text())
        self.SettingsDHCP['range'] = str(self.range_dhcp.text())
        return self.SettingsDHCP
Exemplo n.º 7
0
class PumpkinMitmproxy(QtGui.QVBoxLayout):
    ''' settings  Transparent Proxy '''
    sendError = QtCore.pyqtSignal(str)

    def __init__(self, mainWindow):
        QtGui.QVBoxLayout.__init__(self)
        self.mainLayout = QtGui.QVBoxLayout()
        self.config = SettingsINI(C.PUMPPROXY_INI)
        self.plugins = []
        self.main_method = mainWindow
        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)

        # 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(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(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.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())
Exemplo n.º 8
0
class ImageCapture(QtGui.QVBoxLayout):
    ''' settings Image capture '''
    sendError = QtCore.pyqtSignal(str)

    def __init__(self, main_method, parent=None):
        super(ImageCapture, self).__init__(parent)
        self.mainLayout = QtGui.QVBoxLayout()
        self.main_method = main_method
        #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.imagesList = []

        self.THUMBNAIL_SIZE = 146
        self.SPACING = 8
        self.IMAGES_PER_ROW = 4
        self.TableImage = QtGui.QTableWidget()
        self.TableImage.setIconSize(QtCore.QSize(146, 146))
        self.TableImage.setColumnCount(self.IMAGES_PER_ROW)
        self.TableImage.setGridStyle(QtCore.Qt.NoPen)

        self.TableImage.verticalHeader().setDefaultSectionSize(
            self.THUMBNAIL_SIZE + self.SPACING)
        self.TableImage.verticalHeader().hide()
        self.TableImage.horizontalHeader().setDefaultSectionSize(
            self.THUMBNAIL_SIZE + self.SPACING)
        self.TableImage.horizontalHeader().hide()

        self.TableImage.setMinimumWidth((self.THUMBNAIL_SIZE + self.SPACING) *
                                        self.IMAGES_PER_ROW +
                                        (self.SPACING * 2))
        self.imageListPath = OrderedDict([('Path', [])])
        self.mainLayout.addWidget(self.TableImage)
        self.layout = QtGui.QHBoxLayout()
        self.layout.addWidget(self.scroll)
        self.addLayout(self.layout)

    def SendImageTableWidgets(self, image):
        self.imageListPath['Path'].append(image)
        rowCount = len(self.imageListPath['Path']) // self.IMAGES_PER_ROW
        if len(self.imageListPath['Path']) % self.IMAGES_PER_ROW: rowCount += 1
        self.TableImage.setRowCount(rowCount)
        row = -1
        for i, picture in enumerate(self.imageListPath['Path']):
            col = i % self.IMAGES_PER_ROW
            if not col: row += 1
            self.addPicture(row, col, picture)

    def addPicture(self, row, col, picturePath):
        item = QtGui.QTableWidgetItem()
        p = QtGui.QPixmap(picturePath)
        if not p.isNull():
            if p.height() > p.width():
                p = p.scaledToWidth(self.THUMBNAIL_SIZE)
            else:
                p = p.scaledToHeight(self.THUMBNAIL_SIZE)
            p = p.copy(0, 0, self.THUMBNAIL_SIZE, self.THUMBNAIL_SIZE)
            item.setIcon(QtGui.QIcon(p))
            self.TableImage.setItem(row, col, item)
            self.TableImage.scrollToBottom()
Exemplo n.º 9
0
class PacketsSniffer(QtGui.QVBoxLayout):
    ''' settings  Transparent Proxy '''
    sendError = QtCore.pyqtSignal(str)

    def __init__(self, main_method, parent=None):
        super(PacketsSniffer, self).__init__(parent)
        self.mainLayout = QtGui.QVBoxLayout()
        self.config = SettingsINI(C.TCPPROXY_INI)
        self.plugins = []
        self.main_method = main_method
        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.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 = dockTCPproxy()

        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', []), ('Author', []),
                                     ('Description', [])])
        self.TabPlugins.setHorizontalHeaderLabels(self.THeaders.keys())
        self.TabPlugins.horizontalHeader().resizeSection(0, 158)
        self.TabPlugins.horizontalHeader().resizeSection(1, 120)

        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:
            self.bt_SettingsDict[plugin.Name] = QtGui.QPushButton(
                plugin.Author)
            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['Author'].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(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.addLayout(self.layout)

    def setPluginOption(self, name, status):
        ''' get each plugins status'''
        # enable realtime disable and enable plugin
        if self.main_method.FSettings.Settings.get_setting('accesspoint',
                                                           'statusAP',
                                                           format=bool):
            self.main_method.Thread_TCPproxy.disablePlugin(name, status)
        self.config.set_setting('plugins', name, status)

    def search_all_ProxyPlugins(self):
        ''' load all plugins function '''
        plugin_classes = default.PSniffer.__subclasses__()
        for p in plugin_classes:
            if p().Name != 'httpCap':
                self.plugins.append(p())
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
class PickleSettings(QtGui.QVBoxLayout):
    ''' settings DHCP options'''
    sendMensage = QtCore.pyqtSignal(str)
    checkDockArea = QtCore.pyqtSignal(dict)

    def __init__(self, parent=None, widgets=None):
        super(PickleSettings, self).__init__(parent)
        self.SettingsAp = widgets['SettingsAP']
        self.Tab_Dock = widgets['Tab_dock']
        self.dockInfo = widgets['DockInfo']
        self.FSettings = widgets['Settings']
        self.NetworkGroup = widgets['Network']
        self.mainLayout = QtGui.QFormLayout()
        self.SettingsDHCP = {}

        #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.GroupDHCP = QtGui.QGroupBox()
        self.GroupArea = QtGui.QGroupBox()
        self.layoutDHCP = QtGui.QFormLayout()
        self.layoutArea = QtGui.QFormLayout()
        self.layoutbuttons = QtGui.QHBoxLayout()
        self.btnDefault = QtGui.QPushButton('Default')
        self.btnSave = QtGui.QPushButton('Apply & Save')
        self.btnSave.setIcon(QtGui.QIcon('icons/export.png'))
        self.btnDefault.setIcon(QtGui.QIcon('icons/settings.png'))
        self.dhcpClassIP = QtGui.QComboBox()
        # dhcp class
        self.classtypes = [
            'Class-A-Address', 'Class-B-Address', 'Class-C-Address'
        ]
        for types in self.classtypes:
            if 'Class-{}-Address'.format(
                    self.FSettings.Settings.get_setting('dhcp',
                                                        'classtype')) in types:
                self.classtypes.remove(types), self.classtypes.insert(0, types)
        self.dhcpClassIP.addItems(self.classtypes)

        self.leaseTime_def = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'leasetimeDef'))
        self.leaseTime_Max = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'leasetimeMax'))
        self.netmask = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'netmask'))
        self.range_dhcp = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'range'))
        self.route = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'router'))
        self.subnet = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'subnet'))
        self.broadcast = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'broadcast'))
        self.option = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'option'))
        self.dns = QtGui.QLineEdit(
            self.FSettings.Settings.get_setting('dhcp', 'dns'))
        self.dhcpClassIP.currentIndexChanged.connect(self.dhcpClassIPClicked)
        self.GroupDHCP.setTitle('DHCP-Settings')
        self.GroupDHCP.setLayout(self.layoutDHCP)
        self.layoutDHCP.addRow('Class Ranges', self.dhcpClassIP)
        self.layoutDHCP.addRow('default-lease-time', self.leaseTime_def)
        self.layoutDHCP.addRow('max-lease-time', self.leaseTime_Max)
        self.layoutDHCP.addRow('subnet', self.subnet)
        self.layoutDHCP.addRow('router', self.route)
        self.layoutDHCP.addRow('netmask', self.netmask)
        self.layoutDHCP.addRow('broadcast-address', self.broadcast)
        self.layoutDHCP.addRow('DNS', self.dns)
        self.layoutDHCP.addRow('option', self.option)
        self.layoutDHCP.addRow('range-dhcp', self.range_dhcp)
        self.GroupDHCP.setFixedWidth(350)

        # layout add
        self.layoutbuttons.addWidget(self.btnSave)
        self.layoutbuttons.addWidget(self.btnDefault)
        self.layoutDHCP.addRow(self.layoutbuttons)

        # Area Group
        self.gridArea = QtGui.QGridLayout()
        self.CB_ActiveMode = QtGui.QCheckBox(
            '::Advanced Mode:: Monitor MITM Attack')
        self.CB_ActiveMode.setHidden(True)
        self.CB_Cread = QtGui.QCheckBox('HTTP-Authentication')
        self.CB_monitorURL = QtGui.QCheckBox('HTTP-Requests')
        self.CB_dhcpd = QtGui.QCheckBox('DHCPD')
        self.CB_mitmproxy = QtGui.QCheckBox('MITM Proxy')
        self.CB_meatglueproxy = QtGui.QCheckBox('MeatGlueDNSProxy')
        self.CB_responder = QtGui.QCheckBox('Responder')
        self.CB_picklePro = QtGui.QCheckBox('Pickle-Proxy')
        self.CB_ActiveMode.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'advanced',
                                                format=bool))
        self.CB_Cread.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_credencials',
                                                format=bool))
        self.CB_monitorURL.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_urlmonitor',
                                                format=bool))
        self.CB_dhcpd.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_dhcpd',
                                                format=bool))
        self.CB_mitmproxy.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_mitmproxy',
                                                format=bool))
        self.CB_meatglueproxy.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_meatglueproxy',
                                                format=bool))
        self.CB_responder.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_responder',
                                                format=bool))
        self.CB_picklePro.setChecked(
            self.FSettings.Settings.get_setting('dockarea',
                                                'dock_PickleProxy',
                                                format=bool))

        #connect
        self.doCheckAdvanced()
        self.CB_ActiveMode.clicked.connect(self.doCheckAdvanced)
        self.CB_monitorURL.clicked.connect(self.doCheckAdvanced)
        self.CB_Cread.clicked.connect(self.doCheckAdvanced)
        self.CB_dhcpd.clicked.connect(self.doCheckAdvanced)
        self.CB_mitmproxy.clicked.connect(self.doCheckAdvanced)
        self.CB_meatglueproxy.clicked.connect(self.doCheckAdvanced)
        self.CB_responder.clicked.connect(self.doCheckAdvanced)
        self.CB_picklePro.clicked.connect(self.doCheckAdvanced)
        # group
        self.layoutArea.addRow(self.CB_ActiveMode)
        self.gridArea.addWidget(self.CB_monitorURL, 0, 0)
        self.gridArea.addWidget(self.CB_Cread, 0, 1)
        self.gridArea.addWidget(self.CB_responder, 0, 2)
        self.gridArea.addWidget(self.CB_dhcpd, 1, 0)
        self.gridArea.addWidget(self.CB_mitmproxy, 1, 1)
        self.gridArea.addWidget(self.CB_meatglueproxy, 1, 2)
        self.layoutArea.addRow(self.gridArea)
        self.GroupArea.setTitle('Activity Monitor settings')
        self.GroupArea.setLayout(self.layoutArea)

        # connects
        self.btnDefault.clicked.connect(self.setdefaultSettings)
        self.btnSave.clicked.connect(self.savesettingsDHCP)
        self.mainLayout.addRow(self.SettingsAp)
        self.mainLayout.addRow(self.NetworkGroup)
        self.mainLayout.addRow(self.GroupArea)
        self.mainLayout.addRow(self.GroupDHCP)
        self.layout = QtGui.QHBoxLayout()
        self.layout.addWidget(self.scroll)
        self.addLayout(self.layout)

    def dhcpClassIPClicked(self, classIP):
        self.selected = str(self.dhcpClassIP.currentText())
        self.leaseTime_def.setText(
            self.FSettings.Settings.get_setting(self.selected, 'leasetimeDef'))
        self.leaseTime_Max.setText(
            self.FSettings.Settings.get_setting(self.selected, 'leasetimeMax'))
        self.netmask.setText(
            self.FSettings.Settings.get_setting(self.selected, 'netmask'))
        self.range_dhcp.setText(
            self.FSettings.Settings.get_setting(self.selected, 'range'))
        self.route.setText(
            self.FSettings.Settings.get_setting(self.selected, 'router'))
        self.subnet.setText(
            self.FSettings.Settings.get_setting(self.selected, 'subnet'))
        self.broadcast.setText(
            self.FSettings.Settings.get_setting(self.selected, 'broadcast'))
        self.dns.setText(
            self.FSettings.Settings.get_setting(self.selected, 'router'))
        self.savesettingsDHCP()

    def AreaWidgetLoader(self, DockInfo):
        if hasattr(self, 'dockList'):
            for dock in self.dockList:
                dock.close()
        self.AllDockArea = {}
        if self.FSettings.Settings.get_setting('dockarea',
                                               'advanced',
                                               format=bool):
            self.dockList = []
            for key in DockInfo.keys():
                if DockInfo[key]['active']:
                    self.dock = QtGui.QDockWidget(key)
                    if key == 'HTTP-Authentication':
                        self.AllDockArea[key] = dockCredsMonitor(
                            None, DockInfo[key])
                    elif key == 'HTTP-Requests':
                        self.AllDockArea[key] = dockUrlMonitor(
                            None, DockInfo[key])
                    elif key == 'PickleProxy':
                        self.AllDockArea[key] = dockPickleProxy(
                            None, DockInfo[key])
                    else:
                        self.AllDockArea[key] = dockAreaAPI(
                            None, DockInfo[key])
                    self.dock.setWidget(self.AllDockArea[key])
                    self.dock.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                            QtGui.QSizePolicy.Expanding)
                    self.dock.setAllowedAreas(QtCore.Qt.AllDockWidgetAreas)
                    self.dock.setFeatures(
                        QtGui.QDockWidget.DockWidgetMovable
                        | QtGui.QDockWidget.DockWidgetFloatable)
                    self.Tab_Dock.addDockWidget(QtCore.Qt.LeftDockWidgetArea,
                                                self.dock)
                    self.dockList.insert(0, self.dock)
            if len(self.dockList) > 1:
                for index in range(1, len(self.dockList) - 1):
                    if self.dockList[index].objectName() != 'HTTP-Requests':
                        self.Tab_Dock.tabifyDockWidget(
                            self.dockList[index], self.dockList[index + 1])
            try:
                self.dockList[0].raise_()
            except IndexError:
                pass
            self.checkDockArea.emit(self.AllDockArea)

    def doCheckAdvanced(self):
        if self.CB_ActiveMode.isChecked():
            self.CB_monitorURL.setEnabled(True)
            self.CB_Cread.setEnabled(True)
            self.CB_dhcpd.setEnabled(True)
            self.CB_mitmproxy.setEnabled(True)
            self.CB_meatglueproxy.setEnabled(True)
            self.CB_responder.setEnabled(True)
            self.CB_picklePro.setEnabled(True)
        else:
            self.CB_monitorURL.setEnabled(False)
            self.CB_Cread.setEnabled(False)
            self.CB_dhcpd.setEnabled(False)
            self.CB_mitmproxy.setEnabled(False)
            self.CB_meatglueproxy.setEnabled(False)
            self.CB_responder.setEnabled(False)
            self.CB_picklePro.setEnabled(False)
        self.FSettings.Settings.set_setting('dockarea', 'dock_credencials',
                                            self.CB_Cread.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_urlmonitor',
                                            self.CB_monitorURL.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_dhcpd',
                                            self.CB_dhcpd.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_mitmproxy',
                                            self.CB_mitmproxy.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_meatglueproxy',
                                            self.CB_meatglueproxy.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_responder',
                                            self.CB_responder.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'dock_PickleProxy',
                                            self.CB_picklePro.isChecked())
        self.FSettings.Settings.set_setting('dockarea', 'advanced',
                                            self.CB_ActiveMode.isChecked())
        self.dockInfo['HTTP-Requests'][
            'active'] = self.CB_monitorURL.isChecked()
        self.dockInfo['HTTP-Authentication'][
            'active'] = self.CB_Cread.isChecked()
        self.dockInfo['DHCPD']['active'] = self.CB_dhcpd.isChecked()
        self.dockInfo['MITMProxy']['active'] = self.CB_mitmproxy.isChecked()
        self.dockInfo['MeatGlueDNSProxy'][
            'active'] = self.CB_meatglueproxy.isChecked()
        self.dockInfo['Responder']['active'] = self.CB_responder.isChecked()
        if self.CB_ActiveMode.isChecked():
            self.AreaWidgetLoader(self.dockInfo)
            self.checkDockArea.emit(self.AllDockArea)
            if hasattr(self.Tab_Dock, 'form_widget'):
                if hasattr(self.Tab_Dock.form_widget, 'Apthreads'):
                    if self.Tab_Dock.form_widget.Apthreads['RougeAP'] != []:
                        for dock in self.Tab_Dock.form_widget.dockAreaList.keys(
                        ):
                            self.Tab_Dock.form_widget.dockAreaList[
                                dock].RunThread()
        else:
            if hasattr(self, 'dockList'):
                for dock in self.dockList:
                    dock.close()

    def setdefaultSettings(self):
        self.dhcpClassIP.setCurrentIndex(
            self.classtypes.index('Class-A-Address'))
        self.leaseTime_def.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'leasetimeDef'))
        self.leaseTime_Max.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'leasetimeMax'))
        self.netmask.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'netmask'))
        self.range_dhcp.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'range'))
        self.route.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'router'))
        self.subnet.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'subnet'))
        self.broadcast.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'broadcast'))
        self.dns.setText(
            self.FSettings.Settings.get_setting('dhcpdefault', 'router'))
        self.option.setText("")

    def writeDhcpConf(self):
        dhcpFile = open(str(C.DHCPCONF_PATH), 'w')
        leaseTimeDefault = self.FSettings.Settings.get_setting(
            'dhcp', 'leasetimeDef')
        leaseTimeMax = self.FSettings.Settings.get_setting(
            'dhcp', 'leasetimeMax')
        networkNetmask = self.FSettings.Settings.get_setting('dhcp', 'netmask')
        fullRange = self.FSettings.Settings.get_setting('dhcp', 'range')
        networkRouterAddr = self.FSettings.Settings.get_setting(
            'dhcp', 'router')
        networkAddr = self.FSettings.Settings.get_setting('dhcp', 'subnet')
        networkBroadcastAddr = self.FSettings.Settings.get_setting(
            'dhcp', 'broadcast')
        lowerRange = str(fullRange).split('/')[0]
        upperRange = str(fullRange).split('/')[1]
        dnsAddr = self.FSettings.Settings.get_setting('dhcp', 'dns')
        dhcpOption = self.FSettings.Settings.get_setting('dhcp', 'option')
        confSkeleton = """
default-lease-time %s;
max-lease-time %s;

ddns-update-style none;

authoritative;

subnet %s netmask %s {
  range %s %s;
  option routers %s;
  option domain-name-servers %s;
  %s
}
""" % (leaseTimeDefault, leaseTimeMax, networkAddr, networkNetmask, lowerRange,
        upperRange, networkRouterAddr, dnsAddr, dhcpOption)
        print('Writting dhcpd.conf with these contents:')
        print(confSkeleton)
        dhcpFile.write(confSkeleton)
        dhcpFile.close()

    def savesettingsDHCP(self):
        self.all_gateway_check = []
        for types in self.classtypes:
            self.all_gateway_check.append(
                self.FSettings.Settings.get_by_index_key(5, types))
        self.FSettings.Settings.set_setting(
            'dhcp', 'classtype',
            str(self.dhcpClassIP.currentText()).split('-')[1])
        self.FSettings.Settings.set_setting('dhcp', 'leasetimeDef',
                                            str(self.leaseTime_def.text()))
        self.FSettings.Settings.set_setting('dhcp', 'leasetimeMax',
                                            str(self.leaseTime_Max.text()))
        self.FSettings.Settings.set_setting('dhcp', 'netmask',
                                            str(self.netmask.text()))
        self.FSettings.Settings.set_setting('dhcp', 'range',
                                            str(self.range_dhcp.text()))
        self.FSettings.Settings.set_setting('dhcp', 'router',
                                            str(self.route.text()))
        self.FSettings.Settings.set_setting('dhcp', 'subnet',
                                            str(self.subnet.text()))
        self.FSettings.Settings.set_setting('dhcp', 'broadcast',
                                            str(self.broadcast.text()))
        self.FSettings.Settings.set_setting('dhcp', 'dns',
                                            str(self.dns.text()))
        self.FSettings.Settings.set_setting('dhcp', 'option',
                                            str(self.option.text()))
        if not str(self.route.text()) in self.all_gateway_check:
            self.FSettings.Settings.set_setting('dhcp', 'classtype', 'Custom')
        self.btnSave.setEnabled(False)
        self.writeDhcpConf()
        #self.sendMensage.emit('settings DHCP saved with success...')
        self.btnSave.setEnabled(True)

    def getPickleSettings(self):
        self.SettingsDHCP['leasetimeDef'] = str(self.leaseTime_def.text())
        self.SettingsDHCP['leasetimeMax'] = str(self.leaseTime_Max.text())
        self.SettingsDHCP['subnet'] = str(self.subnet.text())
        self.SettingsDHCP['router'] = str(self.route.text())
        self.SettingsDHCP['netmask'] = str(self.netmask.text())
        self.SettingsDHCP['broadcast'] = str(self.broadcast.text())
        self.SettingsDHCP['range'] = str(self.range_dhcp.text())
        return self.SettingsDHCP