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

[Draft Pull Request] Proof of concept Mac utun support #4100

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mbUSC
Copy link

@mbUSC mbUSC commented Aug 21, 2023

Resolves #4049

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #4100 (8af2e41) into master (f37c402) will increase coverage by 0.26%.
Report is 25 commits behind head on master.
The diff coverage is 34.28%.

@@            Coverage Diff             @@
##           master    #4100      +/-   ##
==========================================
+ Coverage   81.68%   81.95%   +0.26%     
==========================================
  Files         328      328              
  Lines       75497    75875     +378     
==========================================
+ Hits        61668    62181     +513     
+ Misses      13829    13694     -135     
Files Changed Coverage Δ
scapy/layers/tuntap.py 73.77% <34.28%> (-9.06%) ⬇️

... and 40 files with indirect coverage changes

@guedou
Copy link
Member

guedou commented Aug 21, 2023

Thanks for this PR. I will give it a try. In the meantine, could you fix the PEP-08 issues https://github.com/secdev/scapy/actions/runs/5920584081/job/16053137679?pr=4100#step:5:1 ?

self.kernel_packet_class = MacOSUtunPacketInfo
self.mtu_overhead = 4

match = re.match(r"([a-z]+)([0-9]+)", self.iface.decode("utf-8"), re.I)
Copy link
Contributor

@micolous micolous Aug 28, 2023

Choose a reason for hiding this comment

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

Don't need to import re or decode bytestrings - just strip the prefix (b'utun') from the string:

# self.iface = b'utun0'
interface_num = int(self.iface[4:])

elif BSD:
if not (self.iface.startswith(b"tap") or
self.iface.startswith(b"tun") or
self.iface.startswith(b"utun")):
Copy link
Contributor

@micolous micolous Aug 28, 2023

Choose a reason for hiding this comment

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

utun is Darwin-specific, so shouldn't be attempted on BSD.

However, tap and tun on Darwin are provided by a third-party kext (which works the same way as BSD's tap and tun), so Darwin will still need to hit this BSD branch.

IntField("addr_family", socket.AF_INET)
]

def guess_payload_class(self, payload):
Copy link
Contributor

Choose a reason for hiding this comment

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

Use bind_layers() rather than implementing guess_payload_class.

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.

Interface names must start with tun or tap on BSD and Darwin
3 participants