Skip to content
Extraits de code Groupes Projets
Valider 7fff84fb rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

Added support for TP-Link Smart Home protocol

parent c6a9ada4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #60771 réussi
"""
Anonymize the TP-Link Smart Home protocol,
running over TCP port 9999.
"""
from scapy.layers.inet import TCP
def anonymize_tplink(packet: TCP) -> None:
"""
Anonymize a packet's TP-Link Smart Home protocol,
by removing the payload.
Args:
packet (scapy.layers.inet.TCP): Packet to anonymize
"""
packet.remove_payload()
......@@ -5,6 +5,9 @@ from pcap_anonymize.layers.coap import CoapFields, anonymize_coap
### TEST FUNCTIONS ###
def test_anonymize_coap() -> None:
"""
Test the function `anonymize_coap`.
"""
# Build CoAP layer
options = [('Uri-Host', 'host'), ('Uri-Path', 'sensors'), ('Uri-Path', 'temperature')]
coap = CoAP(type=0, code=1, msg_id=0x1234, token=b"token", options=options)
......
from scapy.packet import Raw
from scapy.layers.inet import TCP
from pcap_anonymize.layers.tplink import anonymize_tplink
### TEST FUNCTIONS ###
def test_anonymize_tplink() -> None:
"""
Test the function `anonymize_tplink`.
"""
# Build dummy TP-Link Smart Home packet
tcp = TCP(dport=9999)
payload = Raw(load=b"abcdef")
packet = tcp / payload
anonymize_tplink(packet)
# Check if payload was correctly deleted
assert not packet.haslayer(Raw)
assert not hasattr(packet, "load")
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter