Fixed crash during GEX tests.

This commit is contained in:
Joe Testa 2023-07-11 11:08:42 -04:00
parent 83e90729e2
commit 3f2fdbaa3d
2 changed files with 15 additions and 10 deletions

View File

@ -182,6 +182,7 @@ For convenience, a web front-end on top of the command-line tool is available at
- Results from concurrent scans against multiple hosts are no longer improperly combined; bug discovered by [Adam Russell](https://github.com/thecliguy).
- Hostname resolution failure no longer causes scans against multiple hosts to terminate unexpectedly; credit [Dani Cuesta](https://github.com/daniel-cues).
- Algorithm recommendations resulting from warnings are now printed in yellow instead of red; credit [Adam Russell](https://github.com/thecliguy).
- Fixed crash during GEX tests.
- Added 1 new key exchange: `curve448-sha512@libssh.org`.
### v2.9.0 (2023-04-29)

View File

@ -26,6 +26,7 @@ import binascii
import os
import random
import struct
import traceback
# pylint: disable=unused-import
from typing import Dict, List, Set, Sequence, Tuple, Iterable # noqa: F401
@ -375,6 +376,7 @@ class KexGroupExchange(KexDH):
while packet_type == Protocol.MSG_DEBUG:
packet_type, payload = s.read_packet(2)
try:
# Parse the modulus (p) and generator (g) values from the server.
ptr = 0
p_len = struct.unpack('>I', payload[ptr:ptr + 4])[0]
@ -388,6 +390,8 @@ class KexGroupExchange(KexDH):
g = int(binascii.hexlify(payload[ptr:ptr + g_len]), 16)
ptr += g_len
except struct.error:
raise KexDHException("Error while parsing modulus and generator during GEX init: %s" % str(traceback.format_exc())) from None
# Now that we got the generator and modulus, perform the DH exchange
# like usual.