コード例 #1
0
class ProcessThread(QObject):
    _ProcssOutput = pyqtSignal(object)

    def __init__(
        self,
        cmd,
    ):
        QObject.__init__(self)
        self.cmd = cmd

    def getNameThread(self):
        return '[New Thread {} ({})]'.format(self.procThread.pid(),
                                             self.objectName())

    @pyqtSlot()
    def readProcessOutput(self):
        self.data = str(self.procThread.readAllStandardOutput())
        self._ProcssOutput.emit(self.data)

    def start(self):
        self.procThread = QProcess(self)
        self.procThread.setProcessChannelMode(QProcess.MergedChannels)
        QObject.connect(self.procThread, SIGNAL('readyReadStandardOutput()'),
                        self, SLOT('readProcessOutput()'))
        self.procThread.start(self.cmd.keys()[0], self.cmd[self.cmd.keys()[0]])
        print '[New Thread {} ({})]'.format(self.procThread.pid(),
                                            self.objectName())

    def stop(self):
        print 'Thread::[{}] successfully stopped.'.format(self.objectName())
        if hasattr(self, 'procThread'):
            self.procThread.terminate()
            self.procThread.waitForFinished()
            self.procThread.kill()
コード例 #2
0
ファイル: threads.py プロジェクト: ihebski/WiFi-Pumpkin
class ProcessThread(QObject):
    _ProcssOutput = pyqtSignal(object)
    def __init__(self,cmd,):
        QObject.__init__(self)
        self.cmd = cmd

    def getNameThread(self):
        return '[New Thread {} ({})]'.format(self.procThread.pid(),self.objectName())

    @pyqtSlot()
    def readProcessOutput(self):
        self.data = str(self.procThread.readAllStandardOutput())
        self._ProcssOutput.emit(self.data)

    def start(self):
        self.procThread = QProcess(self)
        self.procThread.setProcessChannelMode(QProcess.MergedChannels)
        QObject.connect(self.procThread, SIGNAL('readyReadStandardOutput()'), self, SLOT('readProcessOutput()'))
        self.procThread.start(self.cmd.keys()[0],self.cmd[self.cmd.keys()[0]])
        print '[New Thread {} ({})]'.format(self.procThread.pid(),self.objectName())

    def stop(self):
        print 'Thread::[{}] successfully stopped.'.format(self.objectName())
        if hasattr(self,'procThread'):
            self.procThread.terminate()
            self.procThread.waitForFinished()
            self.procThread.kill()
コード例 #3
0
ファイル: threads.py プロジェクト: laykatz/WiFi-Pumpkin
class ProcessHostapd(QObject):
    statusAP_connected = pyqtSignal(object)
    def __init__(self,cmd):
        QObject.__init__(self)
        self.cmd = cmd

    def getNameThread(self):
        return '[New Thread {} ({})]'.format(self.procHostapd.pid(),self.objectName())

    @pyqtSlot()
    def read_OutputCommand(self):
        self.data = str(self.procHostapd.readAllStandardOutput())
        if 'AP-STA-DISCONNECTED' in self.data.rstrip() or 'inactivity (timer DEAUTH/REMOVE)' in self.data.rstrip():
            self.statusAP_connected.emit(self.data.split()[2])

    def start(self):
        self.makeLogger()
        self.procHostapd = QProcess(self)
        self.procHostapd.setProcessChannelMode(QProcess.MergedChannels)
        QObject.connect(self.procHostapd, SIGNAL('readyReadStandardOutput()'), self, SLOT('read_OutputCommand()'));
        self.procHostapd.start(self.cmd.keys()[0],self.cmd[self.cmd.keys()[0]])
        print '[New Thread {} ({})]'.format(self.procHostapd.pid(),self.objectName())

    def makeLogger(self):
        setup_logger('hostapd', './Logs/AccessPoint/requestAP.log')
        self.log_hostapd = logging.getLogger('hostapd')

    def stop(self):
        print 'Thread::[{}] successfully stopped.'.format(self.objectName())
        if hasattr(self,'procHostapd'):
            self.procHostapd.terminate()
            self.procHostapd.waitForFinished()
            self.procHostapd.kill()
コード例 #4
0
class ProcessHostapd(QObject):
    statusAP_connected = pyqtSignal(object)
    statusAPError = pyqtSignal(object)

    def __init__(self, cmd, session):
        QObject.__init__(self)
        self.cmd = cmd
        self.session = session
        self.errorAPDriver = ('AP-DISABLED', 'Failed to initialize interface',
                              'nl80211 driver initialization failed.',
                              'errors found in configuration file')

    def getNameThread(self):
        return '[New Thread {} ({})]'.format(self.procHostapd.pid(),
                                             self.objectName())

    @pyqtSlot()
    def read_OutputCommand(self):
        self.data = str(self.procHostapd.readAllStandardOutput())
        if 'AP-STA-DISCONNECTED' in self.data.rstrip(
        ) or 'inactivity (timer DEAUTH/REMOVE)' in self.data.rstrip():
            self.statusAP_connected.emit(self.data.split()[2])
        self.log_hostapd.info(self.data)
        for error in self.errorAPDriver:
            if self.data.find(error) != -1:
                return self.statusAPError.emit(self.data)

    def start(self):
        self.makeLogger()
        self.procHostapd = QProcess(self)
        self.procHostapd.setProcessChannelMode(QProcess.MergedChannels)
        QObject.connect(self.procHostapd, SIGNAL('readyReadStandardOutput()'),
                        self, SLOT('read_OutputCommand()'))
        self.procHostapd.start(self.cmd.keys()[0],
                               self.cmd[self.cmd.keys()[0]])
        print '[New Thread {} ({})]'.format(self.procHostapd.pid(),
                                            self.objectName())

    def makeLogger(self):
        setup_logger('hostapd', C.LOG_HOSTAPD, self.session)
        self.log_hostapd = logging.getLogger('hostapd')

    def stop(self):
        print 'Thread::[{}] successfully stopped.'.format(self.objectName())
        if hasattr(self, 'procHostapd'):
            QObject.disconnect(self.procHostapd,
                               SIGNAL('readyReadStandardOutput()'), self,
                               SLOT('read_OutputCommand()'))
            self.procHostapd.terminate()
            self.procHostapd.waitForFinished()
            self.procHostapd.kill()
コード例 #5
0
ファイル: threads.py プロジェクト: ihebski/WiFi-Pumpkin
class ProcessHostapd(QObject):
    statusAP_connected = pyqtSignal(object)
    statusAPError = pyqtSignal(object)
    def __init__(self,cmd,session):
        QObject.__init__(self)
        self.cmd         = cmd
        self.session     = session
        self.errorAPDriver = ('AP-DISABLED',
        'Failed to initialize interface',
        'nl80211 driver initialization failed.',
        'errors found in configuration file')

    def getNameThread(self):
        return '[New Thread {} ({})]'.format(self.procHostapd.pid(),self.objectName())

    @pyqtSlot()
    def read_OutputCommand(self):
        self.data = str(self.procHostapd.readAllStandardOutput())
        if 'AP-STA-DISCONNECTED' in self.data.rstrip() or 'inactivity (timer DEAUTH/REMOVE)' in self.data.rstrip():
            self.statusAP_connected.emit(self.data.split()[2])
        self.log_hostapd.info(self.data)
        for error in self.errorAPDriver:
            if self.data.find(error) != -1:
                return self.statusAPError.emit(self.data)

    def start(self):
        self.makeLogger()
        self.procHostapd = QProcess(self)
        self.procHostapd.setProcessChannelMode(QProcess.MergedChannels)
        QObject.connect(self.procHostapd, SIGNAL('readyReadStandardOutput()'), self, SLOT('read_OutputCommand()'));
        self.procHostapd.start(self.cmd.keys()[0],self.cmd[self.cmd.keys()[0]])
        print '[New Thread {} ({})]'.format(self.procHostapd.pid(),self.objectName())

    def makeLogger(self):
        setup_logger('hostapd', './logs/AccessPoint/hostapd.log',self.session)
        self.log_hostapd = logging.getLogger('hostapd')

    def stop(self):
        print 'Thread::[{}] successfully stopped.'.format(self.objectName())
        if hasattr(self,'procHostapd'):
            QObject.disconnect(self.procHostapd,
            SIGNAL('readyReadStandardOutput()'), self, SLOT('read_OutputCommand()'))
            self.procHostapd.terminate()
            self.procHostapd.waitForFinished()
            self.procHostapd.kill()
コード例 #6
0
ファイル: threads.py プロジェクト: leoshan/WiFi-Pumpkin
class ProcessHostapd(QObject):
    statusAP_connected = pyqtSignal(object)

    def __init__(self, cmd, session):
        QObject.__init__(self)
        self.cmd = cmd
        self.session = session

    def getNameThread(self):
        return '[New Thread {} ({})]'.format(self.procHostapd.pid(),
                                             self.objectName())

    @pyqtSlot()
    def read_OutputCommand(self):
        self.data = str(self.procHostapd.readAllStandardOutput())
        if 'AP-STA-DISCONNECTED' in self.data.rstrip(
        ) or 'inactivity (timer DEAUTH/REMOVE)' in self.data.rstrip():
            self.statusAP_connected.emit(self.data.split()[2])
        self.log_hostapd.info(self.data)

    def start(self):
        self.makeLogger()
        self.procHostapd = QProcess(self)
        self.procHostapd.setProcessChannelMode(QProcess.MergedChannels)
        QObject.connect(self.procHostapd, SIGNAL('readyReadStandardOutput()'),
                        self, SLOT('read_OutputCommand()'))
        self.procHostapd.start(self.cmd.keys()[0],
                               self.cmd[self.cmd.keys()[0]])
        print '[New Thread {} ({})]'.format(self.procHostapd.pid(),
                                            self.objectName())

    def makeLogger(self):
        setup_logger('hostapd', './Logs/AccessPoint/hostapd.log', self.session)
        self.log_hostapd = logging.getLogger('hostapd')

    def stop(self):
        print 'Thread::[{}] successfully stopped.'.format(self.objectName())
        if hasattr(self, 'procHostapd'):
            self.procHostapd.terminate()
            self.procHostapd.waitForFinished()
            self.procHostapd.kill()
コード例 #7
0
class Kitty(QObject):
    """manage kitty process (terminals)"""
    exe_name = 'kitty'
    DELAY = 150

    def __init__(self,
                 ip,
                 port,
                 protocol,
                 name,
                 log_path,
                 window_title,
                 log_name,
                 parent=None):
        QObject.__init__(self, parent)
        self.ip = ip
        self.port = port
        self.protocol = protocol
        self.log_path = log_path
        self.log_name = log_name
        self.id = str(os.getpid()) + name
        self.window_title = window_title
        self.terminal = QProcess()
        self.terminal.finished.connect(self.close)
        self.terminal.stateChanged.connect(self.state)
        self.send_process = QProcess()
        self.send_process.finished.connect(self.end_send)

    def open(self):
        """ kitty -telnet -P 9696 hostname """
        if self.terminal.state() == QProcess.Running:
            return
        file_name = utils.set_log_name(self.log_name,
                                       self.log_path,
                                       ext='.txt')
        args = [
            '-{}'.format(self.protocol), self.ip, '-P', self.port, '-log',
            os.path.join(self.log_path, file_name), '-title',
            self.window_title, '-classname', self.id
        ]
        while self.terminal.state() == QProcess.NotRunning:
            self.terminal.start(os.path.join(dep_dir, Kitty.exe_name), args)
            self.terminal.waitForStarted()
            QThread.msleep(Kitty.DELAY)

    def send(self, text):
        if self.send_process.state() == QProcess.Running:
            self.send_process.close()
        self.show_terminal()
        args = ['-classname', self.id, '-sendcmd', text]
        self.send_process.start(os.path.join(dep_dir, Kitty.exe_name), args)
        self.send_process.waitForStarted()
        self.send_process.waitForFinished()
        QThread.msleep(Kitty.DELAY)

    def show_terminal(self):
        if self.terminal.state() == QProcess.NotRunning:
            return
        autowin.show_window(autowin.get_qprocess_pid(self.terminal.pid()))
        QThread.msleep(Kitty.DELAY)

    @staticmethod
    def show_main():
        autowin.show_window(os.getpid())

    def end_send(self):
        pass

    def close(self):
        self.terminal.close()

    def state(self, st):
        print(st)