Example #1
0
def main():
	print ('Receptor de Senales de Alarma Version 1.65')
	Lic = LicCheck()
	if Lic == True:
		if Modo != None:
			t = threading.Thread(target=AvisodeApertura,args=[Lic])
			t.setDaemon(False)
			t.start()

			#AvisodeApertura(Lic)
			app = QApplication(sys.argv)
			import qt4reactor
			qt4reactor.install()
			from twisted.internet import reactor
			#app.setStyle(QStyleFactory.create("plastique"))
			w = MainWindow(reactor)
			#Retornamos en BD 'No hay BD' en caso de que no se consiga la BD
			#Si el receptor esta en MODO de BD. Para que no muestre nunca la 
			#Ventana.

			bd = w.IniciarReceptores()
			w.show()
			a = Remote(w)
			a.Iniciar()
			if bd == 'No hay BD':
				pass
			else:

				reactor.run()
				#sys.exit(app.exec_())

	else:
		AvisodeApertura(Lic)
		pass
Example #2
0
def main(width, height, path, timeout, hosts):
    """
    @summary: main algorithm
    @param height: {integer} height of screenshot
    @param width: {integer} width of screenshot
    @param timeout: {float} in sec
    @param hosts: {list(str(ip[:port]))}
    @return: {list(tuple(ip, port, Failure instance)} list of connection state
    """
    #create application
    app = QtGui.QApplication(sys.argv)
    
    #add qt4 reactor
    import qt4reactor
    qt4reactor.install()
    
    from twisted.internet import reactor
        
    for host in hosts:      
        if ':' in host:
            ip, port = host.split(':')
        else:
            ip, port = host, "3389"
            
        reactor.connectTCP(ip, int(port), RDPScreenShotFactory(reactor, app, width, height, path + "%s.jpg"%ip, timeout))
        
    reactor.runReturn()
    app.exec_()
    return RDPScreenShotFactory.__STATE__
Example #3
0
def install_qtreactor():
    global qtapp

    from PyQt4.QtGui import QApplication
    qtapp = QApplication(sys.argv)
    import qt4reactor
    qt4reactor.install()
Example #4
0
def main():
    app = QtGui.QApplication(sys.argv)
    qt4reactor.install() # requires QApplication to exist
    ex = MainWindow() # requires qt4reactor to be installed
    # late import because installReactor is being used
    from twisted.internet import reactor
    reactor.run()
Example #5
0
def main():
    dut_address = None
    playback_filename = None
    developer_menu = False
    if '-p' in sys.argv:
        f_index = sys.argv.index('-p')
        playback_filename = sys.argv[f_index + 1]
        del sys.argv[f_index:f_index + 2]
    if '-v' in sys.argv:
        sys.argv.remove('-v')
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig()
    if '-d' in sys.argv:
        developer_menu = True
        sys.argv.remove('-d')
    if len(sys.argv) > 1:
        dut_address = sys.argv[1]
    app = QtGui.QApplication(sys.argv)
    qt4reactor.install() # requires QApplication to exist
    # requires qt4reactor to be installed
    ex = MainWindow(dut_address, playback_filename, developer_menu)
    # late import because installReactor is being used
    from twisted.internet import reactor
    reactor.run()
Example #6
0
def mytest(ip, port, username, password):
    domain = ""
    width = 1024
    height = 800
    fullscreen = False
    optimized = False
    recodedPath = None
    keyboardLayout = 'en'
    app = QtGui.QApplication(sys.argv)

    #add qt4 reactor
    import qt4reactor
    qt4reactor.install()

    if fullscreen:
        width = QtGui.QDesktopWidget().screenGeometry().width()
        height = QtGui.QDesktopWidget().screenGeometry().height()

    log.info("keyboard layout set to %s"%keyboardLayout)

    from twisted.internet import reactor
    ret = {"connected": False}
    mytimer = TimerThread(app, reactor, ret)
    mytimer.start()

    reactor.connectTCP(ip, int(port), RDPClientQtFactory(width, height, username, password, domain, fullscreen, keyboardLayout, optimized, "nego", recodedPath, mytimer))
    reactor.runReturn()
    app.exec_()
    return ret["connected"]
Example #7
0
    def __init__(self, args):
        from deluge import configmanager

        self.ui_config = configmanager.ConfigManager("qtui.conf", self.default_ui_config)

#        if self.ui_config["style"] and '-style' not in args:
#            QtGui.QApplication.setStyle(self.ui_config["style"])
        app = QtGui.QApplication(args, applicationName="Deluge", quitOnLastWindowClosed=False)

        import qt4reactor
        qt4reactor.install()
        from twisted.internet import reactor

        self.locale_dir = pkg_resources.resource_filename("deluge", "i18n")

        from ui_tools import IconLoader
        app.setWindowIcon(IconLoader.themeIcon("deluge"))
        self.ui_config.register_set_function("language", self.on_language_change, apply_now=True)

        from .tracker_icons import TrackerIcons
        from deluge.ui.sessionproxy import SessionProxy
        from .connection_manager import ConnectionManager
        from .main_window import MainWindow
        from .plugin_manager import PluginManager

        TrackerIcons()
        SessionProxy()
        PluginManager()
        connection_manager = ConnectionManager()
        main_window = MainWindow()
        main_window.show()

        app.aboutToQuit.connect(self.on_quit)
        reactor.callLater(0, connection_manager.first_time)
        reactor.run() # calls app.exec_()
Example #8
0
def install_qtreactor(verbose):
    global qtapp

    from twisted.python import log
    from PyQt4.QtGui import QApplication
    from PyQt4.QtCore import QAbstractEventDispatcher

    class QApp(QApplication):

        blockedAt = 0

        def __init__(self, *args):
            super(QApp, self).__init__(*args)
            if verbose:
                disp = QAbstractEventDispatcher.instance()
                disp.aboutToBlock.connect(self.aboutToBlock)
                disp.awake.connect(self.awake)

        def aboutToBlock(self):
            self.blockedAt = time.time()
            log.msg("aboutToBlock", system="QAbstractEventDispatcher")

        def awake(self):
            diff = time.time() - self.blockedAt
            log.msg("awake; block time: %0.4f" % diff, system="QAbstractEventDispatcher")

    qtapp = QApp(sys.argv)
    import qt4reactor
    qt4reactor.install()
Example #9
0
    def start(self):
        import qt4reactor
        app = get_app_qt4()
        qt4reactor.install()

        from twisted.internet import reactor
        self.reactor = reactor
        reactor.runReturn()
Example #10
0
def main():
    app = QCoreApplication.instance()
    if app == None:
        app = KinectPlanes(sys.argv)
        qt4reactor.install()
        from twisted.internet import reactor
        app.set_reactor(reactor)
    sys.exit(app.start())
Example #11
0
 def __init__(self, appName):
     QApplication.__init__(self, sys.argv)
     if self._initialized:
         return
     qt4reactor.install()
     OTPApplication._appName = appName
     OTPApplication._nodeName = buildNodeName(self._appName, randomize=True)
     OTPApplication._process = twotp.Process(self._nodeName, self._cookie)
     QTimer.singleShot(0, self._startup)
     OTPApplication._initialized = True
Example #12
0
def main():
    if '-v' in sys.argv:
        sys.argv.remove('-v')
        logging.basicConfig(level=logging.DEBUG)
    app = QtGui.QApplication(sys.argv)
    qt4reactor.install() # requires QApplication to exist
    ex = MainWindow() # requires qt4reactor to be installed
    # late import because installReactor is being used
    from twisted.internet import reactor
    reactor.run()
Example #13
0
 def runQtGui(self):
     import qt4reactor
     from PyQt4.QtGui import QApplication
     app = QApplication(sys.argv)
     qt4reactor.install()
     from .gui import SimulatorWidget
     win = SimulatorWidget()
     win.setWindowTitle("Simulador Profile: %s" % self.profile.name)
     win.add_di()
     win.show()
     return app.exec_()
Example #14
0
def main(args):
    app = Qt.QApplication(args)
    
    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    import labrad, labrad.util, labrad.types
    
    demo = make()
    reactor.runReturn()
    sys.exit(app.exec_())
Example #15
0
def main(args):
    app = Qt.QApplication(args)

    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor

    reactor.runReturn()
    demo = make()
    v = app.exec_()
    reactor.threadpool.stop()
    sys.exit(v)
Example #16
0
def install_reactor():
    # https://github.com/ghtdak/qtreactor/issues/21
    # from qtreactor import pyside4reactor as reactor
    # from qtreactor import qt4reactor as reactor
    import sys
    if 'qt4reactor' in sys.modules:
        print "qt4reactor already in sys.modules!!"
    if 'twisted.internet.reactor' not in sys.modules:
        import qt4reactor
        qt4reactor.install()
        print "Installed qt4reactor"
    else:
        from twisted.internet import reactor
        print "Reactor already installed: %s" % reactor
def capture_host(cli_parsed, vnc_object):
    log._LOG_LEVEL = log.Level.ERROR
    app = QtGui.QApplication(sys.argv)

    # add qt4 reactor
    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    reactor.connectTCP(
        vnc_object.remote_system, vnc_object.port, RFBScreenShotFactory(
            vnc_object.screenshot_path, reactor, app, vnc_object))

    reactor.runReturn()
    app.exec_()
Example #18
0
def run():
    app = QtGui.QApplication(sys.argv)
    app.setApplicationName('l3_client_qt')
    connDialog = ConnectionDialog()
    connDialog.exec_()
    if connDialog.result() == QtGui.QDialog.Accepted:
        factory = Client()
        main = GUI(factory)
        import qt4reactor
        qt4reactor.install()
        from twisted.internet import reactor
        main.show()
        reactor.connectTCP(connDialog.getHost(), connDialog.getPort(), factory)
        reactor.run()
Example #19
0
def main():
    """Main function"""
    app = QtGui.QApplication(sys.argv)
    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor

    if len(sys.argv) > 1 and sys.argv[1] == "-t":
        interface = terminal.TerminalInterface()
        stdio.StandardIO(interface)
    else:
        interface = gui.GuiInterface()
    server = Server.Server(reactor, interface)
    interface.start(server)
    reactor.runReturn()
    app.exec_()
    reactor.stop()
Example #20
0
def capture_host(cli_parsed, rdp_object):
    log._LOG_LEVEL = log.Level.ERROR
    width = 1200
    height = 800
    timeout = cli_parsed.timeout

    app = QtGui.QApplication(sys.argv)

    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor

    reactor.connectTCP(
        rdp_object.remote_system, int(rdp_object.port), RDPScreenShotFactory(
            reactor, app, width, height,
            rdp_object.screenshot_path, timeout, rdp_object))

    reactor.runReturn()
    app.exec_()
Example #21
0
def main():
    global reactor
    app = Stabilizer()

    # Set up twisted events
    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    ## print all loaded modules:
    reactor.addSystemEventTrigger('before', 'shutdown', reactor.stop)
    app.start_sending()
    app.start_listening()
    # Create gui
    main_window = MainWindow(app)
    main_window.show()
    # main_window.start_or_stop_listening(True)
    # start event loop
    app.exec_()
    app.settings.save()
Example #22
0
def main():
    name = None
    if '-v' in sys.argv:
        sys.argv.remove('-v')
        logging.basicConfig(level=logging.DEBUG)
    if '-d' in sys.argv:
        d_index = sys.argv.index('-d')
        name = sys.argv[d_index + 1]
        del sys.argv[d_index:d_index + 2]
    app = QtGui.QApplication(sys.argv)
    qt4reactor.install() # requires QApplication to exist
    # requires qt4reactor to be installed
    if name:
        ex = MainWindow(open(name, 'wb'))
    else:
        ex = MainWindow()
    # late import because installReactor is being used
    from twisted.internet import reactor
    reactor.run()
Example #23
0
def install_qtreactor(verbose):
    init_qt_app(verbose)
    import qt4reactor
    qt4reactor.install()
Example #24
0
import sys
from PyQt4 import QtGui, QtScript
from PyQt4.QtCore import QTimer, SIGNAL
import qt4reactor

app = QtGui.QApplication(sys.argv)
qt4reactor.install(app)

from twisted.internet import reactor, task
from twisted.python import log
log.startLogging(sys.stdout)


def testReactor():
    print 'tick...'


def buttonClick():
    print 'click...'
    reactor.iterate(5.0)
    print 'click return'


engine = QtScript.QScriptEngine()

button = QtGui.QPushButton()
scriptButton = engine.newQObject(button)
engine.globalObject().setProperty("button", scriptButton)

app.connect(button, SIGNAL("clicked()"), buttonClick)
Example #25
0
from twisted.internet.protocol import Factory, Protocol
from sys import stdout
from PyQt4 import QtCore, QtGui
import qt4reactor
from test import*
import sys
import time
app=QtGui.QApplication(['test'])
GUI=Swan_Server()
GUI.show()
reactor=qt4reactor.install()
string=""
class User:

	def __init__(self):
		self.users_list=[]
		self.log=open("log.txt",'a')

	def addUser(self,user_name,stat,avtr,tp):
		self.users_list.append((user_name,tp,stat,avtr))			##username,transport and status message is appended to users_list
		GUI.textBrowser_2.append("new user logined in -> "+user_name)

	def removeUser(self,name):						##called to remove user from users_list
		GUI.textBrowser_2.append(name+" : loged out ")	
		temp=[]
		for i in self.users_list:
			if i[0]!=name:
				temp.append(i)
		self.users_list=temp						##refreshed users_list
	def names(self):
		lis=[]
Example #26
0
def main():
    app = QtGui.QApplication(sys.argv)
    qt4reactor.install()
    from twisted.internet import reactor
    clientWindow = ClientWindow(reactor)
    reactor.run()
Example #27
0
def install_qtreactor(verbose):
    init_qt_app(verbose)
    import qt4reactor
    qt4reactor.install()
Example #28
0
    def makeControlWidget(self, reactor):
        from barium.lib.clients.TrapControl_client.TrapControl_client import TrapControlClient
        control = TrapControlClient(reactor)
        return control

    def makeFrequencyWidget(self, reactor):
        from barium.lib.clients.FrequencyControl_client.FrequencyControl_client import FrequencyControlClient
        frequency = FrequencyControlClient(reactor)
        return frequency

    def makePMTCameraSwitchWidget(self, reactor):
        from barium.lib.clients.PMTCameraSwitch_client.PMTCameraSwitch_client import PMTCameraSwitchClient
        switch = PMTCameraSwitchClient(reactor)
        return switch

    def closeEvent(self, x):
        self.reactor.stop()

if __name__ == "__main__":
    a = QtGui.QApplication(sys.argv)
    clipboard = a.clipboard()
    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    BariumGUI = BARIUM_GUI(reactor, clipboard)
    BariumGUI.setWindowIcon(
        QtGui.QIcon('C:/Users/barium133/Code/barium/BARIUM_IONS.png'))
    BariumGUI.setWindowTitle('Barium GUI')
    BariumGUI.show()
    reactor.run()
Example #29
0
def main(width, height, ssColorPath, ssGrayPath, pwnedPath, timeout, targetFile, trainingModel, hosts):
    """
    @summary: main algorithm
    @param height: {integer} height of screenshot
    @param width: {integer} width of screenshot
    @param timeout: {float} in sec
    @param hosts: {list(str(ip[:port]))}
    @return: {list(tuple(ip, port, Failure instance)} list of connection state
    """
    #create application
    app = QtGui.QApplication(sys.argv)

    #add qt4 reactor
    import qt4reactor
    qt4reactor.install()

    from twisted.internet import reactor

    targetList = []

    if targetFile != "":
        for line in open(targetFile):
            targetList = [line.rstrip('\n') for line in open(targetFile)]
        print targetList
    # If there was no input list
    else:
        for host in hosts:
            targetList.append(host)

    for host in targetList:
        if ':' in host:
            ip, port = host.split(':')
        else:
            ip, port = host, "3389"

        reactor.connectTCP(ip, int(port), RDPScreenShotFactory(reactor, app, width, height, ssColorPath + "%s.jpg"%ip, ssGrayPath + "%s_gray.jpg"%ip, timeout))

    reactor.runReturn()
    app.exec_()

    # Create hacked directory if not already exists
    if not os.path.exists(ssColorPath + "/" + pwnedPath):
        os.mkdir(ssColorPath + "/" + pwnedPath)
        print "Directory " + pwnedPath + " created."
    if not os.path.exists(ssGrayPath + "/" + pwnedPath):
        os.mkdir(ssGrayPath + "/" + pwnedPath)
        print "Directory " + pwnedPath + " created."

    classifier = load(trainingModel)

    Xlist2 = []
    grayFileName = ssGrayPath + "%s_gray.jpg"%ip
    try:
        img2=Image.open(grayFileName)
        featurevector2=numpy.array(img2).flatten()
        Xlist2.append(featurevector2)
        img2.close()

        predicted = classifier.predict(Xlist2)

        for prediction in predicted:
            if str(prediction) == "hacked":
                print "Result:" + str(ip) + ":" + Fore.RED + str(prediction) + Style.RESET_ALL
                os.rename(grayFileName, ssGrayPath + "/" + pwnedPath + "/%s_gray.jpg"%ip)
                os.rename(ssColorPath + "/%s.jpg"%ip, ssColorPath + "/" + pwnedPath + "/%s.jpg"%ip)
            else:
                print "Result:" + str(ip) + ":" + Fore.GREEN + str(prediction) + Style.RESET_ALL
    except:
        log.info("Something went wrong with the screenshot")

    return RDPScreenShotFactory.__STATE__
Example #30
0
#    channels <- points to parent Client instance's channels. just for convenience.
#    queries <- points to parent Client instance's queries.  just for convenience.
#    nickname <- nickname currently being used.  this member is automatically used (and changed? i dunno..) by twisted.words.protocols.irc
#
#  Script instances
#    module <- the script's entire module
#    script <- the script module's running Script() instance

from PyQt4.QtGui import *
from PyQt4.QtCore import *

import sys, qt4reactor, re, cPickle, os, types
import traceback

if __name__ == "__main__":
    qt4reactor.install()  # why don't i need this?

from optparse import OptionParser
from twisted.internet import protocol, reactor
from twisted.words.protocols import irc


class Config:
    pass


mirccolors = [
    Qt.white,
    Qt.black,
    Qt.darkBlue,
    Qt.darkGreen,
Example #31
0
def run(*args, **kw):
    """
    Call with::

      [-d, <description>,] [-N, <values>,]
      [-o, <imageFile>,]
      [-g,] [-s,]
      Nx, cr, ci, crPM, [ciPM]

    Writes PNG image to stdout unless -o is set, then saves it to
    C{imageFile}. In that case, prints some stats about the
    multiprocessing computation to stdout.

    Options-as-arguments:
    
      - B{d}: An endpoint I{description} of a server running a
        L{wire.server}.

      - B{s}: Show image (B{TODO})

    @keyword N_values: Integer number of possible values for
      Mandelbrot points during iteration. Can set with the C{-N
      values} arg instead.
    
    @keyword ignoreReactor: Set C{True} to let somebody else start and
      stop the reactor.
    """
    @defer.inlineCallbacks
    def reallyRun():
        if description:
            myRunner = wire.RemoteRunner(description)
            yield myRunner.setup(N_values=N_values)
        else:
            myRunner = runner.Runner(N_values, stats)
        runInfo = yield myRunner.run(fh, Nx, cr, ci, crPM, ciPM)
        if stats:
            yield myRunner.showStats(runInfo)
        yield myRunner.shutdown()
        if not ignoreReactor:
            reactor.stop()
        defer.returnValue(runInfo)

    def getOpt(opt, default=None):
        optCode = "-{}".format(opt)
        if optCode in args:
            k = args.index(optCode)
            args.pop(k)
            if default is None:
                return
            optType = type(default)
            return optType(args.pop(k))
        return default

    ignoreReactor = kw.pop('ignoreReactor', False)
    if not args:
        args = sys.argv[1:]
    args = list(args)
    show = getOpt('s')
    N_values = getOpt('N', 2000)
    fileName = getOpt('o', "")
    description = getOpt('d', "")
    useGUI = getOpt('g')
    if fileName:
        stats = True
        fh = open(fileName, 'w')
    else:
        stats = False
        fh = sys.stdout
    if len(args) < 4:
        print(
            "Usage: [-N values] "+\
            "[-o imageFile] [-d description] [-g] [-s] " +\
            "N cr ci crPM [ciPM]")
        sys.exit(1)
    Nx = int(args[0])
    cr, ci, crPM = [float(x) for x in args[1:4]]
    ciPM = float(args[4]) if len(args) > 4 else crPM
    if useGUI:
        raise NotImplementedError("GUI not yet implemented")
        # TODO
        from PyQt4 import QtGui
        import qt4reactor
        import gui
        app = QtGui.QApplication(sys.argv)
        qt4reactor.install()
        w = gui.MainWindow(Nx, cr, ci, crPM)
        reactor.run()
    elif ignoreReactor:
        return reallyRun()
    else:
        reactor.callWhenRunning(reallyRun)
        reactor.run()
Example #32
0
    def twisted__init__(self):
        import qt4reactor

        qt4reactor.install()

        from twisted.internet import reactor
        from twisted.internet.protocol import ServerFactory
        from twisted.protocols.basic import LineReceiver

        self.PORT=2424
        self.reactor=reactor
        core=self

        class Client(object):
            def __init__(self,name):
                self.id=str(uuid.uuid4())
                self.name=name
                self.ip=name

            def onConnect(self):
                self.item=core.api.exMethod('main','addListItem','%s connected\n[%s]' % (self.name,self.id),icon='client')
                self.item.plugin='main'
                core.clients[self.id]=self

            def refresh(self):
                self.item.setText('%s connected\n%s' % (self.name,self.ip))

        class ChatProtocol(LineReceiver):

            name = ""

            def sendLine(self, line):
                self.transport.write(line.encode('utf-8')+"\r\n")

            def getName(self):
                if self.name!="":
                    return self.name
                return self.transport.getPeer().host

            def new(self):
                self.factory.sendMessageToAllClients('{"sign":"new","args":[{"uid":"%s","name":"%s","ip":"%s","coord":"%s"}]}' % (self.client.id,self.client.name,self.client.ip,self.client.coord))

            def m_move(self,x,y):
                self.client.coord=(int(x),int(y))
                self.factory.sendMessageToAllClients('{"sign":"p_move","args":[{"uid":"%s","coord":"%s"}]}' % (self.client.id,self.client.coord))
            def uid(self):
                self.sendLine('{"sign":"uid","args":["%s"]}' % self.client.id)

            def sendList(self):
                cllist=[]
                for client in core.clients:
                    client=core.clients[client]
                    cllist.append({"uid":client.id,"name":client.name,"ip":client.ip,"coord":str(client.coord)})

                self.sendLine('{"sign":"list","args":%s}' % cllist)

            def connectionMade(self):
                core.api.info("New connection from "+self.getName())
                self.client=Client(self.getName())
                self.client.protocol=self
                self.sendLine("Welcome to Nightgleam server.")
                reactor.callLater(1, self.uid)
                reactor.callLater(2, self.new)
                reactor.callLater(3, self.sendList)
                self.factory.clientProtocols.append(self)
                self.client.onConnect()


            def connectionLost(self, reason):
                self.factory.clientProtocols.remove(self)
                core.api.exMethod('main','removeItem',self.client.item)
                self.factory.sendMessageToAllClients('{"sign":"left","args":["%s"]}' % self.client.id)
                del core.clients[self.client.id]

            def lineReceived(self, line):
                core.api.info(self.getName()+" said "+line)
#                line=re.findall('([^ ]*)',line)
                line=json.loads(line)
                ln=line['sign']
                args=line['args']

                for arg in args:
                    if not arg:
                        args.remove(arg)
                try:
                    m=core.app.getMethod('main',ln)
                    try:
                        m(*args)
                    except:
                        m(self,*args)
                    core.app['debug']('Remote execution: %s (%s)' % (m.func_name,args))
                except Exception,e:
                    core.app['error']('%s: %s' %(m,e))
                    self.sendLine("Wrong command.")


            def m_name(self,name,coord):
                self.name = name
                self.client.name = name
                self.client.coord=coord
                self.client.refresh()
                self.new()

            def m_q(self):
                self.transport.loseConnection()
                self.factory.sendMessageToAllClients('{"sign":"left","args":["%s"]}' % self.client.id)
Example #33
0
def main():
    app = QtGui.QApplication(sys.argv)
    qt4reactor.install()
    from twisted.internet import reactor
    clientWindow = ClientWindow(reactor)
    reactor.run()
Example #34
0
def multi_mode(cli_parsed):
    dbm = db_manager.DB_Manager(cli_parsed.d + '/ew.db')
    dbm.open_connection()
    if not cli_parsed.resume:
        dbm.initialize_db()
    dbm.save_options(cli_parsed)
    m = Manager()
    targets = m.Queue()
    lock = m.Lock()
    multi_counter = m.Value('i', 0)
    display = None

    def exitsig(*args):
        dbm.close()
        if current_process().name == 'MainProcess':
            print ''
            print 'Resume using ./EyeWitness.py --resume {0}'.format(cli_parsed.d + '/ew.db')
        os._exit(1)

    signal.signal(signal.SIGINT, exitsig)
    if cli_parsed.resume:
        pass
    else:
        url_list, rdp_list, vnc_list = target_creator(cli_parsed)
        if any((cli_parsed.web, cli_parsed.headless)):
            for url in url_list:
                dbm.create_http_object(url, cli_parsed)
        for rdp in rdp_list:
            dbm.create_vnc_rdp_object('rdp', rdp, cli_parsed)
        for vnc in vnc_list:
            dbm.create_vnc_rdp_object('vnc', vnc, cli_parsed)

    if any((cli_parsed.web, cli_parsed.headless)):
        if cli_parsed.web and not cli_parsed.show_selenium:
            display = Display(visible=0, size=(1920, 1080))
            display.start()

        multi_total = dbm.get_incomplete_http(targets)
        if multi_total > 0:
            if cli_parsed.resume:
                print 'Resuming Web Scan ({0} Hosts Remaining)'.format(str(multi_total))
            else:
                print 'Starting Web Requests ({0} Hosts)'.format(str(multi_total))

        if multi_total < cli_parsed.threads:
            num_threads = multi_total
        else:
            num_threads = cli_parsed.threads
        for i in xrange(num_threads):
            targets.put(None)
        try:
            workers = [Process(target=worker_thread, args=(
                cli_parsed, targets, lock, (multi_counter, multi_total))) for i in xrange(num_threads)]
            for w in workers:
                w.start()
            for w in workers:
                w.join()
        except Exception as e:
            print str(e)

        # Set up UA table here
        if cli_parsed.cycle is not None:
            ua_dict = get_ua_values(cli_parsed.cycle)
            if not cli_parsed.ua_init:
                dbm.clear_table("ua")
                completed = dbm.get_complete_http()
                completed[:] = [x for x in completed if x.error_state is None]
                for item in completed:
                    for browser, ua in ua_dict.iteritems():
                        dbm.create_ua_object(item, browser, ua)

                cli_parsed.ua_init = True
                dbm.clear_table("opts")
                dbm.save_options(cli_parsed)

            for browser, ua in ua_dict.iteritems():
                targets = m.Queue()
                multi_counter.value = 0
                multi_total = dbm.get_incomplete_ua(targets, browser)
                if multi_total > 0:
                    print("[*] Starting requests for User Agent {0}"
                          " ({1} Hosts)").format(browser, str(multi_total))
                if multi_total < cli_parsed.threads:
                    num_threads = multi_total
                else:
                    num_threads = cli_parsed.threads
                for i in xrange(num_threads):
                    targets.put(None)
                workers = [Process(target=worker_thread,
                                   args=(cli_parsed, targets, lock,
                                         (multi_counter, multi_total),
                                         (browser, ua)))
                           for i in xrange(num_threads)]
                for w in workers:
                    w.start()
                for w in workers:
                    w.join()

    if any((cli_parsed.vnc, cli_parsed.rdp)):
        log._LOG_LEVEL = log.Level.ERROR
        multi_total, targets = dbm.get_incomplete_vnc_rdp()
        if multi_total > 0:
            print ''
            print 'Starting VNC/RDP Requests ({0} Hosts)'.format(str(multi_total))

            app = QtGui.QApplication(sys.argv)
            timer = QTimer()
            timer.start(10)
            timer.timeout.connect(lambda: None)

            # add qt4 reactor
            import qt4reactor
            qt4reactor.install()
            from twisted.internet import reactor

            for target in targets:
                if os.path.dirname(cli_parsed.d) != os.path.dirname(target.screenshot_path):
                    target.set_paths(cli_parsed.d)
                tdbm = db_manager.DB_Manager(cli_parsed.d + '/ew.db')
                if target.proto == 'vnc':
                    reactor.connectTCP(
                        target.remote_system, target.port,
                        vnc_module.RFBScreenShotFactory(
                            target.screenshot_path, reactor, app,
                            target, tdbm))
                else:
                    reactor.connectTCP(
                        target.remote_system, int(target.port),
                        rdp_module.RDPScreenShotFactory(
                            reactor, app, 1200, 800,
                            target.screenshot_path, cli_parsed.timeout,
                            target, tdbm))
            reactor.runReturn()
            app.exec_()

    if display is not None:
        display.stop()
    results = dbm.get_complete_http()
    vnc_rdp = dbm.get_complete_vnc_rdp()
    dbm.close()
    m.shutdown()
    write_vnc_rdp_data(cli_parsed, vnc_rdp)
    sort_data_and_write(cli_parsed, results)
Example #35
0
def multi_mode(cli_parsed):
    dbm = db_manager.DB_Manager(cli_parsed.d + '/ew.db')
    dbm.open_connection()
    if not cli_parsed.resume:
        dbm.initialize_db()
    dbm.save_options(cli_parsed)
    m = Manager()
    targets = m.Queue()
    lock = m.Lock()
    multi_counter = m.Value('i', 0)
    display = None

    def exitsig(*args):
        dbm.close()
        if current_process().name == 'MainProcess':
            print ''
            print 'Resume using ./EyeWitness.py --resume {0}'.format(
                cli_parsed.d + '/ew.db')
        os._exit(1)

    signal.signal(signal.SIGINT, exitsig)
    if cli_parsed.resume:
        pass
    else:
        url_list, rdp_list, vnc_list = target_creator(cli_parsed)
        if any((cli_parsed.web, cli_parsed.headless)):
            for url in url_list:
                dbm.create_http_object(url, cli_parsed)
        for rdp in rdp_list:
            dbm.create_vnc_rdp_object('rdp', rdp, cli_parsed)
        for vnc in vnc_list:
            dbm.create_vnc_rdp_object('vnc', vnc, cli_parsed)

    if any((cli_parsed.web, cli_parsed.headless)):
        if cli_parsed.web and not cli_parsed.show_selenium:
            display = Display(visible=0, size=(1920, 1080))
            display.start()

        multi_total = dbm.get_incomplete_http(targets)
        if multi_total > 0:
            if cli_parsed.resume:
                print 'Resuming Web Scan ({0} Hosts Remaining)'.format(
                    str(multi_total))
            else:
                print 'Starting Web Requests ({0} Hosts)'.format(
                    str(multi_total))

        if multi_total < cli_parsed.threads:
            num_threads = multi_total
        else:
            num_threads = cli_parsed.threads
        for i in xrange(num_threads):
            targets.put(None)
        try:
            workers = [
                Process(target=worker_thread,
                        args=(cli_parsed, targets, lock, (multi_counter,
                                                          multi_total)))
                for i in xrange(num_threads)
            ]
            for w in workers:
                w.start()
            for w in workers:
                w.join()
        except Exception as e:
            print str(e)

        # Set up UA table here
        if cli_parsed.cycle is not None:
            ua_dict = get_ua_values(cli_parsed.cycle)
            if not cli_parsed.ua_init:
                dbm.clear_table("ua")
                completed = dbm.get_complete_http()
                completed[:] = [x for x in completed if x.error_state is None]
                for item in completed:
                    for browser, ua in ua_dict.iteritems():
                        dbm.create_ua_object(item, browser, ua)

                cli_parsed.ua_init = True
                dbm.clear_table("opts")
                dbm.save_options(cli_parsed)

            for browser, ua in ua_dict.iteritems():
                targets = m.Queue()
                multi_counter.value = 0
                multi_total = dbm.get_incomplete_ua(targets, browser)
                if multi_total > 0:
                    print(
                        "[*] Starting requests for User Agent {0}"
                        " ({1} Hosts)").format(browser, str(multi_total))
                if multi_total < cli_parsed.threads:
                    num_threads = multi_total
                else:
                    num_threads = cli_parsed.threads
                for i in xrange(num_threads):
                    targets.put(None)
                workers = [
                    Process(target=worker_thread,
                            args=(cli_parsed, targets, lock,
                                  (multi_counter, multi_total), (browser, ua)))
                    for i in xrange(num_threads)
                ]
                for w in workers:
                    w.start()
                for w in workers:
                    w.join()

    if any((cli_parsed.vnc, cli_parsed.rdp)):
        log._LOG_LEVEL = log.Level.ERROR
        multi_total, targets = dbm.get_incomplete_vnc_rdp()
        if multi_total > 0:
            print ''
            print 'Starting VNC/RDP Requests ({0} Hosts)'.format(
                str(multi_total))

            app = QtGui.QApplication(sys.argv)
            timer = QTimer()
            timer.start(10)
            timer.timeout.connect(lambda: None)

            # add qt4 reactor
            import qt4reactor
            qt4reactor.install()
            from twisted.internet import reactor

            for target in targets:
                if os.path.dirname(cli_parsed.d) != os.path.dirname(
                        target.screenshot_path):
                    target.set_paths(cli_parsed.d)
                tdbm = db_manager.DB_Manager(cli_parsed.d + '/ew.db')
                if target.proto == 'vnc':
                    reactor.connectTCP(
                        target.remote_system, target.port,
                        vnc_module.RFBScreenShotFactory(
                            target.screenshot_path, reactor, app, target,
                            tdbm))
                else:
                    reactor.connectTCP(
                        target.remote_system, int(target.port),
                        rdp_module.RDPScreenShotFactory(
                            reactor, app, 1200, 800, target.screenshot_path,
                            cli_parsed.timeout, target, tdbm))
            reactor.runReturn()
            app.exec_()

    if display is not None:
        display.stop()
    results = dbm.get_complete_http()
    vnc_rdp = dbm.get_complete_vnc_rdp()
    dbm.close()
    m.shutdown()
    write_vnc_rdp_data(cli_parsed, vnc_rdp)
    sort_data_and_write(cli_parsed, results)
    if cli_parsed.ocr:
        for target in targets:
            try:
                rdp_module.parse_screenshot(cli_parsed.d, target)
            except IOError:
                pass
Example #36
0
import sys
from PyQt4 import QtGui, QtScript
from PyQt4.QtCore import QTimer, SIGNAL
import qt4reactor

app = QtGui.QApplication(sys.argv)
qt4reactor.install(app)

from twisted.internet import reactor, task
from twisted.python import log
log.startLogging(sys.stdout)

def testReactor():
    print 'tick...'

def buttonClick():
    print 'click...'
    reactor.iterate(5.0)
    print 'click return'
    
engine = QtScript.QScriptEngine()

button = QtGui.QPushButton()
scriptButton = engine.newQObject(button)
engine.globalObject().setProperty("button", scriptButton)

app.connect(button, SIGNAL("clicked()"), buttonClick)

engine.evaluate("button.text = 'Hello World!'")
engine.evaluate("button.styleSheet = 'font-style: italic'")
engine.evaluate("button.show()")
class CONNECTIONS(QtGui.QGraphicsObject):
    def __init__(self, reactor, parent=None):
        super(CONNECTIONS, self).__init__()
        self.reactor = reactor
        self.dwDict = {} # dictionary relating Dataset and ApplicationWindow
        self.connect()
        self.startTimer()
        self.introWindow = FirstWindow(self)
        self.introWindow.show()

    # connect to the data vault    
    @inlineCallbacks    
    def connect(self):
        from labrad.wrappers import connectAsync
        from labrad.types import Error
        self.cxn = yield connectAsync()
        self.server = yield self.cxn.data_vault
        yield self.setupListeners()
    
    # set up dataset listener    
    @inlineCallbacks
    def setupListeners(self):               
        yield self.server.signal__new_dataset(99999)#, context = context)
        yield self.server.addListener(listener = self.updateDataset, source = None, ID = 99999)#, context = context)
        yield self.cxn.data_vault.cd(DIRECTORY)
        
    # new dataset signal
    def updateDataset(self,x,y):
        dataset = int(y[1:5])
        self.newDataset(dataset)
 
    # Creates a new dataset and gives it an ID for identifying later (Overlaying)
    @inlineCallbacks
    def newDataset(self, dataset):
        context = yield self.cxn.context()
        datasetObject = Dataset(self.cxn, context, dataset)
        yield datasetObject.openDataset()
        answer = yield datasatObjcet.waitforparameter()
        if answer:
            pass
        else:
            #datasetObject.close()
            #del(datasetObject)
        #subscribe to signal
        #create a new one shot timer
        
        
        #if windows request the overlay, update those. else, create a new window.
        overlayWindows = self.getOverlayingWindows()
        if overlayWindows:
            self.dwDict[datasetObject] = overlayWindows
            for window in overlayWindows:
                window.qmc.initializeDataset(dataset)
        else:
            win = self.newGraph(dataset, context)
            #yield win.doneMaking
            self.dwDict[datasetObject] = [win]
            win.qmc.initializeDataset(dataset)
            #del(indep)
            #win.qmc.setPlotParameters()
            #win.qmc.refreshPlots()
            
    def startTimer(self): 
        lc = LoopingCall(self.timerEvent)
        lc.start(GraphRefreshTime)
        
    @inlineCallbacks
    def timerEvent(self):
#        newDataWindows = set()
        for datasetObject in self.dwDict.keys():
        # stuff you want timed goes here
            if (datasetObject.data != None):
                #print self.datasetObject.data
                windowsToDrawOn = self.dwDict[datasetObject]
                data = datasetObject.data
                yield datasetObject.emptyDataBuffer()
                for i in windowsToDrawOn:
                    i.qmc.setPlotData(datasetObject.dataset, data)
        
        
##                    newDataWindows.add((i,datasetObject.dataset))
#        for window,dataset in newDataWindows:
#            window.qmc.drawPlot(dataset)
#        windowlist = set()
#        for l in self.dwDict.values():
#            for window in l:
#                windowlist.add(window)
#        noDataWindows = windowlist.difference(newDataWindows)
#        for window in noDataWindows:
#            window.qmc.refreshPlot()

    
    # create a new graph, also sets up a Window ID so that if a graph...
    # ... asks for plot Overlay, it can be id
    def newGraph(self, dataset, context):
        win = ApplicationWindow(self.cxn, context, dataset)
        win.show()
        #time.sleep(2)
        return win
    
    # Cycles through the values in each key for checked Overlay boxes, returns the windows...
    # ...with the overlay button checked
    def getOverlayingWindows(self):
        self.overlaidWindows = []
        for i in self.dwDict.keys():
            values = self.dwDict[i]
            for j in values:
                if j.cb2.isChecked():
                    # skip duplicates
                    if j in self.overlaidWindows:
                        pass
                    else:
                        self.overlaidWindows.append(j)
        return self.overlaidWindows
                     
if __name__ == '__main__':
    a = QtGui.QApplication( [] )
    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    Connections = CONNECTIONS(reactor)
    reactor.run()
Example #38
0
        yield self.server.addListener(listener=self.followSignal, source=None, ID=SIGNALID)

    def followSignal(self, x, (switchName, state)):
        button = self.d["Switches"][switchName]
        button.setChecked(state)
        self.setButtonText(button, switchName)

    def setButtonText(self, button, prefix):
        if button.isChecked():
            button.setText("{} is ON".format(prefix))
        else:
            button.setText("{} is OFF".format(prefix))

    def closeEvent(self, x):
        self.reactor.stop()

    def sizeHint(self):
        return QtCore.QSize(100, 100)


if __name__ == "__main__":
    a = QtGui.QApplication([])
    import qt4reactor

    qt4reactor.install()
    from twisted.internet import reactor

    triggerWidget = triggerWidget(reactor)
    triggerWidget.show()
    reactor.run()
Example #39
0
    def function1(self):
        print 'do something'

    @inlineCallbacks
    def function2(self):
        yield print 'do something asynchronous'
    '''

    def closeEvent(self, x):
        '''
        This function is run upon the GUI being closed all cleanup should be done here such as stopping the reactor
        '''
        self.reactor.stop()  #stops the reactor


if __name__ == "__main__":
    '''
    This is the function that gets run first if the client python file is run directly, however if this client is imported by another function
    this function will not be run
    '''
    a = QtGui.QApplication(
        [])  #Creates a GUI structure and can take sys arguments
    import qt4reactor  #imports the PyQt4 reactor that must be integrated with twisted reactor (this must happen here)
    qt4reactor.install()  #installs the pyqt4 reactor
    from twisted.internet import reactor  # imports the twisted reactor
    client_shellWidget = client_shell(
        reactor)  #instantiates a widget with the just imported reactor
    client_shellWidget.show()  #shows the widget
    reactor.run()  #runs the integrated reactor