projectdiscovery / mapcidr

Utility program to perform multiple operations for a given subnet/CIDR ranges.
https://projectdiscovery.io
MIT License
977 stars 91 forks source link

[Issue] Filtered IPs should not show up in aggregate subnets #473

Closed coffeegist closed 1 week ago

coffeegist commented 1 month ago

Describe the bug I expect, if I filter input using the -fi command, and then aggregate with -a to the minimum number of subnets, that the subnets generated would match the output given if -a is not provided. However, the filtered IPs are added back in after aggregating. Is there another way to exclude IPs and aggregate them back to the minimal subnets that do not include the filtered addresses?

Mapcidr version Include the version of mapcidr you are using, mapcidr -version

$ mapcidr --version                                                                                                                                                                                                                       

                   ____________  ___    
  __ _  ___ ____  / ___/  _/ _ \/ _ \   
 /  ' \/ _ '/ _ \/ /___/ // // / , _/   
/_/_/_/\_,_/ .__/\___/___/____/_/|_|
          /_/                                                            

                projectdiscovery.io

[INF] Current Version: v1.1.34
$ mapcidr -silent -cl 10.0.0.0/30                                                                                                                                                                                                         
10.0.0.0
10.0.0.1
10.0.0.2
10.0.0.3

$ mapcidr -silent -cl 10.0.0.0/30 -fi 10.0.0.1
10.0.0.0
10.0.0.2
10.0.0.3

$ mapcidr -silent -cl 10.0.0.0/30 -fi 10.0.0.1 -a
10.0.0.0/30
coffeegist commented 1 month ago

I suppose a workaround would be the following

$ mapcidr -silent -cl 10.0.0.0/30 -fi 10.0.0.1 | mapcidr -silent -a
10.0.0.0/32
10.0.0.2/31