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

HostsInCIDR improvement #107

Merged
merged 1 commit into from
Feb 20, 2022
Merged

HostsInCIDR improvement #107

merged 1 commit into from
Feb 20, 2022

Conversation

NickChillClub
Copy link
Contributor

@NickChillClub NickChillClub commented Jun 27, 2021

Changed the code for HostsInCIDR, It's easier from byte level.
Changed info on the scan flags you are able to do comma separated as well.
Changed a few lines to Sprintf as it's better to read.

@leonjza
Copy link
Member

leonjza commented Jun 28, 2021

Thanks for the PR! 🙌

I think I might not understand this well (apologies for that!), but I worry a bit about the overall readability of HostsInCIDR after this change. Is there a specific problem this solves for CIDR calculation?

The rest of the changes look 👌 !

@NickChillClub
Copy link
Contributor Author

NickChillClub commented Jun 28, 2021

There is no specific problem other than it's faster.
I'm a big fan of optimising, faster code and better use of the Golang standard packages.
This is more efficient, cleaner and the same method is used in the other code languages for ages. To get the range of a cidr the easiest way is to convert it to integer. Then only what you have to do is increment. To check if it's a network or broadcast address you can check if the least significant byte is set to 0, in the last octet, with 0xFF and ignore if the result is 0 or 255.

@leonjza leonjza merged commit 71125b2 into sensepost:master Feb 20, 2022
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.

2 participants