-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
test_DoS_memory_client.py
executable file
·41 lines (33 loc) · 1.4 KB
/
test_DoS_memory_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# This file is part of Parti.
# Copyright (C) 2010-2012 Antoine Martin <antoine@devloop.org.uk>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.
import gobject
from wimpiggy.log import Logger
log = Logger()
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)