Python SimpleXMLRPCServer.SimpleXMLRPCServer() Examples

The following are 30 code examples of SimpleXMLRPCServer.SimpleXMLRPCServer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module SimpleXMLRPCServer , or try the search function .
Example #1
Source File: test_xmlrpc.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #2
Source File: test_xmlrpc.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #3
Source File: test_xmlrpc.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
def test_fail_with_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        # Check that errors in the server send back exception/traceback
        # info when flag is set
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # We should get error info in the response
                expected_err = "invalid literal for int() with base 10: 'I am broken'"
                self.assertEqual(e.headers.get("x-exception"), expected_err)
                self.assertTrue(e.headers.get("x-traceback") is not None) 
Example #4
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #5
Source File: test_xmlrpc.py    From BinderFilter with MIT License 6 votes vote down vote up
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #6
Source File: recv.py    From transperf with Apache License 2.0 6 votes vote down vote up
def listen(self, addr):
        """Starts the RPC server on the addrress.

        Args:
            addr: The tuple of listening address and port.

        Raises:
            RuntimeError: If the server is already running.
        """
        if not self.__done:
            raise RuntimeError('server is already running')

        self.__done = False
        # SimpleXMLRPCServer, by default, is IPv4 only. So we do some surgery.
        SocketServer.TCPServer.address_family = self.__ip_mode
        server = SimpleXMLRPCServer.SimpleXMLRPCServer(addr, allow_none=True)
        server.register_instance(self)
        while not self.__done:
            server.handle_request() 
Example #7
Source File: test_xmlrpc.py    From oss-ftp with MIT License 6 votes vote down vote up
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #8
Source File: test_xmlrpc.py    From BinderFilter with MIT License 6 votes vote down vote up
def test_fail_with_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        # Check that errors in the server send back exception/traceback
        # info when flag is set
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # We should get error info in the response
                expected_err = "invalid literal for int() with base 10: 'I am broken'"
                self.assertEqual(e.headers.get("x-exception"), expected_err)
                self.assertTrue(e.headers.get("x-traceback") is not None) 
Example #9
Source File: test_xmlrpc.py    From oss-ftp with MIT License 6 votes vote down vote up
def test_fail_with_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        # Check that errors in the server send back exception/traceback
        # info when flag is set
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # We should get error info in the response
                expected_err = "invalid literal for int() with base 10: 'I am broken'"
                self.assertEqual(e.headers.get("x-exception"), expected_err)
                self.assertTrue(e.headers.get("x-traceback") is not None) 
Example #10
Source File: plaso_xmlrpc.py    From plaso with Apache License 2.0 6 votes vote down vote up
def _Open(self, hostname, port):
    """Opens the RPC communication channel for clients.

    Args:
      hostname (str): hostname or IP address to connect to for requests.
      port (int): port to connect to for requests.

    Returns:
      bool: True if the communication channel was successfully opened.
    """
    try:
      self._xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer(
          (hostname, port), logRequests=False, allow_none=True)
    except SocketServer.socket.error as exception:
      logger.warning((
          'Unable to bind a RPC server on {0:s}:{1:d} with error: '
          '{2!s}').format(hostname, port, exception))
      return False

    self._xmlrpc_server.register_function(
        self._callback, self._RPC_FUNCTION_NAME)
    return True 
Example #11
Source File: idawrapper.py    From TimeMachine with GNU Lesser General Public License v3.0 6 votes vote down vote up
def main():
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")

    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")

    server.register_instance(IDAWrapper())

    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
Example #12
Source File: idawrapper.py    From AndroBugs_Framework with GNU General Public License v3.0 6 votes vote down vote up
def main():
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")

    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")

    server.register_instance(IDAWrapper())

    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
Example #13
Source File: idawrapper.py    From MARA_Framework with GNU Lesser General Public License v3.0 6 votes vote down vote up
def main():
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")

    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")

    server.register_instance(IDAWrapper())

    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
Example #14
Source File: idawrapper.py    From MARA_Framework with GNU Lesser General Public License v3.0 6 votes vote down vote up
def main() :
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")
    
    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")
    
    server.register_instance(IDAWrapper())
    
    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
Example #15
Source File: binja_lobotomy.py    From MARA_Framework with GNU Lesser General Public License v3.0 6 votes vote down vote up
def start_lobotomy(bv):
    """
    Start the lobotomy service
    """
    # Locals
    HOST = "127.0.0.1"
    PORT = 6666
    rpc = None

    try:
        # Create a new SimpleXMLRPCServer instance with the
        # LobotomyRequestHandler
        rpc = SimpleXMLRPCServer((HOST, PORT),
                                 requestHandler=LobotomyRequestHandler,
                                 logRequests=False,
                                 allow_none=True)
        # Register the Lobotomy class
        rpc.register_instance(Lobotomy(rpc, bv))
        print("[*] Started lobotomy service (!)")
        while True:
            # Handle inbound requests
            rpc.handle_request()
    except Exception as e:
        ExceptionHandler(e) 
Example #16
Source File: idawrapper.py    From MARA_Framework with GNU Lesser General Public License v3.0 6 votes vote down vote up
def main():
    autoWait()
    ea = ScreenEA()

    server = SimpleXMLRPCServer(("localhost", 9000))
    server.register_function(is_connected, "is_connected")

    server.register_function(wrapper_get_raw, "get_raw")
    server.register_function(wrapper_get_function, "get_function")
    server.register_function(wrapper_Heads, "Heads")
    server.register_function(wrapper_Functions, "Functions")

    server.register_instance(IDAWrapper())

    server.register_function(wrapper_quit, "quit")
    server.serve_forever()

    qexit(0) 
Example #17
Source File: ida_gef.py    From GdbPlugins with GNU General Public License v3.0 6 votes vote down vote up
def start_xmlrpc_server():
    """
    Initialize the XMLRPC thread
    """
    print("[+] Starting XMLRPC server: {}:{}".format(HOST, PORT))
    server = SimpleXMLRPCServer((HOST, PORT),
                                requestHandler=RequestHandler,
                                logRequests=False,
                                allow_none=True)
    server.register_introspection_functions()
    server.register_instance( Gef(server) )
    print("[+] Registered {} functions.".format( len(server.system_listMethods()) ))
    while True:
        if hasattr(server, "shutdown") and server.shutdown==True:
            break
        server.handle_request()

    return 
Example #18
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_basic(self):
        # check that flag is false by default
        flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
        self.assertEqual(flagval, False)

        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        # test a call that shouldn't fail just as a smoke test
        try:
            p = xmlrpclib.ServerProxy(URL)
            self.assertEqual(p.pow(6,8), 6**8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #19
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_fail_with_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        # Check that errors in the server send back exception/traceback
        # info when flag is set
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # We should get error info in the response
                expected_err = "invalid literal for int() with base 10: 'I am broken'"
                self.assertEqual(e.headers.get("x-exception"), expected_err)
                self.assertTrue(e.headers.get("x-traceback") is not None) 
Example #20
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def setUp(self):
        # enable traceback reporting
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True

        self.evt = threading.Event()
        # start server thread to handle requests
        serv_args = (self.evt, self.request_count, self.requestHandler)
        t = threading.Thread(target=self.threadFunc, args=serv_args)
        t.setDaemon(True)
        t.start()

        # wait for the server to be ready
        self.evt.wait(10)
        self.evt.clear() 
Example #21
Source File: test_SimpleXMLRPCServer.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_exposeFunction1(self):
        """Expose a function via XML-RPC."""
        server = SimpleXMLRPCServer((HOST, PORT + 1))
        server.register_function(multiply)
        ServerThread(server).start()

        # Access the exposed service.
        client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 1))
        self.assertEqual(client.multiply(5, 10), 50) 
Example #22
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def tearDown(self):
        # wait on the server thread to terminate
        self.evt.wait()
        # reset flag
        SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False
        # reset message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = mimetools.Message 
Example #23
Source File: test_xmlrpc.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setUp(self):
        self.cgi = SimpleXMLRPCServer.CGIXMLRPCRequestHandler() 
Example #24
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_fail_no_info(self):
        # use the broken message class
        SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass

        try:
            p = xmlrpclib.ServerProxy(URL)
            p.pow(6,8)
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e) and hasattr(e, "headers"):
                # The two server-side error headers shouldn't be sent back in this case
                self.assertTrue(e.headers.get("X-exception") is None)
                self.assertTrue(e.headers.get("X-traceback") is None) 
Example #25
Source File: binja_gef.py    From GdbPlugins with GNU General Public License v3.0 5 votes vote down vote up
def start_service(host, port, bv):
    log_info("[+] Starting service on {}:{}".format(host, port))
    server = SimpleXMLRPCServer((host, port),
                                requestHandler=RequestHandler,
                                logRequests=False,
                                allow_none=True)
    server.register_introspection_functions()
    server.register_instance(Gef(server, bv))
    log_info("[+] Registered {} functions.".format( len(server.system_listMethods()) ))
    while True:
        if hasattr(server, "shutdown") and server.shutdown==True:
            break
        server.handle_request()
    return 
Example #26
Source File: test_xmlrpc.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_introspection4(self):
        # the SimpleXMLRPCServer doesn't support signatures, but
        # at least check that we can try making the call
        try:
            p = xmlrpclib.ServerProxy(URL)
            divsig = p.system.methodSignature('div')
            self.assertEqual(divsig, 'signatures not supported')
        except (xmlrpclib.ProtocolError, socket.error), e:
            # ignore failures due to non-blocking socket 'unavailable' errors
            if not is_unavailable_exception(e):
                # protocol error; provide additional information in test output
                self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) 
Example #27
Source File: test_SimpleXMLRPCServer.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_exposeClass(self):
        """Expose an entire class and test the _dispatch method."""
        server = SimpleXMLRPCServer((HOST, PORT + 3))
        server.register_instance(MyService())
        ServerThread(server).start()

        # Access the exposed service.
        client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 3))
        self.assertEqual(client.squared(10), 100) 
Example #28
Source File: test_SimpleXMLRPCServer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_exposeLambda(self):
        """Expose a lambda function via XML-RPC."""
        # Create a server instance.
        server = SimpleXMLRPCServer((HOST, PORT))
        server.register_function(lambda x,y: x+y, 'add')
        ServerThread(server).start()

        # Access the exposed service.
        client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT))
        self.assertEqual(client.add(10, 20), 30) 
Example #29
Source File: test_SimpleXMLRPCServer.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_exposeFunction1(self):
        """Expose a function via XML-RPC."""
        server = SimpleXMLRPCServer((HOST, PORT + 1))
        server.register_function(multiply)
        ServerThread(server).start()

        # Access the exposed service.
        client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 1))
        self.assertEqual(client.multiply(5, 10), 50) 
Example #30
Source File: test_SimpleXMLRPCServer.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_exposeFunction2(self):
        """Expose a function using a different name via XML-RPC."""
        server = SimpleXMLRPCServer((HOST, PORT + 2))
        server.register_function(multiply, "mult")
        ServerThread(server).start()

        # Access the exposed service.
        client = xmlrpclib.ServerProxy("http://%s:%d" % (HOST, PORT + 2))
        self.assertEqual(client.mult(7, 11), 77)