예제 #1
0
def main(width, height, path, timeout):
    """
    @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

    with open(fname, 'r') as f:
        for ips in f:
            if ':' in ips:
                ip, port = ips.split(':')

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

        reactor.runReturn()
        app.exec_()
        return RDPScreenShotFactory.__STATE__
    f.close()
예제 #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 = QtWidgets.QApplication(sys.argv)

    #add qt5 reactor
    import qt5reactor
    qt5reactor.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__
예제 #3
0
def get_screenshot(ip, port, logdir):
    log._LOG_LEVEL = log.Level.ERROR
    app = QtGui.QApplication(sys.argv)

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

    try:
        os.mkdirs(logdir + "5_Reporting/images/")
    except:
        pass

    reactor.connectTCP(
        ip, int(port),
        RDPScreenShotFactory(
            reactor, app, 1200, 800,
            "%s/5_Reporting/images/rdp_%s_%s.jpg" % (logdir, ip, port), 7))

    try:
        reactor.runReturn(installSignalHandlers=0)
    except:
        pass
    app.exec_()

    return "%s/5_Reporting/images/rdp_%s_%s.jpg" % (logdir, ip, port)
예제 #4
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__
예제 #5
0
def main_run(target):
    """
    @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

    reactor.connectTCP(target["ip"], target["port"],
                       RDPScreenShotFactory(reactor, app, target))

    reactor.runReturn()


    app.exec_()
    return RDPScreenShotFactory.__STATE__
예제 #6
0
def main():
    log.startLogging(sys.stdout)
    parser = argparse.ArgumentParser(description="Exchange files!")
    args = parser.parse_args()
    
    # Initialize peer discovery using UDP multicast
    multiCastPort = 8006
    teiler = TeilerState()
    teiler.multiCastPort = multiCastPort
    reactor.listenMulticast(multiCastPort,
                            PeerDiscovery(teiler),
                            listenMultiple=True)
    log.msg("Initiating Peer Discovery")
    
    app = TeilerWindow(teiler)
    # Initialize file transfer service
    fileReceiver = FileReceiverFactory(teiler, app)
    reactor.listenTCP(teiler.tcpPort, fileReceiver)
    log.msg("Starting file listener on ", teiler.tcpPort)
    
    # qt4reactor requires runReturn() in order to work
    reactor.runReturn()
    
    # filetransfer.sendFile("/home/armin/tempzip.zip",port=teiler.tcpPort,address=teiler.address)
    # Create an instance of the application window and run it
    
    app.run()
예제 #7
0
파일: test.py 프로젝트: colin-zhou/reserve
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"]
예제 #8
0
파일: plugin.py 프로젝트: nmichaud/codeflow
    def start(self):
        import qt4reactor
        app = get_app_qt4()
        qt4reactor.install()

        from twisted.internet import reactor
        self.reactor = reactor
        reactor.runReturn()
예제 #9
0
    def __setup_reactor(self):

        # ought to be triggered when shutting down
        def stop():
            reactor.stop()

        reactor.runReturn()
        reactor.addSystemEventTrigger('before', 'shutdown', stop)
예제 #10
0
 def __installReactor():
     """install the twisted reactor"""
     if Internal.reactor is None:
         import qtreactor
         qtreactor.install()
         from twisted.internet import reactor
         reactor.runReturn(installSignalHandlers=False)
         Internal.reactor = reactor
         if Debug.quit:
             logDebug('Installed qtreactor')
예제 #11
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_())
예제 #12
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_())
예제 #13
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)
예제 #14
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)
예제 #15
0
def main():
    """Run application."""
    # Hook up Qt application to Twisted.
    from twisted.internet import reactor

    # Make sure stopping twisted event also shuts down QT.
    reactor.addSystemEventTrigger('after', 'shutdown', app.quit)

    # Shutdown twisted when window is closed.
    app.connect(app, QtCore.SIGNAL("lastWindowClosed()"), reactor.stop)

    # Do not block test to finish.
    reactor.runReturn()
예제 #16
0
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_()
예제 #17
0
파일: frachan.py 프로젝트: frafra/Frachan
        self.setCentralWidget(self.chat)

def main():
    """ Startup code """
    window = Window()
    window.show()
    if len(sys.argv) == 2:
        if sys.argv[1] == "server":
            factory = ServerFactory(window.chat)
            reactor.listenTCP(PORT, factory)
    else:
        factory = ClientFactory(window.chat)
        reactor.connectTCP(HOST, PORT, factory)
    window.factory = factory
예제 #18
0
파일: db.py 프로젝트: hundeboll/ticket
    def __init__(self, dbtype, host, user, pwd, winkas, ticket):

        self.dbtype = dbtype
        self.host = host
        self.port = -1
        self.user = user
        self.pwd = pwd
        self.winkas = winkas
        self.ticket = ticket
        self.timeout = 3

        self.event_id = None

        self.connect_db()
        reactor.runReturn()
예제 #19
0
def start(app):
    """
    Start the mainloop.

    :param app: the main qt QApplication instance.
    :type app: QtCore.QApplication
    """
    from twisted.internet import reactor
    logger.debug('starting twisted reactor')

    # this seems to be troublesome under some
    # unidentified settings.
    #reactor.run()

    reactor.runReturn()
    app.exec_()
예제 #20
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()
예제 #21
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()
예제 #22
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_()
예제 #23
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_()
예제 #24
0
def start_server(qapplication, condition='1', no_ui=False, max_images=None):
    """
    Start a server associated with the given qapplication and experimental condition.
    Optionally, one can start a headless server using no_ui or constraint the maximum
    number of images in a meaning space using max_images.
    :param qapplication:
    :param condition:
    :param no_ui:
    :param max_images:
    :return:
    """
    from leaparticulator.p2p.ui.server import LeapP2PServerUI

    factory = None
    assert condition in ['1', '1r', '2', '2r', 'master']
    try:
        if no_ui:
            print "Headless mode..."
            sys.stdout.flush()
            factory = get_server_instance(condition=condition,
                                          ui=None,
                                          max_images=max_images)
            if not (constants.TESTING or reactor.running):
                print "Starting reactor..."
                reactor.runReturn()
        else:
            print "Normal GUI mode..."
            sys.stdout.flush()
            ui = LeapP2PServerUI(qapplication)
            factory = get_server_instance(condition=condition,
                                          ui=ui,
                                          max_images=max_images)
            ui.setFactory(factory)
            if not (constants.TESTING or reactor.running):
                print "Starting reactor..."
                reactor.runReturn()
            ui.go()
        return factory
    except IndexError, e:
        import traceback
        traceback.print_exc()
        print "ERROR: You should specify a condition (1/2/1r/2r) as a command line argument."
        sys.exit(-1)
예제 #25
0
파일: flash.py 프로젝트: epcmatt/stlib
def main(args=None):
    app = QApplication(sys.argv)

    if args is None:
        args = sys.argv[1:]

    args = parse_args(args=args)

    if args.verbose >= 1:
        logger.setLevel(logging.DEBUG)

    if args.verbose >= 2:
        twisted.internet.defer.setDebugging(True)

    if args.verbose >= 3:
        logging.getLogger().setLevel(logging.DEBUG)

    qt5reactor.install()
    from twisted.internet import reactor

    reactor.runReturn()

    QApplication.instance().aboutToQuit.connect(about_to_quit)

    real_bus = can.interface.Bus(bustype=args.interface,
                                 channel=args.channel,
                                 bitrate=args.bitrate)
    bus = epyqlib.busproxy.BusProxy(bus=real_bus, auto_disconnect=False)

    flasher = Flasher(file=args.file, bus=bus)

    flasher.completed.connect(lambda f=flasher: completed(flasher=f))
    flasher.failed.connect(failed)
    flasher.done.connect(bus.set_bus)

    flasher.flash()

    return app.exec()
예제 #26
0
def main():
    log.startLogging(sys.stdout)
    
    config = Config(utils.getLiveInterface(),  # ip
                          9998,  # tcp port
                          utils.generateSessionID(),
                          utils.getUsername(),
                          PeerList(),
                          # udp connection information
                          '230.0.0.30',
                          8005,
                          os.path.join(os.path.expanduser("~"), "teiler"))

    reactor.listenMulticast(config.multiCastPort,
                            PeerDiscovery(
                                reactor,
                                config.sessionID,
                                config.peerList,
                                config.name,
                                config.multiCastAddress,
                                config.multiCastPort,
                                config.address,
                                config.tcpPort),
                            listenMultiple=True)

    app = Window(config)
    
    fileReceiver = FileReceiverFactory(config, app)
    reactor.listenTCP(config.tcpPort, fileReceiver)

    # Initialize file transfer service
    log.msg("Starting file listener on {0}".format(config.tcpPort))
    
    reactor.runReturn()
    
    # Create an instance of the application window and run it
    
    app.run()
예제 #27
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)

    my_initial()

    from twisted.internet import reactor
    ret = {"connected": False}
    mytimer = TimerThread(app, reactor, ret)
    mytimer.start()
    timeout = 2
    my_client = RDPClientQtFactory(width, height, username, password, domain, fullscreen, keyboardLayout, optimized, "nego", recodedPath, mytimer)
    mytimer.add_client(my_client)
    reactor.connectTCP(ip, int(port), my_client, timeout)
    reactor.runReturn()
    app.exec_()
    return ret
예제 #28
0
파일: app.py 프로젝트: subodhtirkey/FiSH
def exec_main_app():
    inst=UIController()
    inst.show()
    reactor.runReturn()
    #Somehow the reactor doesn't trigger shutdown automatically?
    exit_reactor(app.exec_())
예제 #29
0
def exec_main_app():
    inst = UIController()
    inst.show()
    reactor.runReturn()
    #Somehow the reactor doesn't trigger shutdown automatically?
    exit_reactor(app.exec_())
예제 #30
0
파일: qtpyrc.4.py 프로젝트: inhahe/qtpyrc
  config = cPickle.load(open(configpath))
else:
  config = makeconfig()

mainwin = QMainWindow()
workspace = QWorkspace()
mainwin.setCentralWidget(workspace)

menubar = mainwin.menuBar()
mnufile = menubar.addMenu('&File')
mnuclose = mnufile.addAction('&Close')
mnunew = mnufile.addMenu("&New")
mnunewserver = mnunew.addAction("&Server window")
mnunewserver.connect(mnunewserver, SIGNAL('triggered()'), newserver)

networks = set()

newserver()

mainwin.showMaximized()

identf = protocol.ServerFactory()
identf.protocol = identd
try: reactor.listenTCP(113,identf)
except:
  print "Could not run identd server."
  #todo: show it in the gui 

reactor.runReturn()
sys.exit(app.exec_())
예제 #31
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)
예제 #32
0
 def _startup(self):
     from twisted.internet import reactor
     reactor.runReturn()
     self._process.register(self._appName)
     self._process.registerModule(self._appName, self.proxy)
     self._process.listen()
예제 #33
0
 def startReactor(cls):
     reactor.runReturn()
예제 #34
0
 def _install(self):
     self._factory = ClientFactory(self._plugin)
     reactor.runReturn()
     return True
 def startReactor(cls):
     reactor.runReturn()
예제 #36
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__
예제 #37
0
def main(args=None):
    """
    Entrypoint for EPyQ. Initializes the general Qt settings, accepts some command line args,
    and sets up the main GUI window. Final thing to be spun up is the reactor from twisted
    allowing for async functionality with the otherwise single threaded UI.

    Args:
        args (Union[int, float, str], optional): [description]. Defaults to None.
        - verbose: sets the logger level
        - quit-after: sets the time for the duration of the application GUI
        - load-offline: loads only the windows in the device tree denoted as offline from the
        given UI file
    """
    print("starting epyq")

    signal.signal(signal.SIGINT, sigint_handler)

    # TODO: CAMPid 9757656124812312388543272342377
    app = QApplication(sys.argv)
    epyqlib.utils.qt.exception_message_box_register_versions(
        version_tag=epyq.__version_tag__,
        build_tag=epyq.__build_tag__,
    )
    sys.excepthook = functools.partial(
        epyqlib.utils.qt.exception_message_box, )
    QtCore.qInstallMessageHandler(epyqlib.utils.qt.message_handler)
    app.setStyleSheet(
        "QMessageBox {{ messagebox-text-interaction-flags: {}; }}".format(
            Qt.TextBrowserInteraction))
    app.setOrganizationName("EPC Power Corp.")
    app.setApplicationName("EPyQ")

    os_signal_timer = QtCore.QTimer()
    os_signal_timer.start(200)
    os_signal_timer.timeout.connect(lambda: None)

    # TODO: CAMPid 03127876954165421679215396954697
    # https://github.com/kivy/kivy/issues/4182#issuecomment-253159955
    # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError
    if "twisted.internet.reactor" in sys.modules:
        del sys.modules["twisted.internet.reactor"]

    import qt5reactor

    qt5reactor.install()

    import argparse

    ui_default = "main.ui"

    parser = argparse.ArgumentParser()
    parser.add_argument("--verbose", "-v", action="count", default=0)
    parser.add_argument("--quit-after", type=float, default=None)
    parser.add_argument("--load-offline", default=None)
    if args is None:
        args = parser.parse_args()
    else:
        args = parser.parse_args(args)

    can_logger_modules = ("can", "can.socketcan.native")

    for module in can_logger_modules:
        logging.getLogger(module).setLevel(logging.WARNING)

    if args.verbose >= 1:
        logger = logging.getLogger(__name__)
        logger.setLevel(logging.DEBUG)

    if args.verbose >= 2:
        import twisted.internet.defer

        twisted.internet.defer.setDebugging(True)

    if args.verbose >= 3:
        logging.getLogger().setLevel(logging.DEBUG)

    if args.verbose >= 4:
        logging.getLogger().setLevel(logging.INFO)
        for module in can_logger_modules:
            logging.getLogger(module).setLevel(logging.DEBUG)

    window = Window()
    epyqlib.utils.qt.exception_message_box_register_parent(parent=window)

    window.show()

    if args.quit_after:
        QtCore.QTimer.singleShot(args.quit_after * 1000, app.quit)

    if args.load_offline:

        def load_offline():
            (bus_node, ) = [
                node for node in window.ui.device_tree.model.root.children
                if node.fields.name == "Offline"
            ]

            split = args.load_offline.split("_", maxsplit=1)
            if split[0] == "test":
                path = epyqlib.tests.common.devices[split[1]]
            else:
                path = args.load_offline

            window.ui.device_tree.add_device(
                bus=bus_node,
                device=epyqlib.device.Device(
                    file=path,
                    bus=bus_node.bus,
                    node_id=247,
                ),
            )

        QtCore.QTimer.singleShot(0.5 * 1000, load_offline)

    from twisted.internet import reactor

    reactor.runReturn()
    result = app.exec()
    if reactor.threadpool is not None:
        reactor._stopThreadPool()
        logging.debug("Thread pool stopped")
    logging.debug("Application ended")
    reactor.stop()
    logging.debug("Reactor stopped")

    # TODO: this should be sys.exit() but something keeps the process
    #       from terminating.  Ref T679  Ref T711
    os._exit(result)
    def __init__(self, appName = 'example', checkRoom = None, suggest = False, options=None):
        splash = None

        FXUI.app = QtGui.QApplication(sys.argv)
        FXUI.app.setApplicationName("wallaby - " + appName)

        for s in ['16', '32', '64', '128', '256']:
            FXUI.app.setWindowIcon(QtGui.QIcon(QtGui.QPixmap(':/icons/images/wallaby_logo_' + s + '.png')))

        pixmap = QtGui.QPixmap(":/images/images/wallaby_splash.png")
        splash = QtGui.QSplashScreen(pixmap)
        splash.show()
        splash.raise_()
        FXUI.app.processEvents()

        if USES_PYSIDE or FXUI.qt4reactor:
            print "Install qt4reactor. USES_PYSIDE =", USES_PYSIDE
            import wallaby.frontends.qt.reactor.qt4reactor as qtreactor
            qtreactor.install()
        else:
            threadedselect.install()
             
            from twisted.internet import reactor
            ii = Interleaver()
            reactor.interleave(ii.toInterleave)
            reactor.suggestThreadPoolSize(50)

        FXUI.mineIcon = QtGui.QIcon(':/icons/images/mine.png')
        FXUI.theirsIcon = QtGui.QIcon(':/icons/images/theirs.png')

        tapp = twisted.application.service.Application("gui")
        service  = FXLogger('wallaby.log')
        service.setServiceParent(tapp)
        service.startService()

        FX.appModule = 'wallaby.apps.' + appName

        try:
            from twisted.plugin import getCache
            pkg = __import__(FX.appModule, globals(), locals(), ["*"], 0)
            if pkg is not None and len(pkg.__path__) > 0 and os.path.exists(pkg.__path__[0]):
                FX.appPath = pkg.__path__[0]
            else:
                FX.appPath = os.path.join(".", "wallaby", "apps", appName)
        except:
            FX.appPath = os.path.join(".", "wallaby", "apps", appName)

        FXUI.css = None

        try:
            print "importing", options.module, "from", FX.appModule
            if options.module == "WallabyApp2" and os.path.exists(os.path.join(FX.appPath, "mainWindow.py")):
                mod = FX.imp(FX.appModule + '.mainWindow', False)
                if os.path.exists(os.path.join(FX.appPath, "mainWindow.css")):
                    FXUI.css = open(os.path.join(FX.appPath, "mainWindow.css")).read()
            else:
                module = options.module
                module = module[0].lower() + module[1:]
                mod = FX.imp(FX.appModule + '.' + module, False)

                if os.path.exists(os.path.join(FX.appPath, module + ".css")):
                    FXUI.css = open(os.path.join(FX.appPath, module + ".css")).read()
        except:
            mod = None

        if mod == None:
            FX.crit('Module', FX.appModule, 'not found')
            reactor.callWhenRunning(self.myQuit)
            if USES_PYSIDE or FXUI.qt4reactor: reactor.runReturn()
            FXUI.app.exec_()
            return

        try:
            FXUI.mainWindow = mod.MainWindow(self.myQuit, options)
            if FXUI.css is not None:
                FXUI.app.setStyle("plastique")
                FXUI.mainWindow.setStyleSheet(FXUI.css)
        except Exception as e:
            import traceback
            traceback.print_exc(file=sys.stdout)

            from twisted.internet import reactor
            reactor.callWhenRunning(self.myQuit)
            if USES_PYSIDE or FXUI.qt4reactor: reactor.runReturn()
            FXUI.app.exec_()
            return

        FXUI.mainWindow.setSplash(splash)

        from twisted.internet import reactor
        reactor.callWhenRunning(self.run, mod, options, checkRoom)

        FXUI.mainWindow.enabled = False
        FXUI.mainWindow.configure()
        FXUI.mainWindow.show()
        FXUI.mainWindow.raise_()

        signal.signal(signal.SIGINT, self.sigint_handler)
        signal.signal(signal.SIGTERM, self.sigint_handler)

        # self.gc = GarbageCollector(FXUI.mainWindow, True)

        if USES_PYSIDE or FXUI.qt4reactor: reactor.runReturn()
        FXUI.app.exec_()
예제 #39
0
파일: __main__.py 프로젝트: bsberry/st
def main(args=None):
    print('starting epyq')

    signal.signal(signal.SIGINT, sigint_handler)

    # TODO: CAMPid 9757656124812312388543272342377
    app = QApplication(sys.argv)
    epyqlib.utils.qt.exception_message_box_register_versions(
        version_tag=epyq.__version_tag__,
        build_tag=epyq.__build_tag__,
    )
    sys.excepthook = functools.partial(
        epyqlib.utils.qt.exception_message_box, )
    QtCore.qInstallMessageHandler(epyqlib.utils.qt.message_handler)
    app.setStyleSheet(
        'QMessageBox {{ messagebox-text-interaction-flags: {}; }}'.format(
            Qt.TextBrowserInteraction))
    app.setOrganizationName('EPC Power Corp.')
    app.setApplicationName('EPyQ')

    os_signal_timer = QtCore.QTimer()
    os_signal_timer.start(200)
    os_signal_timer.timeout.connect(lambda: None)

    # TODO: CAMPid 03127876954165421679215396954697
    # https://github.com/kivy/kivy/issues/4182#issuecomment-253159955
    # fix for pyinstaller packages app to avoid ReactorAlreadyInstalledError
    if 'twisted.internet.reactor' in sys.modules:
        del sys.modules['twisted.internet.reactor']

    import qt5reactor
    qt5reactor.install()

    import argparse

    ui_default = 'main.ui'

    parser = argparse.ArgumentParser()
    parser.add_argument('--verbose', '-v', action='count', default=0)
    parser.add_argument('--quit-after', type=float, default=None)
    parser.add_argument('--load-offline', default=None)
    if args is None:
        args = parser.parse_args()
    else:
        args = parser.parse_args(args)

    can_logger_modules = ('can', 'can.socketcan.native')

    for module in can_logger_modules:
        logging.getLogger(module).setLevel(logging.WARNING)

    if args.verbose >= 1:
        logger = logging.getLogger(__name__)
        logger.setLevel(logging.DEBUG)

    if args.verbose >= 2:
        import twisted.internet.defer
        twisted.internet.defer.setDebugging(True)

    if args.verbose >= 3:
        logging.getLogger().setLevel(logging.DEBUG)

    if args.verbose >= 4:
        logging.getLogger().setLevel(logging.INFO)
        for module in can_logger_modules:
            logging.getLogger(module).setLevel(logging.DEBUG)

    window = Window()
    epyqlib.utils.qt.exception_message_box_register_parent(parent=window)

    window.show()

    if args.quit_after is not None:
        QtCore.QTimer.singleShot(args.quit_after * 1000, app.quit)

    if args.load_offline is not None:

        def load_offline():
            bus_node, = [
                node for node in window.ui.device_tree.model.root.children
                if node.fields.name == 'Offline'
            ]

            split = args.load_offline.split('_', maxsplit=1)
            if split[0] == 'test':
                path = epyqlib.tests.common.devices[split[1]]
            else:
                path = args.load_offline

            window.ui.device_tree.add_device(
                bus=bus_node,
                device=epyqlib.device.Device(
                    file=path,
                    bus=bus_node.bus,
                    node_id=247,
                ),
            )

        QtCore.QTimer.singleShot(0.5 * 1000, load_offline)

    from twisted.internet import reactor
    reactor.runReturn()
    result = app.exec()
    if reactor.threadpool is not None:
        reactor._stopThreadPool()
        logging.debug('Thread pool stopped')
    logging.debug('Application ended')
    reactor.stop()
    logging.debug('Reactor stopped')

    # TODO: this should be sys.exit() but something keeps the process
    #       from terminating.  Ref T679  Ref T711
    os._exit(result)
예제 #40
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 cli_parsed.web:
            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 cli_parsed.web:
        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 range(num_threads):
            targets.put(None)
        try:
            workers = [
                Process(
                    target=worker_thread,
                    args=(
                        cli_parsed,
                        targets,
                        lock,
                        (multi_counter,
                         multi_total))) for i in range(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.items():
                        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.items():
                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 range(num_threads):
                    targets.put(None)
                workers = [Process(target=worker_thread,
                                   args=(cli_parsed, targets, lock,
                                         (multi_counter, multi_total),
                                         (browser, ua)))
                           for i in range(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
예제 #41
0
            recodedPath = arg

    if ':' in args[0]:
        ip, port = args[0].split(':')
    else:
        ip, port = args[0], "3389"

    # create application
    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

    reactor.connectTCP(
        ip, int(port),
        RDPClientQtFactory(width, height, username, password, domain,
                           fullscreen, keyboardLayout, optimized, "nego",
                           recodedPath))
    reactor.runReturn()
    app.exec_()
예제 #42
0
    initLog('kajongg')

    ABOUT = About()
    KCmdLineArgs.init (sys.argv, ABOUT.about)
    KCmdLineArgs.addCmdLineOptions(defineOptions())
    KApplication.setGraphicsSystem('raster')
    APP = KApplication()
    parseOptions()

    if Debug.events:
        EVHANDLER = EvHandler()
        APP.installEventFilter(EVHANDLER)

    from config import SetupPreferences
    SetupPreferences()

    import qt4reactor
    qt4reactor.install()
    from twisted.internet import reactor
    reactor.runReturn(installSignalHandlers=False) # pylint: disable=E1101
    # pylint thinks reactor is missing runReturn
    Internal.reactor = reactor

    if Options.gui:
        from playfield import PlayField
        PlayField().show()
    else:
        from humanclient import HumanClient
        HumanClient()
    Internal.app.exec_()