-
Notifications
You must be signed in to change notification settings - Fork 19
/
CVE-2024-38063.py
36 lines (28 loc) · 1.2 KB
/
CVE-2024-38063.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
# copy from nullenc0de's gist,just a backup
# org: https://gist.github.com/nullenc0de
class IPv6Packet:
def __init__(self, main_header_length, extension_headers):
self.main_header_length = main_header_length
self.extension_headers = extension_headers
def process_packet(packet):
total_length = packet.main_header_length
# Vulnerable loop: doesn't check for integer underflow
for header_length in packet.extension_headers:
total_length += header_length
# Simulating a buffer to hold packet data
buffer = bytearray(64) # Only 64 bytes allocated
# Vulnerable write: uses unchecked total_length
for i in range(total_length):
buffer[i] = 0xFF # Potential out-of-bounds write
return buffer
# Normal packet
normal_packet = IPv6Packet(40, [8, 16])
result = process_packet(normal_packet)
print("Normal packet processed, buffer length:", len(result))
# Malicious packet causing integer underflow
malicious_packet = IPv6Packet(40, [8, 2**32 - 47]) # Very large number
try:
result = process_packet(malicious_packet)
print("Malicious packet processed, buffer length:", len(result))
except IndexError as e:
print("Crash occurred:", str(e))