Categories: Kali Linux

MapCIDR : Small Utility Program To Perform Multiple Operations For A Given sub-net/CIDR Ranges

MapCIDR is a small utility program to perform multiple operations for a given subnet/CIDR ranges.

The tool was developed to ease load distribution for mass scanning operations, it can be used both as a library and as independent CLI tool.

Features

  • Simple and modular code base making it easy to contribute.
  • CIDR distribution for distributed scanning.
  • Stdin and stdout support for integrating in workflows

Installation

  • From Source

▶ GO111MODULE=auto go get -u github.com/projectdiscovery/mapcidr/cmd/mapcidr

  • From Github

▶ git clone https://github.com/projectdiscovery/mapcidr.git; cd mapcidr/cmd/mapcidr; go build .; cp mapcidr /usr/local/bin

Usage

▶ mapcidr -h

This will display help for the tool. Here are all the switches it supports.

FlagDescriptionExample
-cidrSingle CIDR to processmapcidr -cidr 173.0.84.0/24
-sbcSlice by CIDR countmapcidr -sbc 10
-sbhSlice by HOST countmapcidr -sbh 10000
-lFile containing list of CIDRsmapcidr -l cidr.txt
-oFile to write output to (optional)mapcidr -o output.txt
-silentMake the output silentmapcidr -silent
-versionPrint current version of mapcidr clientmapcidr -version

Running mapCIDR

In order to get list of IPs for a give CIDR, use the following command.

▶ mapcidr -cidr 173.0.84.0/24
▶ echo 173.0.84.0/24 | mapcidr

Slice by CIDR

In order to slice given CIDR or list of CIDR by CIDR count or slice into multiple and equal smaller subnets, use the following command.

▶ mapcidr -cidr 173.0.84.0/24 -sbc 10 -silent
▶ echo 173.0.84.0/24 | mapcidr -sbc 10 -silent

Slice by HOST

In order to slice given CIDR for equal number of host count in each CIDR, use the following command.

▶ mapcidr -cidr 173.0.84.0/16 -sbh 20000 -silent
▶ echo 173.0.84.0/16 | mapcidr -sbh 20000 -silent

Note: it’s possible to obtain a perfect split only when the desired amount of slices or hosts per subnet is a powers of two. Otherwise the tool will attempt to automatically find the best split strategy to obtain the desired outcome.

Use mapCIDR as a library

It’s possible to use the library directly in your go programs. The following code snippets outline how to divide a cidr into subnets, and how to divide the same into subnets containing a certain number of hosts

package main
import (
“fmt”
“github.com/projectdiscovery/mapcidr”
)
func main() {
// Divide the CIDR into two subnets
subnets1 := mapcidr.SplitN(“192.168.1.0/24”, 2)
for , subnet := range subnets1 { fmt.Println(subnet) } // Divide the CIDR into two subnets containing 128 hosts each subnets2 := mapcidr.SplitByNumber(“192.168.1.0/24”, 128) for , subnet := range subnets2 {
fmt.Println(subnet)
}
// List all ips in the CIDR
ips, _ := mapcidr.Ips(“192.168.1.0/24”)
for _, ip := range ips {
fmt.Println(ip)
}
}

mapCDIR is made with 🖤 by the projectdiscovery team.

R K

Recent Posts

Kali Linux 2024.4 Released, What’s New?

Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…

4 hours ago

Lifetime-Amsi-EtwPatch : Disabling PowerShell’s AMSI And ETW Protections

This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…

4 hours ago

GPOHunter – Active Directory Group Policy Security Analyzer

GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…

2 days ago

2024 MITRE ATT&CK Evaluation Results – Cynet Became a Leader With 100% Detection & Protection

Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…

5 days ago

SecHub : Streamlining Security Across Software Development Lifecycles

The free and open-source security platform SecHub, provides a central API to test software with…

1 week ago

Hawker : The Comprehensive OSINT Toolkit For Cybersecurity Professionals

Don't worry if there are any bugs in the tool, we will try to fix…

1 week ago