Skip to content

Commit

Permalink
DceRpc fix register_dcerpc_interface duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Feb 23, 2025
1 parent 53b9cce commit 538a4e6
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions scapy/layers/dcerpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,15 +1205,9 @@ def register_dcerpc_interface(name, uuid, version, opnums):
# Interface is already registered.
interface = DCE_RPC_INTERFACES[(uuid, if_version)]
if interface.name == name:
if interface.if_version == if_version and set(opnums) - set(
interface.opnums
):
if set(opnums) - set(interface.opnums):
# Interface is an extension of a previous interface
interface.opnums.update(opnums)
return
elif interface.if_version != if_version:
# Interface has a different version
pass
else:
log_runtime.warning(
"This interface is already registered: %s. Skip" % interface
Expand All @@ -1223,15 +1217,17 @@ def register_dcerpc_interface(name, uuid, version, opnums):
raise ValueError(
"An interface with the same UUID is already registered: %s" % interface
)
DCE_RPC_INTERFACES_NAMES[uuid] = name
DCE_RPC_INTERFACES_NAMES_rev[name.lower()] = uuid
DCE_RPC_INTERFACES[(uuid, if_version)] = DceRpcInterface(
name,
uuid,
version_tuple,
if_version,
opnums,
)
else:
# New interface
DCE_RPC_INTERFACES_NAMES[uuid] = name
DCE_RPC_INTERFACES_NAMES_rev[name.lower()] = uuid
DCE_RPC_INTERFACES[(uuid, if_version)] = DceRpcInterface(
name,
uuid,
version_tuple,
if_version,
opnums,
)
# bind for build
for opnum, operations in opnums.items():
bind_top_down(DceRpc5Request, operations.request, opnum=opnum)
Expand Down

0 comments on commit 538a4e6

Please sign in to comment.