Use this test against a password protected server. The server should kick us within 10 seconds out as we aren't replying to its challenge request. """ def __init__(self, conn, opts): GLibXpraClient.__init__(self, conn, opts) def check_connection_timeout(*args): log.error("BUG: timeout did not fire: we are still connected!") self.quit() gobject.timeout_add(20 * 1000, check_connection_timeout) def _process_challenge(self, packet): log.info("got challenge - which we shall ignore!") def _process_hello(self, packet): log.error( "cannot try to DoS this server: it has no password protection!") self.quit() def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS test_DoS(TestTimeoutClient, sys.argv)
The server should kick us within 10 seconds out as we aren't replying to its challenge request. """ def __init__(self, conn, opts): GLibXpraClient.__init__(self, conn, opts) def check_connection_timeout(*args): log.error("BUG: timeout did not fire: we are still connected!") self.quit() gobject.timeout_add(20 * 1000, check_connection_timeout) def _process_challenge(self, packet): log.info("got challenge - which we shall ignore!") def _process_hello(self, packet): log.error("cannot try to DoS this server: it has no password protection!") self.quit() def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS test_DoS(TestTimeoutClient, sys.argv)
def __init__(self, conn, opts): GLibXpraClient.__init__(self, conn, opts) def check_connection_dead(*args): self.send(["irrelevant"]) gobject.timeout_add(1000, check_connection_dead) def check_connection_timeout(*args): log.error( "BUG: packet size failsafe did not fire: we are still connected!" ) self.quit() gobject.timeout_add(20 * 1000, check_connection_timeout) def make_hello(self, challenge_response=None): capabilities = XpraClientBase.make_hello(self, challenge_response) capabilities["waste_of_space"] = "\0" * (32 * 1024) return capabilities def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS test_DoS(TestMemoryClient, sys.argv)
self.send(["irrelevant: should be kicked out already"]) def send_hello(self, challenge_response=None): GLibXpraClient.send_hello(self, challenge_response) self._protocol._queue_write("PS00000000000006l201234567890123456789") gobject.timeout_add(1000, self.try_sending_again) def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) class TestGiberringCommandClientNoPacketSize(TestGiberringCommandClient): def send_hello(self, challenge_response=None): hello = self.make_hello(challenge_response) self._protocol._queue_write(bencode(["hello", hello])) def send_gibberish(): self._protocol._queue_write("01234567890123456789") gobject.timeout_add(1000, send_gibberish) gobject.timeout_add(3000, self.try_sending_again) def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS #test_DoS(TestGiberringCommandClient, sys.argv) test_DoS(TestGiberringCommandClientNoPacketSize, sys.argv)
from wimpiggy.log import Logger log = Logger() from xpra.client_base import GLibXpraClient class TestIllegalCommandClient(GLibXpraClient): """ Sending an illegal command should get us kicked out """ def __init__(self, conn, opts): GLibXpraClient.__init__(self, conn, opts) def check_kicked_out(*args): log.error("BUG: illegal command did not get us kicked out: we are still connected!") self.quit() gobject.timeout_add(5*1000, check_kicked_out) def send_hello(self, challenge_response=None): #we should not be able to do this before hello: for i in xrange(1, 10): self.send(["close-window", i]) def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS test_DoS(TestIllegalCommandClient, sys.argv)
from xpra.client_base import XpraClientBase, GLibXpraClient class TestMemoryClient(GLibXpraClient): """ Try to exhaust server memory without authenticating by sending an overly large packet. """ def __init__(self, conn, opts): GLibXpraClient.__init__(self, conn, opts) def check_connection_dead(*args): self.send(["irrelevant"]) gobject.timeout_add(1000, check_connection_dead) def check_connection_timeout(*args): log.error("BUG: packet size failsafe did not fire: we are still connected!") self.quit() gobject.timeout_add(20*1000, check_connection_timeout) def make_hello(self, challenge_response=None): capabilities = XpraClientBase.make_hello(self, challenge_response) capabilities["waste_of_space"] = "\0" * (32*1024) return capabilities def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS test_DoS(TestMemoryClient, sys.argv)
GLibXpraClient.send_hello(self, challenge_response) self._protocol._queue_write("PS00000000000006l201234567890123456789") gobject.timeout_add(1000, self.try_sending_again) def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) class TestGiberringCommandClientNoPacketSize(TestGiberringCommandClient): def send_hello(self, challenge_response=None): hello = self.make_hello(challenge_response) self._protocol._queue_write(bencode(["hello", hello])) def send_gibberish(): self._protocol._queue_write("01234567890123456789") gobject.timeout_add(1000, send_gibberish) gobject.timeout_add(3000, self.try_sending_again) def quit(self, *args): log.info("server correctly terminated the connection") GLibXpraClient.quit(self) if __name__ == "__main__": import sys from xpra.test_DoS_client import test_DoS #test_DoS(TestGiberringCommandClient, sys.argv) test_DoS(TestGiberringCommandClientNoPacketSize, sys.argv)