Eli Fulkerson .com HomeProjectsXips
 

xips

"xips" (for eXpand IPS) is a console program that parses stdin for ip addresses and "summarized" ip addresses and outputs them individually, suitable for use with xargs. For instance:

echo 172.20.141.0/24 | xips | xargs -n 1 tcping -n 1

Alternatively, with the "-s" or "--summarize" flag, xips will take the same input and attempt to summarize those ip addressess into IP ranges, suitable for use in (for instance) Cisco ASA configuration files. By default it will make (ipv4) subnets no smaller than /24, but that is adjustable via -m.

I am using the same ip address range syntax as in ips. (which is an IP address range aware grep-like tool)

Usage:


Syntax: your_command | xips [-4] [-6] [-v]

Eats STDIN, expands IP addresses.
Options:
 -4     : expand IPv4 addresses only
 -6     : expand IPv6 addresses only
 -s     : summarize, rather than expand
 --sort : expand and sort numerically
 -m X   : summarize to a max depth of /X (also --max-depth X)
 -c     : output /cidr notation rather than subnet mask
 --asa  : output asa network-object notation
 -v     : Display version information
 --max-depth-ipv4 X : summarize to a max cidr of X for IPv4 only
 --max-depth-ipv6 X : summarize to a max cidr of X for IPv6 only

IP/Range Syntax:
 192.168.1.1
 192.168.1.1-192.168.1.255
 192.168.1.1/24
 192.168.1.1/C
 '192.168.1.1 255.255.255.0'
 192.168.1.5-15


Action shots:


$echo 192.168.100.5-10 | xips
192.168.100.5
192.168.100.6
192.168.100.7
192.168.100.8
192.168.100.9
192.168.100.10

$cat example.txt
192.168.0.1
192.168.0.2
192.168.0.3
10.0.10.0
10.0.10.1
10.0.10.2
10.0.10.3
10.0.10.4
10.0.10.5
10.0.10.200
172.20.5.6
172.20.5.6

$cat example.txt | xips -s
10.0.10.0 255.255.255.0
172.20.5.0 255.255.255.0
192.168.0.0 255.255.255.0

$cat example.txt | xips -s -m 30
10.0.10.0 255.255.255.248
10.0.10.200 255.255.255.252
172.20.5.4 255.255.255.252
192.168.0.0 255.255.255.252

$echo "192.168.20.1-5" | xips | xargs -n 1 tcping -n 1

Probing 192.168.20.1:80/tcp - Port is open - time=0.782ms

Ping statistics for 192.168.20.1:80
     1 probes sent.
     1 successful, 0 failed.
Approximate trip times in milli-seconds:
     Minimum = 0.782ms, Maximum = 0.782ms, Average = 0.782ms

Probing 192.168.20.2:80/tcp - Port is open - time=0.813ms

Ping statistics for 192.168.20.2:80
     1 probes sent.
     1 successful, 0 failed.
Approximate trip times in milli-seconds:
     Minimum = 0.813ms, Maximum = 0.813ms, Average = 0.813ms

Probing 192.168.20.3:80/tcp - No response - time=2001.949ms

Ping statistics for 192.168.20.3:80
     1 probes sent.
     0 successful, 1 failed.
Was unable to connect, cannot provide trip statistics.

Probing 192.168.20.4:80/tcp - No response - time=2001.538ms

Ping statistics for 192.168.20.4:80
     1 probes sent.
     0 successful, 1 failed.
Was unable to connect, cannot provide trip statistics.

Probing 192.168.20.5:80/tcp - Port is open - time=1.107ms

Ping statistics for 192.168.20.5:80
     1 probes sent.
     1 successful, 0 failed.
Approximate trip times in milli-seconds:
     Minimum = 1.107ms, Maximum = 1.107ms, Average = 1.107ms


Downloads:


Listing directory https://download.elifulkerson.com/files/xips/0.5:
Makefile April 23 2018 14:48:30 71 makefile script, ASCII text xips.cpp April 30 2018 17:43:08 41045 C++ source, ASCII text, with CRLF line terminators xips.cpp.asc May 01 2018 13:29:14 801 GnuPG signature xips.cpp.md5 May 01 2018 13:29:14 43 MD5 checksum xips.cpp.sha1 May 01 2018 13:29:14 51 SHA1 checksum xips.cpp.sha256 May 01 2018 13:29:14 75 SHA256 checksum xips.cpp.sha512 May 01 2018 13:29:14 139 SHA512 checksumBrowse the download server

To compile: g++ -std=c++11 -o xips xips.cpp

Updates:

Update: Jan 5 2018, v0.1. Initial release.

Update: Jan 6 2018, v0.2. Fix so it compiles properly with -std=c++11. Added .exe version for windows folks (you will need the cygwin dlls).

Update: Apr 5 2018, v0.3. Oops - some of the formats were broken because I made some bad assumptions. /C, /24 and more variations of "-", "to", etc will work correctly now. Also "thru", because of John.

Update: Apr 23 2018, v0.4. Added "--sort" - for outputting single IP addresses sorted by byte order, rather than input order.

Update: Apr 30 2018, v0.5. Added "--asa" - which outputs the format "network-object host blah" etc. Also changed summary to have default max depth of /32.

License:

GPLv3

See Also:

ips - an ip address aware "grep" analog which xips' parsing logic is based on