Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipv4_reassembly #80

Closed
mkrase opened this issue Feb 10, 2021 · 2 comments
Closed

ipv4_reassembly #80

mkrase opened this issue Feb 10, 2021 · 2 comments

Comments

@mkrase
Copy link

mkrase commented Feb 10, 2021

Describe the bug
I' reading packets with dpkt like this:

import dpkt
import pcapkit
from pcapkit.reassembly import IPv4_Reassembly
ipv4_reassembly = IPv4_Reassembly()
f = open(r'test.pcapng','rb')
pcap = dpkt.pcapng.Reader(f)
buffer = []
for timestamp, buf in pcap:
    eth = dpkt.ethernet.Ethernet(buf)
    if isinstance(eth.data, dpkt.ip.IP):
        ip = eth.data
        if ip.p == dpkt.ip.IP_PROTO_UDP:
            udp = ip.data
            frag, defrag = pcapkit.toolkit.dpkt.ipv4_reassembly(eth)
            if frag:
                buffer = ipv4_reassembly(defrag)    

System information

  • OS Version: [Windows 10]
  • Python Version: [3.8,7]
  • Python Implementation: [CPython]

Traceback stack
Run program again with PCAPKIT_DEVMODE=true set to provide the traceback stack.

pcapkit.utilities.exceptions.IntError: Function call expected integral number, NotImplementedType got instead.
During handling of the above exception, another exception occurred:
pcapkit.utilities.exceptions.FragmentError: 'Malformed fragment object: Function call expected integral number, NotImplementedType got instead.'

With

buffer = []
for timestamp, buf in pcap:
    eth = dpkt.ethernet.Ethernet(buf)
    if isinstance(eth.data, dpkt.ip.IP):
        ip = eth.data
        if ip.p == dpkt.ip.IP_PROTO_UDP:
            udp = ip.data
            frag, defrag = pcapkit.toolkit.dpkt.ipv4_reassembly(eth)
            if frag:
                defrag['num'] = 0
                buffer = ipv4_reassembly(defrag)      

I got:
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "", line 10, in
UnboundLocalError: local variable 'TDL' referenced before assignment

Expected behavior
Defragmented packet(s).

@mkrase
Copy link
Author

mkrase commented Feb 10, 2021

Okay, I think I just have know how I fill the dict for ipv4_reassembly...

@JarryShaw
Copy link
Owner

FYI, you may check out pcapkit.toolkit.dpkt to see about the utility functions that may help you generate a valid dict for reassembly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants