secdev / scapy

Scapy: the Python-based interactive packet manipulation program & library.
https://scapy.net
GNU General Public License v2.0
10.72k stars 2.02k forks source link

OPC DA Layer does not result in valid packets, missing DCOM layer #3910

Closed Problembeloeser closed 1 year ago

Problembeloeser commented 1 year ago

Brief description

When trying to create a pcap with scapy containing OPC DA traffic, instead of TCP a DCOM layer is needed. That however is missing in scapy, causing packets created with OPC not to be valid.

Scapy version

2.5.0

Python version

3.10.9

Operating system

Arch Linux on Kernel 6.1.12-arch1-1

Additional environment information

No response

How to reproduce

Try to run a setup similar to the following snippet:

import importlib
import inspect

from scapy.layers.inet import IP
from scapy.packet import Packet
from scapy.utils import wrpcap
module = importlib.import_module('scapy.contrib.opc_da')
classes = [obj for _, obj in inspect.getmembers(module) if
           inspect.isclass(obj) and issubclass(obj, Packet) and obj is not Packet]
types = []
for classPacket in classes:
    try:
        types.append(classPacket())
    except Exception as e:
        pass
ps = [IP(dst='127.0.0.1') / DCOM() / type for type in types]

OPC DA needs DCOM, but DCOM is not available for imports

Actual result

No response

Expected result

DCOM can be imported and used for creation of packets

Related resources

I tried to ask on gitter but received no help, so I assume that this behaviour is a bug

gpotter2 commented 1 year ago

Correct, feel free to provide a PR.