{"id":13581997,"url":"https://github.com/projectdiscovery/mapcidr","last_synced_at":"2025-05-13T22:09:24.429Z","repository":{"id":37381339,"uuid":"289295869","full_name":"projectdiscovery/mapcidr","owner":"projectdiscovery","description":"Utility program to perform multiple operations for a given subnet/CIDR ranges.","archived":false,"fork":false,"pushed_at":"2025-05-04T23:56:02.000Z","size":1319,"stargazers_count":1087,"open_issues_count":10,"forks_count":99,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-05-08T00:45:54.664Z","etag":null,"topics":["cidr","cidr-ranges","subnetting","subnetwork"],"latest_commit_sha":null,"homepage":"https://projectdiscovery.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/projectdiscovery.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-21T14:57:44.000Z","updated_at":"2025-05-07T22:23:24.000Z","dependencies_parsed_at":"2023-02-16T17:31:18.375Z","dependency_job_id":"f07974e2-bb74-4067-90a5-f92ca5563be2","html_url":"https://github.com/projectdiscovery/mapcidr","commit_stats":{"total_commits":537,"total_committers":18,"mean_commits":"29.833333333333332","dds":"0.35940409683426444","last_synced_commit":"8f361ee1def0a6fb4646bb09b41b6166bcc89dec"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectdiscovery%2Fmapcidr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectdiscovery%2Fmapcidr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectdiscovery%2Fmapcidr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/projectdiscovery%2Fmapcidr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/projectdiscovery","download_url":"https://codeload.github.com/projectdiscovery/mapcidr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036830,"owners_count":22003654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","cidr-ranges","subnetting","subnetwork"],"created_at":"2024-08-01T15:02:22.451Z","updated_at":"2025-05-13T22:09:19.401Z","avatar_url":"https://github.com/projectdiscovery.png","language":"Go","readme":"\n\u003ch1 align=\"center\"\u003e\n  \u003cimg src=\"static/mapCIDR-logo.png\" alt=\"mapCIDR\" width=\"180px\"\u003e\u003c/a\u003e\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eA utility program to perform multiple operations for a given subnet/cidr ranges.\u003c/h4\u003e\n\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/projectdiscovery/mapcidr/issues\"\u003e\u003cimg src=\"https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/projectdiscovery/mapcidr/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/projectdiscovery/mapcidr\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/pdiscoveryio\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/pdiscoveryio.svg?logo=twitter\"\u003e\u003c/a\u003e\n\u003ca href=\"https://discord.gg/projectdiscovery\"\u003e\u003cimg src=\"https://img.shields.io/discord/695645237418131507.svg?logo=discord\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n      \n\u003cp align=\"center\"\u003e\n  \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e •\n  \u003ca href=\"#installation\"\u003eInstall\u003c/a\u003e •\n  \u003ca href=\"#running-mapcidr\"\u003eUsage\u003c/a\u003e •\n  \u003ca href=\"#use-mapcidr-as-a-library\"\u003eLibrary\u003c/a\u003e •\n  \u003ca href=\"https://discord.gg/projectdiscovery\"\u003eJoin Discord\u003c/a\u003e\n\u003c/p\u003e\n\n----\n\nmapCIDR is developed to ease load distribution for mass scanning operations, it can be used both as a library and as independent CLI tool.\n\n# Features\n\n\u003ch1 align=\"left\"\u003e\n  \u003cimg src=\"static/mapCIDR-run.png\" alt=\"mapCIDR\" width=\"700px\"\u003e\u003c/a\u003e\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n - **CIDR expansion** support (**default**)\n - **CIDR slicing** support (`sbh`, `sbc`)\n - **CIDR/IP aggregation** support (`a`, `aa`)\n - **CIDR/IP matcher** support (`match-ip`)\n - **CIDR/IP filter** support (`filter-ip`)\n - **CIDR/IP sorting** support (`s`, `sr`)\n - **CIDR host count** support (`count`)\n - Multiple **IP Format** support (`ip-format`)\n - IP/PORT shuffling support (`si`, `sp`)\n - **IPv4/IPv6 Conversation** support (`t4`, `t6`)\n - CIDR STDIN (pipe) input support\n\n# Installation\n\n```sh\ngo install -v github.com/projectdiscovery/mapcidr/cmd/mapcidr@latest\n```\n\n# Usage\n\n```sh\nmapcidr -h\n```\n\nThis will display help for the tool. Here are all the switches it supports.\n\n```yaml\nINPUT:\n   -cl, -cidr string[]  CIDR/IP/File containing list of CIDR/IP to process\n\nPROCESS:\n   -sbc int                  Slice CIDRs by given CIDR count\n   -sbh int                  Slice CIDRs by given HOST count\n   -a, -aggregate            Aggregate IPs/CIDRs into minimum subnet\n   -aa, -aggregate-approx    Aggregate sparse IPs/CIDRs into minimum approximated subnet\n   -c, -count                Count number of IPs in given CIDR\n   -t4, -to-ipv4             Convert IPs to IPv4 format\n   -t6, -to-ipv6             Convert IPs to IPv6 format\n   -ip-format, -if string[]  IP formats (0,1,2,3,4,5,6,7,8,9,10,11)\n   -zpn, -zero-pad-n int     number of padded zero to use (default 3)\n   -zpp, -zero-pad-permute   enable permutations from 0 to zero-pad-n for each octets\n\nFILTER:\n   -f4, -filter-ipv4         Filter IPv4 IPs from input\n   -f6, -filter-ipv6         Filter IPv6 IPs from input\n   -skip-base                Skip base IPs (ending in .0) in output\n   -skip-broadcast           Skip broadcast IPs (ending in .255) in output\n   -mi, -match-ip string[]   IP/CIDR/FILE containing list of IP/CIDR to match (comma-separated, file input)\n   -fi, -filter-ip string[]  IP/CIDR/FILE containing list of IP/CIDR to filter (comma-separated, file input)\n\nMISCELLANEOUS:\n   -s, -sort                  Sort input IPs/CIDRs in ascending order\n   -sr, -sort-reverse         Sort input IPs/CIDRs in descending order\n   -si, -shuffle-ip           Shuffle Input IPs in random order\n   -sp, -shuffle-port string  Shuffle Input IP:Port in random order\n\nUPDATE:\n   -up, -update                 update mapcidr to latest version\n   -duc, -disable-update-check  disable automatic mapcidr update check\n   \nOUTPUT:\n   -verbose            Verbose mode\n   -o, -output string  File to write output to\n   -silent             Silent mode\n   -version            Show version of the project\n```\n\n# Running mapCIDR\n\nIn order to get list of IPs for a give CIDR, use the following command.\n\n### CIDR expansion\n\n```console\nmapcidr -cidr 173.0.84.0/24\n```\n\n```console\n                   ____________  ___    \n  __ _  ___ ____  / ___/  _/ _ \\/ _ \\\n /  ' \\/ _ '/ _ \\/ /___/ // // / , _/   \n/_/_/_/\\_,_/ .__/\\___/___/____/_/|_| v0.5\n          /_/                                                     \t \n\n\t\tprojectdiscovery.io\n\n[WRN] Use with caution. You are responsible for your actions\n[WRN] Developers assume no liability and are not responsible for any misuse or damage.\n\n173.0.84.0\n173.0.84.1\n173.0.84.2\n173.0.84.3\n173.0.84.4\n173.0.84.5\n173.0.84.13\n173.0.84.14\n173.0.84.15\n173.0.84.16\n```\n\nIt is also possible to get list of IP's for a given IP range, use the following command\n```console\n$ echo \"192.168.0.0-192.168.0.5\" | mapcidr\n```\n```console\n192.168.0.0\n192.168.0.1\n192.168.0.2\n192.168.0.3\n192.168.0.4\n192.168.0.5\n```\n### CIDR Slicing by CIDR Count\n\nIn order to slice given CIDR or list of CIDR by CIDR count or slice into multiple and equal smaller subnets, use the following command.\n\n\n```console\nmapcidr -cidr 173.0.84.0/24 -sbc 10 -silent\n```\n\n```console\n173.0.84.0/27\n173.0.84.32/27\n173.0.84.64/27\n173.0.84.96/27\n173.0.84.128/27\n173.0.84.160/27\n173.0.84.208/28\n173.0.84.192/28\n173.0.84.240/28\n173.0.84.224/28\n```\n\n### CIDR slicing by HOST Count\n\nIn order to slice given CIDR for equal number of host count in each CIDR, use the following command.\n\n```console\nmapcidr -cidr 173.0.84.0/16 -sbh 20000 -silent\n```\n\n```console\n173.0.0.0/18\n173.0.64.0/18\n173.0.128.0/18\n173.0.192.0/18\n```\n\nNote: 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. \n\n### CIDR/IP Aggregation\n\nIn order to merge multiple CIDR ranges into smaller subnet block, use the following command.\n\n```console\n$ mapcidr -cl cidrs.txt -aggregate\n```\n\nIn order to list CIDR blocks for given list of IPs, use the following command.\n\n```console\n$ mapcidr -il ips.txt -aggregate\n```\n\nIt's also possible to perform approximated aggregations for sparse ips groups (only version 4). The final interval will contain contiguous ips not belonging to the input:\n\n```console\n$ cat ips.txt \n\n1.1.1.1\n1.1.1.16\n1.1.1.31\n```\n\n```console\n$ cat ips.txt | mapcidr -aggregate-approx\n\n1.1.1.0/27\n```\n\nIn order to list CIDR blocks for given IP Range (**IPv4 | IPv6**), use the following command.\n```\n $ mapcidr  -cl 192.168.0.1-192.168.0.255 -aggregate\n OR\n $ echo 192.168.0.1-192.168.0.255 | mapcidr -aggregate\n```\n```\n192.168.0.1/32\n192.168.0.2/31\n192.168.0.4/30\n192.168.0.8/29\n192.168.0.16/28\n192.168.0.32/27\n192.168.0.64/26\n192.168.0.128/25\n\n```\n### Match / Filter IP's from CIDR\n\nIn order to match IPs from the given list of CIDR ranges, use the following command.\n\n```console\n$ mapcidr -cidr 192.168.1.0/24 -mi 192.168.1.253,192.168.1.252\n$ mapcidr -cidr 192.168.1.0/24 -mi ip_list_to_match.txt\n```\n\nIn order to match IPs from the given list of CIDR ranges, use the following command.\n\n```console\n$ mapcidr -cidr 192.168.1.224/28 -fi 192.168.1.233,192.168.1.234\n$ mapcidr -cidr 192.168.1.224/28 -fi ip_list_to_filter.txt\n```\n\n### IP Formats\n\nIn order to represent given IP into multiple formats, `-if 0` flag can be used to display all the supported format values, and specific type of format can be displayed using specific index number as listed [here](https://github.com/projectdiscovery/mapcidr/wiki/IP-Format-Index), currently [10 unique formats are supported](https://github.com/projectdiscovery/mapcidr/wiki/IP-Format-Index).\n\n```console\n$ echo 127.0.1.0 | mapcidr -if 0 -silent\n\n127.0.1.0\n127.1\n0177.0.01.0\n0x7f.0x0.0x1.0x0\n0x7f000100\n0xabfa659dfa7f000100\n281472812450048\n111111111111111101111111000000000000000100000000\n0x7f.0.01.0x0\n::ffff:7f00:0100\n%31%32%37%2E%30%2E%31%2E%30\n127.000.001.000\n```\n\n\n### IP Conversion\n\n**IPv4 | IPv6** addresses can be converted from either the v6 to v4 notation or IPv4-mapped notation into IPv4 addresses using `-t4` and `-t6` to IPv4 and IPv6 respectively.\n\n```console\n$ cat ips.txt \n\n1.1.1.1\n2.2.2.2\n```\n\n```\n$ mapcidr -cl ips.txt -t6\n\n00:00:00:00:00:ffff:0101:0101\n00:00:00:00:00:ffff:0202:0202\n```\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003ch3\u003eNote:\u003c/h3\u003e\n\nNot all IPv6 address can be converted to IPv4. You can only convert valid IPv4 represented IPv6 addresses.\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n### CIDR Host Counting\n\nIn order to count number of hosts for a given CIDR or list of CIDR, use the following command.\n\n```console\n$ echo 173.0.84.0/16 | mapcidr -count -silent\n\n65536\n```\n\n### ASN Input\n\nIn order to get the IP address of ASN number, use the following command\n```\necho AS15133 | mapcidr -silent\n\n5.104.64.0\n5.104.64.1\n5.104.64.2\n5.104.64.3\n5.104.64.4\n```\n\n# Use mapCIDR as a library\n\nIt'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\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/projectdiscovery/mapcidr\"\n)\n\nfunc main() {\n\t// Divide the CIDR into two subnets\n\tsubnets1 := mapcidr.SplitN(\"192.168.1.0/24\", 2)\n\tfor _, subnet := range subnets1 {\n\t\tfmt.Println(subnet)\n\t}\n\t// Divide the CIDR into two subnets containing 128 hosts each\n\tsubnets2 := mapcidr.SplitByNumber(\"192.168.1.0/24\", 128)\n\tfor _, subnet := range subnets2 {\n\t\tfmt.Println(subnet)\n\t}\n\n\t// List all ips in the CIDR\n\tips, _ := mapcidr.IPAddresses(\"192.168.1.0/24\")\n\tfor _, ip := range ips {\n\t\tfmt.Println(ip)\n\t}\n}\n\n```\n\n\nmapCDIR is made with 🖤 by the [projectdiscovery](https://projectdiscovery.io) team.\n","funding_links":[],"categories":["Go","Go (531)","Weapons","Miscellaneous"],"sub_categories":["Tools","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectdiscovery%2Fmapcidr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprojectdiscovery%2Fmapcidr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprojectdiscovery%2Fmapcidr/lists"}