The Wayback Machine - https://web.archive.org/web/20201109134031/https://github.com/secdev/scapy/issues/2804
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

PacketField Does not Fuzz #2804

Open
sarcasticmonkeys opened this issue Sep 8, 2020 · 4 comments
Open

PacketField Does not Fuzz #2804

sarcasticmonkeys opened this issue Sep 8, 2020 · 4 comments

Comments

@sarcasticmonkeys
Copy link

@sarcasticmonkeys sarcasticmonkeys commented Sep 8, 2020

If you call fuzz on a layer that contains a PacketField, that fuzz does not recurse down into a PacketField within the layer

class Foo(Packet):
    name='Foo'
    fields_desc=[
        int64("bar"),
    ]
    def extract_padding(self, s):
        return b'', s
        
class demo(Packet):
    name="demo"
    fields_desc = [ PacketField(name="foo",default=Foo(),cls=Foo)]
instance = demo()
print(fuzz(instance).show())

Results in:

###[ demo ]### 
  \foo       \
   |###[ Foo ]### 
   |  bar       = 0

None

What do people think of modifying

elif isinstance(f, MultipleTypeField):

to add

            elif isinstance(f, PacketField):
                if(f.default is not None):
                    fuzz(getattr(q, f.name),_inplace=1)

resulting in

###[ demo ]### 
  \foo       \
   |###[ Foo ]### 
   |  bar       = <RandSLong>

None

To me this makes sense, but I'm obviously very new to this.

@gpotter2
Copy link
Member

@gpotter2 gpotter2 commented Sep 16, 2020

This sounds pretty reasonable. Feel free to submit a PR.
You can also use the holds_packets field attribute to see if it holds a packet, this is more general than testing for PacketField (but watch out PacketListField).

Thanks for the suggestion

@badsketch
Copy link

@badsketch badsketch commented Oct 4, 2020

I'd like to give this a shot if nobody else has claimed it yet 🙂

@gpotter2
Copy link
Member

@gpotter2 gpotter2 commented Oct 4, 2020

@badsketch Sure, have a shot ! Feel free to ask questions If you get stuck somewhere 😄

@badsketch
Copy link

@badsketch badsketch commented Oct 26, 2020

Bit off more than I could chew, and don't think I can make a valuable contribution very soon. I'll keep working away on it in my own time, but if anyone else can implement this, please go ahead! Apologies for the late update. 😕

@gpotter2 gpotter2 removed the Hacktoberfest label Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.