Exploit database

GH-1d972c7e3b74035401e9780264f0829c

msdmehdipour/meshtastic-cve-2025-52464-poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-52464

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files15
msdmehdipour/meshtastic-cve-2025-52464-pocRevision de08c744a69e

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

node.py

Python · 3,143 bytes
"""
node.py

Simulation of a Meshtastic node.

Each node owns an X25519 key pair and uses CryptoEngine to
encrypt and decrypt Direct Messages.
"""

from crypto_engine import CryptoEngine
from datetime import datetime
from packet import Packet

class Node:
    """
    Simulated Meshtastic node.
    """

    def __init__(self, name, vulnerable=False, weak_private_key=None):
        """
        Create a node.

        Parameters
        ----------
        name : str
            Human-readable node name (Alice, Bob, etc.).

        vulnerable : bool
            If True, reuse the supplied weak private key.
            Otherwise generate a fresh secure key pair.

        weak_private_key : bytes
            Raw 32-byte private key used in vulnerable mode.
        """

        self.name = name
        self.vulnerable = vulnerable

        if vulnerable:
            if weak_private_key is None:
                raise ValueError(
                    "A weak private key must be supplied in vulnerable mode."
                )

            self.private_key, self.public_key = (
                CryptoEngine.generate_vulnerable_keypair(
                    weak_private_key
                )
            )

        else:
            self.private_key, self.public_key = (
                CryptoEngine.generate_secure_keypair()
            )


    def get_public_key_bytes(self):
        """
        Return this node's public key as raw 32-byte data.
        """
        return CryptoEngine.public_key_bytes(self.public_key)
    
    def derive_aes_key(self, peer_public_key):
        """
        Derive the AES encryption key shared with another node.

        Parameters
        ----------
        peer_public_key
            The other node's X25519 public key.

        Returns
        -------
        bytes
            32-byte AES key derived from the shared secret.
        """
        shared_secret = CryptoEngine.derive_shared_secret(
            self.private_key,
            peer_public_key,
        )

        return CryptoEngine.derive_aes_key(shared_secret)

    
    def create_direct_message_packet(self, receiver_node, message):
        """
        Encrypt a Direct Message and wrap it in a Packet.
        """
        aes_key = self.derive_aes_key(receiver_node.public_key)
        nonce, ciphertext = CryptoEngine.encrypt_message(aes_key, message)

        return Packet(
            sender=self.name,
            receiver=receiver_node.name,
            nonce=nonce,
            ciphertext=ciphertext,
            timestamp=datetime.now(),
        )


    def decrypt_direct_message(self, sender_node, nonce, ciphertext):
        """
        Decrypt a Direct Message received from another node.
        """
        aes_key = self.derive_aes_key(sender_node.public_key)
        plaintext = CryptoEngine.decrypt_message(aes_key, nonce, ciphertext)
        return plaintext

    def decrypt_packet(self, sender_node, packet):
        """
        Decrypt a received Packet.
        """
        return self.decrypt_direct_message(
            sender_node,
            packet.nonce,
            packet.ciphertext,
        )