./redteamer

Functions

Network Functions

Functions for working with networking and IP addresses.


Address Calculation

These functions are used to calculate IP addresses or address ranges within a given IP network.

cidr_host

The net::cidr_host function calculates a full host IP address for a specific host number within a given IP network address prefix.

net::cidr_host("192.168.10.0/24", 25)
# Result: "192.168.10.25"

net::cidr_host("172.20.0.0/16", 500)
# Result: "172.20.1.244"

net::cidr_host("fd00:abcd:1234:5678::/64", 100)
# Result: "fd00:abcd:1234:5678::64"

net::cidr_host("10.0.0.0/8", 1000)
# Result: "10.0.3.232"

net::cidr_host("203.0.113.0/26", 50)
# Result: "203.0.113.50"

cidr_subnet

The net::cidr_subnet function calculates a subnet address within a given IP network address prefix.

net::cidr_subnet("192.0.2.0/24", 3, 1)
# Result: "192.0.2.32/27"

net::cidr_subnet("198.51.100.0/22", 2, 3)
# Result: "198.51.102.0/24"

net::cidr_subnet("fd00:abcd:1234::/48", 8, 10)
# Result: "fd00:abcd:1234:a00::/56"

net::cidr_subnet("203.0.113.0/25", 2, 2)
# Result: "203.0.113.64/27"

net::cidr_subnet("10.10.0.0/16", 4, 4)
# Result: "10.10.64.0/20"

cidr_subnets

The net::cidr_subnets function calculates a sequence of consecutive IP address ranges within a specific CIDR prefix.

net::cidr_subnets("192.168.0.0/16", 4, 4, 4, 4)
# Result: ["192.168.0.0/20", "192.168.16.0/20", "192.168.32.0/20", "192.168.48.0/20"]

net::cidr_subnets("fd00:abcd:1234::/48", 8, 8, 8, 8)
# Result: ["fd00:abcd:1234::/56", "fd00:abcd:1234:100::/56", "fd00:abcd:1234:200::/56", "fd00:abcd:1234:300::/56"]

Address Conversion

These functions convert between different forms of representing an IP network.

cidr_netmask

The net::cidr_netmask function converts an IPv4 address prefix, provided in CIDR notation, into a subnet mask address.

net::cidr_netmask("203.0.113.0/26")
# Result: "255.255.255.192"

net::cidr_netmask("198.51.100.0/23")
# Result: "255.255.254.0"

net::cidr_netmask("192.0.2.0/28")
# Result: "255.255.255.240"
Previous
Generation Functions