MCPcopy Create free account
hub / github.com/mozilla/cipherscan / scan

Method scan

cscan/scanner.py:74–157  ·  view source on GitHub ↗

Perform a scan on server.

(self)

Source from the content-addressed store, hash-verified

72 self.hostname = hostname
73
74 def scan(self):
75 """Perform a scan on server."""
76 defragger = Defragmenter()
77 defragger.addStaticSize(ContentType.change_cipher_spec, 1)
78 defragger.addStaticSize(ContentType.alert, 2)
79 defragger.addDynamicSize(ContentType.handshake, 1, 3)
80
81 try:
82 raw_sock = socket.create_connection((self.host, self.port), 5)
83 except socket.error as e:
84 return [e]
85
86 sock = MessageSocket(raw_sock, defragger)
87
88 if self.hostname is not None:
89 client_hello = self.hello_gen(bytearray(self.hostname,
90 'utf-8'))
91 else:
92 client_hello = self.hello_gen(None)
93
94 # record layer version - TLSv1.x
95 # use the version from configuration, if present, or default to the
96 # RFC recommended (3, 1) for TLS and (3, 0) for SSLv3
97 if hasattr(client_hello, 'record_version'):
98 sock.version = client_hello.record_version
99 elif hasattr(self.hello_gen, 'record_version'):
100 sock.version = self.hello_gen.record_version
101 elif client_hello.client_version > (3, 1): # TLS1.0
102 sock.version = (3, 1)
103 else:
104 sock.version = client_hello.client_version
105
106 # we don't want to send invalid messages (SSLv2 hello in SSL record
107 # layer), so set the record layer version to SSLv2 if the hello is
108 # of SSLv2 format
109 if client_hello.ssl2:
110 sock.version = (0, 2)
111
112 # save the record version used in the end for later analysis
113 client_hello.record_version = sock.version
114
115 messages = [client_hello]
116
117 handshake_parser = HandshakeParser()
118
119 try:
120 sock.sendMessageBlocking(client_hello)
121 except socket.error as e:
122 messages.append(e)
123 return messages
124 except TLSAbruptCloseError as e:
125 sock.sock.close()
126 messages.append(e)
127 return messages
128
129 # get all the server messages that affect connection, abort as soon
130 # as they've been read
131 try:

Callers 1

scan_with_configFunction · 0.95

Calls 2

parseMethod · 0.95
HandshakeParserClass · 0.85

Tested by

no test coverage detected