Example #1
0
def main():

    yara_object = YaraObject("yaraconnector")

    yara_object.set_feed_info(name="Yara",
                     summary="Scan binaries collected by Carbon Black with Yara.",
                     tech_data="There are no requirements to share any data with Carbon Black to use this feed.",
                     provider_url="http://plusvic.github.io/yara/",
                     icon_path="yara-logo.png",
                     display_name="Yara")

    yara_object.start()
    #rpc interface to the rpcinterface in cbrprcinterface.py
    server = SimpleXMLRPCServer(('0.0.0.0', 9002),
                            requestHandler=RequestHandler)
    server.register_introspection_functions()
    server.register_instance(yara_object)

    try:
            # Run the server's main loop
        server.serve_forever()
    except BaseException as bae:
        logger.debug("Yara eror {}".format(str(e)))
    finally:
        yara_object.stop()
def handle_server(server):
    print('Server RPC di 127.0.0.1 di port 6667')

    server.register_function(add_pasien, "add_pasien")
    server.register_function(get_pasien, "get_pasien")

    server.serve_forever()
def _start_de_server(server):
    """Start the DE server and listen forever"""
    try:
        server.get_logger().info("running _start_de_server")

        server.get_logger().debug(
            "running _start_de_server: step reaper_start")
        server.reaper_start(delay=server.global_config["dataspace"].get(
            "reaper_start_delay_seconds", 1818))

        server.get_logger().debug(
            "running _start_de_server: step start_channels")
        server.start_channels()

        server.get_logger().debug(
            "running _start_de_server: step startup_complete")
        server.startup_complete.set()

        server.get_logger().debug(
            "running _start_de_server: step serve_forever")
        server.serve_forever()

        server.get_logger().debug("done with _start_de_server")
    except Exception as __e:  # pragma: no cover
        msg = f"""Server Address: {server.global_config.get('server_address')}
              Fatal Error: {__e}"""
        print(msg, file=sys.stderr)

        with contextlib.suppress(Exception):
            server.get_logger().error(msg)

        raise __e
def run_xmlrpcserver(pipe_conn, port):
    server = xmlrpc.server.SimpleXMLRPCServer(('', port),
                                              requestHandler=_RequestHandler,
                                              allow_none=True)
    server.register_introspection_functions()
    server.register_instance(XMLRPCServer(pipe_conn))
    server.serve_forever()
Example #5
0
def main():
    """Main."""
    winutils.exit_if_admin()

    script_name = os.path.basename(sys.argv[0])  # in case it is full path
    script_name_no_ext = os.path.splitext(script_name)[0]

    log_filename = "%s.log" % (script_name_no_ext,)
    format = ("%(asctime)s %(name)s %(levelname)s : %(message)s")

    logging.basicConfig(format=format,
                        filename=log_filename,
                        filemode='w',
                        level=logging.DEBUG)

    print("Starting PTS ...")
    pts = PyPTSWithXmlRpcCallback()
    print("OK")

    print("Serving on port {} ...".format(SERVER_PORT))

    server = xmlrpc.server.SimpleXMLRPCServer(("", SERVER_PORT), allow_none=True)
    server.register_instance(pts)
    server.register_introspection_functions()
    server.serve_forever()
Example #6
0
def listen(use_new_keys=False):
    """
  Listens on TIMESERVER_PORT for xml-rpc calls to functions:
   - get_signed_time(nonces)
  """

    # Set the timeserver's signing key.
    print('Loading timeserver signing key.')
    timeserver.set_timeserver_key(load_timeserver_key(use_new_keys))
    print('Timeserver signing key loaded.')

    # Create server
    server = xmlrpc.server.SimpleXMLRPCServer(
        (demo.TIMESERVER_HOST, demo.TIMESERVER_PORT),
        requestHandler=RequestHandler)  #, allow_none=True)
    #server.register_introspection_functions()

    # Add a function to the Timeserver's xml-rpc interface.
    # Register function that can be called via XML-RPC, allowing a Primary to
    # request the time for its Secondaries.
    server.register_function(timeserver.get_signed_time, 'get_signed_time')
    server.register_function(timeserver.get_signed_time_ber,
                             'get_signed_time_ber')

    print('Timeserver will now listen on port ' + str(demo.TIMESERVER_PORT))
    server.serve_forever()
Example #7
0
def main():
    """Main."""
    winutils.exit_if_admin()

    script_name = os.path.basename(sys.argv[0])  # in case it is full path
    script_name_no_ext = os.path.splitext(script_name)[0]

    log_filename = "%s.log" % (script_name_no_ext, )
    format = ("%(asctime)s %(name)s %(levelname)s : %(message)s")

    logging.basicConfig(format=format,
                        filename=log_filename,
                        filemode='w',
                        level=logging.DEBUG)

    c = wmi.WMI()
    for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=True):
        print("Local IP address: %s DNS %r" %
              (iface.IPAddress, iface.DNSDomain))

    print("Starting PTS ...")
    pts = PyPTSWithXmlRpcCallback()
    print("OK")

    print("Serving on port {} ...".format(SERVER_PORT))

    server = xmlrpc.server.SimpleXMLRPCServer(("", SERVER_PORT),
                                              allow_none=True)
    server.register_instance(pts)
    server.register_introspection_functions()
    server.serve_forever()
Example #8
0
def serve():
    container_number = int(sys.argv[1])
    port_number = int(sys.argv[2])
    server = xmlrpc.server.SimpleXMLRPCServer(("0.0.0.0", port_number), allow_none=True)
    print("Container", container_number, "Listening on port", port_number, "...")
    server.register_function(Predict, "Predict")
    server.serve_forever()
Example #9
0
def serve():
    container_number = int(sys.argv[1])  # first argument
    port_number = int(sys.argv[2])  # second argument
    server = xmlrpc.server.SimpleXMLRPCServer(("0.0.0.0", port_number))
    print("Container", container_number, "Listening on port", port_number,
          "...")
    server.register_function(Predict, "Predict")
    server.serve_forever()
Example #10
0
	def getsensorCO():
		for i in range(0, len(sensor)):
	        if sensor[i]["topik"] == "sensor/suhu":
	            return json.dumps(sensor[i])

	server.register_function(getAllsensor, 'getAllsensor')
	server.register_function(getsensorsuhu, 'getsensorsuhu')
	server.register_function(getsensorkelembaban, 'getsensorkelembaban')
	server.register_function(getsensorCO, 'getsensorCO')
	server.serve_forever()            
Example #11
0
def main(port=8000, address='', quiet=False):
    'if __name__ == __main__'
    with Server((address, port), xmlrpc.server.SimpleXMLRPCRequestHandler,
                not quiet) as server:
        server.register_function(judge)
        if not quiet:
            print('Serving XML-RPC on', address or 'localhost', 'port', port)
        try:
            server.serve_forever()
        except KeyboardInterrupt:
            print()
            if not quiet:
                print("Keyboard interrupt received, exiting.")
def main():
    host, port, notify = handle_commandline()
    manager, server = setup(host, port)
    print("Meter server startup at  {} on {}:{}{}".format(
        datetime.datetime.now().isoformat()[:19], host, port, PATH))
    try:
        if notify:
            with open(notify, "wb") as file:
                file.write(b"\n")
        server.serve_forever()
    except KeyboardInterrupt:
        print("\rMeter server shutdown at {}".format(
            datetime.datetime.now().isoformat()[:19]))
        manager._dump()
Example #13
0
def main():
    host, port, notify = handle_commandline()
    manager, server = setup(host, port)
    print("Meter server startup at  {} on {}:{}{}".format(
            datetime.datetime.now().isoformat()[:19], host, port, PATH))
    try:
        if notify:
            with open(notify, "wb") as file:
                file.write(b"\n")
        server.serve_forever()
    except KeyboardInterrupt:
        print("\rMeter server shutdown at {}".format(
                datetime.datetime.now().isoformat()[:19]))
        manager._dump()
Example #14
0
def main():
    # FIXME: that needs to be determined properly
    host = '127.0.0.1'
    port = 8081

    server = xmlrpc.server.SimpleXMLRPCServer((host, port))

    server.register_instance(GameServer('Nowhere'))

    logging.info("MUD serving at enpoint http://{0}:{1}/".format(host, port))
    logging.info("Press Ctrl-C to stop")

    try:
        server.serve_forever()
    except KeyboardInterrupt:
        logging.info("Stopped")
Example #15
0
def serve():
    """Starts a server listening for Slaves requesting or submitting work"""

    def get_work_pickled(cores_max):
        return tuple(map(pickle.dumps, get_work(cores_max)))

    def submit_work_pickled(*args):
        submit_work(*tuple(map(pickle.loads, args)))
        return True
    # pickling over xml over rpc, yeah
    # we need to pickle because xmlrpcserver only understands few types
    # Dunno if this server can serve multiple requests concurrently
    server = xmlrpc.server.SimpleXMLRPCServer(("kirk.zulan.net", 8000), use_builtin_types=True)
    print("Listening on port 8000...")
    server.register_function(get_work_pickled, "get_work_pickled")
    server.register_function(submit_work_pickled, "submit_work_pickled")
    server.serve_forever()
Example #16
0
 def main():

    """Main program; parse options and go."""

    try:

        opts, args = getopt.getopt(sys.argv[1:], 'hd:p:o:')

    except getopt.error as msg:

        usage(2, msg)

    options = Options.options

    for opt, arg in opts:

        if opt == '-h':

            usage(0)

        elif opt == '-o':

            options.set_from_cmdline(arg, sys.stderr)

    dbname, usedb = storage.database_type(opts)

    if len(args) != 1:

        usage(2, "IP:PORT not specified")

    ip, port = args[0].split(":")

    port = int(port)

    bayes = storage.open_storage(dbname, usedb)

    h = XMLHammie(bayes)

    server = ReusableSimpleXMLRPCServer(
        (ip, port),
        xmlrpc.server.SimpleXMLRPCRequestHandler)

    server.register_instance(h)

    server.serve_forever()
Example #17
0
def _start_de_server(global_config, channel_config_loader):
    '''Create and start the DE server with the passed global configuration and config manager'''
    try:
        server = _create_de_server(global_config, channel_config_loader)
        server.reaper_start(delay=global_config['dataspace'].get(
            'reaper_start_delay_seconds', 1818))
        server.start_channels()
        server.serve_forever()
    except Exception as e:  # pragma: no cover
        msg = f"""Server Address: {global_config.get('server_address')}
              Fatal Error: {e}"""
        print(msg, file=sys.stderr)

        try:
            server.get_logger().error(msg)
        except Exception:
            pass

        raise e
Example #18
0
def main():
    global master_host
    global master_port
    global zk
    global group_infos
    print("INFO: I am the primary master now!")
    master_setup()
    get_servers()
    with ThreadXMLRPCServer((master_host, master_port)) as server:
        server.register_multicall_functions()
        server.register_instance(masterRPC())
        print("INFO: Master booted on http://{}:{}".format(
            master_host, master_port))
        try:
            server.serve_forever()
        except KeyboardInterrupt:
            zk.stop()
            print("\nKeyboard interrupt received, exiting.")
            exit(0)
Example #19
0
def _start_de_server(server):
    '''Start the DE server and listen forever'''
    try:
        server.reaper_start(delay=server.global_config['dataspace'].get(
            'reaper_start_delay_seconds', 1818))
        server.start_channels()
        server.startup_complete.set()
        server.serve_forever()
    except Exception as __e:  # pragma: no cover
        msg = f"""Server Address: {server.global_config.get('server_address')}
              Fatal Error: {__e}"""
        print(msg, file=sys.stderr)

        try:
            server.get_logger().error(msg)
        except Exception:  # pragma: no cover
            pass

        raise __e
Example #20
0
def _start_de_server(server):
    """Start the DE server and listen forever"""
    try:
        server.get_logger().info("running _start_de_server")

        server.get_logger().debug(
            "running _start_de_server: step reaper_start")
        server.reaper_start(delay=server.global_config["dataspace"].get(
            "reaper_start_delay_seconds", 1818))

        server.get_logger().debug(
            "running _start_de_server: step start_channels")
        server.start_channels()

        if not server.global_config.get("no_webserver"):
            # cherrypy for metrics
            server.get_logger().debug(
                "running _start_de_server: step start_webserver (metrics)")
            server.start_webserver()

        server.get_logger().debug(
            "running _start_de_server: step startup_complete")
        server.startup_complete.set()

        server.get_logger().debug(
            "running _start_de_server: step serve_forever")
        server.serve_forever()

        server.get_logger().debug("done with _start_de_server")
    except Exception as __e:  # pragma: no cover
        msg = f"""Server Address: {server.global_config.get('server_address')}
              Fatal Error: {__e}"""
        print(msg, file=sys.stderr)

        with contextlib.suppress(Exception):
            server.get_logger().error(msg)

        raise __e
    finally:
        r = redis.Redis.from_url(server.broker_url)
        with contextlib.suppress(Exception):
            r.flushdb()
Example #21
0
 def serve_forever(self):
     self.register_zeroconf()
     addr = ("0.0.0.0", self.port)
     server = xmlrpc.server.SimpleXMLRPCServer(addr)
     print("serving on", addr)
     frzr = FreezerInstance()
     db = FreezerDB()
     server.register_function(db.read_all, "read_all")
     server.register_function(db.read_albums, "read_albums")
     server.register_function(frzr.zip_album)
     server.register_function(frzr.search, name="search")
     server.serve_forever()
     try:
         while True:
             time.sleep(0.1)
     except KeyboardInterrupt:
         pass
     finally:
         print("\nUnregistering...")
         self.close()
Example #22
0
def start_agent_rpc_server():
    rpc_server = xmlrpc.server.SimpleXMLRPCServer((AGENT_IP, AGENT_PORT), allow_none=True)
    print("agent rpc server listening on port", AGENT_PORT)
    # register rpc methods
    rpc_server.register_function(rpc_heartbeat, "heartbeat")
    rpc_server.register_function(rpc_submit_job, "submit_job")
    rpc_server.register_function(rpc_stream_output, "stream_output")
    rpc_server.register_function(rpc_kill_job, "kill_job")
    rpc_server.register_introspection_functions()
    rpc_server_thread = Thread(target=lambda server : server.serve_forever(), args=(rpc_server,))
    rpc_server_thread.setDaemon(True)
    rpc_server_thread.start()
    return rpc_server_thread
Example #23
0
    def serve_forever(self):
        self.register_zeroconf()
        addr = ("0.0.0.0", self.port)

        with xmlrpc.server.SimpleXMLRPCServer(addr,
                                              allow_none=True,
                                              logRequests=False) as server:
            print("Listening on", addr)
            server.register_function(self._get_nick, "get_nick")
            server.register_function(self._update_remote_info,
                                     "update_remote_info")
            server.register_function(self._files_exist, "files_exist")
            server.register_function(self._receive, "receive")
            server.register_function(self._permission_needed,
                                     "permission_needed")
            server.register_function(self._get_permission, "get_permission")
            server.register_function(self._prevent_overwriting,
                                     "prevent_overwriting")
            server.register_function(self._abort_transfer, "abort_transfer")
            server.register_function(self._abort_request, "abort_request")
            server.register_function(self._update_progress, "update_progress")
            server.register_function(self._ping, "ping")
            server.serve_forever()
Example #24
0
    def start(self):
        ''' starts the network server for secure file up-/downloads '''
        if not (self._args.port > 0 and self._args.port < 65536):
            print("Please choose a valid port number.", file=sys.stderr)
            sys.exit(1)

        # create the storage directory if it does not exist
        if not os.path.isdir("%s-storage" % self._path):
            os.mkdir("%s-storage" % self._path)

        ctx = self._makectx()
        server = xmlrpc.server.SimpleXMLRPCServer(
            (self._args.address, self._args.port), bind_and_activate=False)
        server.socket = ctx.wrap_socket(server.socket, server_side=True)
        server.server_bind()
        server.server_activate()

        print("Server listening on %s:%s..."
              % (self._args.address, self._args.port), file=sys.stderr)

        server.register_multicall_functions()
        server.register_function(self.upload, "upload")
        server.register_function(self.download, "download")
        server.serve_forever()
def run_xmlrpcserver(pipe_conn, port):
    server = xmlrpc.server.SimpleXMLRPCServer(
        ('', port), requestHandler=_RequestHandler, allow_none=True)
    server.register_introspection_functions()
    server.register_instance(XMLRPCServer(pipe_conn))
    server.serve_forever()
def _start_de_server(global_config, channel_config_loader):
    '''Create and start the DE server with the passed global configuration and config manager'''
    server = _create_de_server(global_config, channel_config_loader)
    server.reaper_start(delay=global_config['dataspace'].get('reaper_start_delay_seconds', 1818))
    server.start_channels()
    server.serve_forever()

class LocatorService:
    def __init__(self, car_num):
        self.car_num = car_num

    def locate_cars(self):
        result = []
        for car_id in range(self.car_num):
            log_entries = log_parser.parse_log(f'logs/client{car_id}.log')
            log_entry = next(log_entry for log_entry in reversed(log_entries)
                             if isinstance(log_entry, log_parser.ArriveEntry)
                             or isinstance(log_entry, log_parser.MoveEntry))
            if isinstance(log_entry, log_parser.ArriveEntry):
                result.append([log_entry.pos])
            else:
                result.append([log_entry.from_pos, log_entry.to_pos])
        return result


if __name__ == '__main__':
    config = json.load(open('config.json', 'r'))
    locator_addr = config['locator_addr']
    car_num = len(config['car_tasks'])

    service = LocatorService(car_num)
    server = xmlrpc.server.SimpleXMLRPCServer(
        (locator_addr['host'], locator_addr['port']))
    server.register_instance(service)
    server.serve_forever()
Example #28
0
def server():
    server = xmlrpc.server.SimpleXMLRPCServer(("0.0.0.0", 8081))
    print("start service get power on 0.0.0.0 8081...")
    server.register_function(get_power, "get_power")
    server.serve_forever()
Example #29
0
 def serve_thread(server, poll_interval):
     server.serve_forever(poll_interval=poll_interval)
Example #30
0
  Moving = True
  move1 = abs(dm1)
  if dm1 > 0:
    dir1 = "a".encode('ASCII')
  else:
    dir1 = "c".encode('ASCII')
  move2 = abs(dm2)
  if dm2 > 0:
    dir2 = "b".encode('ASCII')
  else:
    dir2 = "d".encode('ASCII')
  while Moving:
    print("{move1}, {move2}                    ".format(move1=move1, move2=move2), end="\r")
    Moving = False
    if move1:
      ser.write(dir1)
      move1 -= 1
      Moving = True
      ser.read()
    if move2:
      ser.write(dir2)
      move2 -= 1
      Moving = True
      ser.read()
  return True

server = xmlrpc.server.SimpleXMLRPCServer(("0.0.0.0", 5000))
print("Listening on port 5000")
server.register_function(move, "move")
server.serve_forever()