Skip to content

Commit

Permalink
null probe for user_mapping extension from RFC4681
Browse files Browse the repository at this point in the history
  • Loading branch information
tomato42 committed Aug 27, 2016
1 parent ce31897 commit baf1307
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
5 changes: 4 additions & 1 deletion prober.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@
OCSPUnderflow12PFS(),
DoubleExtension(),
DoubleExtension12(),
DoubleExtension12PFS()
DoubleExtension12PFS(),
UserMappingNull(),
UserMappingNull12(),
UserMappingNull12PFS()
]

def probe(ipaddress, port, starttls, specified_probe):
Expand Down
26 changes: 26 additions & 0 deletions probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,3 +1583,29 @@ class DoubleExtension12(DoubleExtension, NormalHandshake12):
class DoubleExtension12PFS(DoubleExtension, NormalHandshake12PFS):
'''Duplicate secure renegotiation extension in PFS TLSv1.2 hello'''
pass


class UserMappingNull(NormalHandshake):
'''Send empty user mapping extension in hello'''

def make_user_mapping_ext(self, value):
user_mapping_ext = Extension.create(
extension_type=6,
data=value)
return self.make_hello([user_mapping_ext])

def test(self, sock):
logging.debug('Sending Client Hello...')
# extension consists of an array and the array needs at least one
# element, don't send any
sock.write(self.make_user_mapping_ext(b''))


class UserMappingNull12(UserMappingNull, NormalHandshake12):
'''Send empty user mapping extension in TLSv1.2 hello'''
pass


class UserMappingNull12PFS(UserMappingNull, NormalHandshake12PFS):
'''Send empty user mapping extension in PFS TLSv1.2 hello'''
pass
61 changes: 61 additions & 0 deletions tests/test_probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3013,3 +3013,64 @@ def test_test(self):
b'\x00'
b'\xff\x01\x00\x01'
b'\x00'])


class TestUserMappingNull(unittest.TestCase):
def test_test(self):
probe = UserMappingNull()
sock = MockSock()

probe.test(sock)

self.assertEqual(sock.sent_data,
[b'\x16\x03\x01\x00?'
b'\x01\x00\x00;'
b'\x03\x01' +
RANDOM_STR +
b'\x00'
b'\x00\x0e' +
DEFAULT_CIPHERS_STR +
b'\x01\x00'
b'\x00\x04'
b'\x00\x06\x00\x00'])


class TestUserMappingNull12(unittest.TestCase):
def test_test(self):
probe = UserMappingNull12()
sock = MockSock()

probe.test(sock)

self.assertEqual(sock.sent_data,
[b'\x16\x03\x01\x00W'
b'\x01\x00\x00S'
b'\x03\x03' +
RANDOM_STR +
b'\x00'
b'\x00&' +
DEFAULT_12_CIPHERS_STR +
b'\x01\x00'
b'\x00\x04'
b'\x00\x06\x00\x00'])


class TestUserMappingNull12PFS(unittest.TestCase):
def test_test(self):
probe = UserMappingNull12PFS()
sock = MockSock()

probe.test(sock)

self.maxDiff = None
self.assertEqual(sock.sent_data,
[b"\x16\x03\x01\x00\x8f"
b"\x01\x00\x00\x8b"
b"\x03\x03" +
RANDOM_STR +
b"\x00"
b"\x00^" +
DEFAULT_PFS_CIPHERS_STR +
b"\x01\x00"
b'\x00\x04'
b'\x00\x06\x00\x00'])

0 comments on commit baf1307

Please sign in to comment.