scapy
scapy copied to clipboard
Problem in __init__() of TCPSession class
Brief description
Problem found in scapy/session.py
class TCPSession(IPSession):
"""A Session that matches seq/ack packets together to dissect
special protocols, such as HTTP.
DEV: implement a class-function `tcp_reassemble` in your Packet class::
@classmethod
def tcp_reassemble(cls, data, metadata):
# data = the reassembled data from the same request/flow
# metadata = empty dictionary, that can be used to store data
[...]
# If the packet is available, return it. Otherwise don't.
# Whenever you return a packet, the buffer will be discarded.
return pkt
# Otherwise, maybe store stuff in metadata, and return None,
# as you need additional data.
return None
For more details and a real example, see:
https://scapy.readthedocs.io/en/latest/usage.html#how-to-use-tcpsession-to-defragment-tcp-packets
:param app: Whether the socket is on application layer = has no TCP
layer. This is used for instance if you are using a native
TCP socket. Default to False
fmt = ('TCP {IP:%IP.src%}{IPv6:%IPv6.src%}:%r,TCP.sport% > ' +
'{IP:%IP.dst%}{IPv6:%IPv6.dst%}:%r,TCP.dport%')
def __init__(self, app=False, *args, **kwargs):
this should probably be changed to:
def __init__(self, *args, app=False, **kwargs):
Without this change, 'app' would be overridden by the first positional argument, which is most likely not the intention.
Scapy version
2.4.5rc1.dev412
Python version
3.6.9
Operating system
Linux 4.15.0-175
Additional environment information
No response
How to reproduce
def f(a=1, *args):
assert a == 1
for i in args:
assert i == 11
def f2(*args, a=1):
assert a == 1
for i in args:
assert i == 11
f(11, 11) # this will fail
f2(11, 11)
Actual result
No response
Expected result
No response
Related resources
No response