-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix #4431 - Allow DHCP Answering Machine to have multiple namesevers #4638
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
Open
mzen17
wants to merge
11
commits into
secdev:master
Choose a base branch
from
mzen17:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a982da5
DHCPAM: Make_reply to use raw to inject IP.
mzen17 23f9dfc
REFACT: Removed whitespace.
mzen17 20f5d0b
REFACT: Minimize make_reply routes.
mzen17 cd8de29
BUG: namesaver not referencing self
mzen17 d6d7465
IMPL: Utilize IP to solve multiple ns
mzen17 d42fc74
REFACT: Fix style
mzen17 d3d8713
IMPL: DHCP_am tests
mzen17 c79516a
Merge branch 'secdev:master' into master
mzen17 2a62d6c
REFAC: Move flatten to parseopt
mzen17 56b4cf8
IMPL: unpack+None handle
mzen17 ecf7f44
Merge branch 'secdev:master' into master
mzen17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how it was tested but it doesn't work in the sense that the option isn't included in DHCP replies at all.
I'm not sure it's necessary to add
ip_to_bytes
either. scapy can turn IP sequences into DHCP options out of the box.self.nameserver
should be unpacked withto get it to work when something like
DHCP_am(nameserver=('1.2.3.4', '5.6.7.8'))
is used.Just out of curiosity looking at the comments I wonder if the code is autogenerated with some sort of an AI assistant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting.
I was playing around with your suggestion to unpack it, however, it was retrieving only the first nameserver rather than both the nameserver. Like, if I used ('1.2.3.4', '5.6.7.8'), it would only get ('1.2.3.4'). The previous method I was using didn't work after examining the output again
I was testing it by inserting this to the end of the make_reply (before it returns).
Just the ip_to_bytes function was AI generated. It was generated with the function comment and a force to use inet_ion and concat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's how it currently works so maybe
make_reply
wasn't edited. With the following patch appliedit should work with more than one IP address (but it doesn't work with one IP address). The idea is to flatten the list. For example here is how it works outside the answering machine:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I adjusted the if statement so that the string is transformed into a tuple if an IP such as "1.1.1.1,2.2.2.2" is used. It also works on sole strings such as "1.1.1.1".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I don't think
split
is needed. I think it should support 2 use cases likeand
but I'd wait for the second opinion.
(It would probably be great to add a test to https://github.com/secdev/scapy/blob/master/test/answering_machines.uts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works but the default second nameserver will be 192.168.0.50 when the input value is blank.
How can it keep blank value when we don't input the second nameserver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't be empty because it's set to
gw
by default inscapy/scapy/layers/dhcp.py
Line 624 in 3e00f42
scapy/scapy/layers/dhcp.py
Line 608 in 3e00f42
FWIW I think it would be better to set
nameserver
inparse_options
instead and then flatten it inmake_reply
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I would agree that parse options makes more sense as a location to flatten it. I did use the comma seperated values because that was what the original issue mentioned (#4431).