Skip to content

Make ARP() great again!#1431

Merged
guedou merged 13 commits intosecdev:masterfrom
p-l-:enh-arp
May 17, 2018
Merged

Make ARP() great again!#1431
guedou merged 13 commits intosecdev:masterfrom
p-l-:enh-arp

Conversation

@p-l-
Copy link
Copy Markdown
Member

@p-l- p-l- commented May 16, 2018

This PR introduces MultipleTypeField() pseudo Field type, and uses it to enhance ARP(). It also fixes a bug and clean some imports (see detailed commit log for more -- please do not stash this PR).

In ARP(), MultipleTypeField() are now used for {hw,p}{dst,src} fields, to achieve two goals:

  • Make ARP() usable with other {hw,p}types than Ether and IP.
  • Keep ARP() as simple as possible to use.

With this patch:

  • raw(ARP()) returns the same result as before.
  • ARP(pytpe="IPv4") works and raw(ARP(pytpe="IPv4")) == raw(ARP())
  • ARP(ptype="IPv6") now works, plen is then set to 16 and psrc & pdst fields are IPv6 addresses: ARP(raw(ARP(ptype="IPv6"))).pdst == "::"

As always, when fixing imports in some important parts of Scapy shows that some modules imports are still a mess. I had to fix some of them, using this opportunity to remove some wildcard imports.

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 16, 2018

Codecov Report

Merging #1431 into master will increase coverage by 0.07%.
The diff coverage is 87.54%.

@@            Coverage Diff             @@
##           master    #1431      +/-   ##
==========================================
+ Coverage   85.11%   85.19%   +0.07%     
==========================================
  Files         174      174              
  Lines       40216    40325     +109     
==========================================
+ Hits        34229    34353     +124     
+ Misses       5987     5972      -15
Impacted Files Coverage Δ
scapy/layers/l2.py 82.1% <100%> (ø) ⬆️
scapy/contrib/openflow3.py 94.44% <100%> (+0.01%) ⬆️
scapy/contrib/gtp_v2.py 100% <100%> (ø) ⬆️
scapy/layers/dhcp.py 86.63% <100%> (+0.05%) ⬆️
scapy/contrib/openflow.py 91% <100%> (+0.05%) ⬆️
scapy/layers/tls/handshake.py 81.01% <100%> (+0.06%) ⬆️
scapy/contrib/gtp.py 88.92% <100%> (+0.57%) ⬆️
scapy/layers/inet.py 70.1% <100%> (ø) ⬆️
scapy/contrib/igmp.py 100% <100%> (ø) ⬆️
scapy/layers/tls/handshake_sslv2.py 92.01% <100%> (+0.06%) ⬆️
... and 9 more

@p-l- p-l- assigned p-l- and unassigned guedou May 16, 2018
@p-l- p-l- force-pushed the enh-arp branch 2 times, most recently from c055fc2 to 7b9ccf4 Compare May 16, 2018 19:23
@p-l- p-l- force-pushed the enh-arp branch 4 times, most recently from bcff287 to 58d544d Compare May 16, 2018 21:29
@p-l- p-l- assigned guedou and unassigned p-l- May 16, 2018
Copy link
Copy Markdown
Member

@guedou guedou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool PRs. I made some minor comments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to catch a specific exception here? Otherwise please catch Exception

scapy/utils.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for except. This also applies to the others try/except blocks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're totally right. I'll have a look.

p-l- added 9 commits May 17, 2018 13:18
This uses MultipleTypeField() for {hw,p}{dst,src} fields, to achieve
two goals:

  - Make ARP() usable with other {hw,p}types than Ether and IP.

  - Keep ARP() as simple as possible.

Notes:

  - raw(ARP()) returns the same result as before.

  - ARP(pytpe="IPv4") works and raw(ARP(pytpe="IPv4")) == raw(ARP())

  - ARP(ptype="IPv6") now works, plen is then set to 16 and psrc &
    pdst fields are IPv6 addresses:

      ARP(raw(ARP(ptype="IPv6"))).pdst == "::"
@p-l-
Copy link
Copy Markdown
Member Author

p-l- commented May 17, 2018

@guedou fixed, thanks for your fast review!

@guedou guedou merged commit 29c07fa into secdev:master May 17, 2018
@p-l- p-l- deleted the enh-arp branch May 17, 2018 12:58
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

Successfully merging this pull request may close these issues.

4 participants