Giter VIP home page Giter VIP logo

epdip's Introduction

epdip

A simple but efficient script for expanding IP addresses in dash format, optimized with bitwise operations and multithreading.

Cheat Sheet

  • ./epdip.sh A.B.C.D-E.F.G.H -s
  • ./epdip.sh A.B.C.D-E.F.G.H -o ips.list
  • ./epdip.sh -f ip_ranges.list -m -o ips.list

Context

Sometimes, you might get ip addresses in a dash format like A.B.C.D-E.F.G.H:

10.10.10.253-10.10.11.3

However, what you need is a complete list of addresses:

10.10.10.253
10.10.10.254
10.10.10.255
10.10.11.1
10.10.11.2
10.10.11.3

So, here is the epdip for you!

Usage

First, you can check the usage by simply execute epdip alone:

$ ./epdip.sh
Usage: ./epdip.sh [-f ip_range_file / ip_range] [-m] [-o output_file] [-s]

-f|--file
    Specify a list of IP ranges for expanding operations. 
-m|--multithreading
    Expand multiple IP ranges parallelly, which may cause out-of-order output. 
-o|--outputfile
    Specify a file to store expanded IPs. 
-s|--silence
    Don't print information messages additional to IPs. 

As for the simplest scene, let's take expanding 10.10.10.253-10.10.11.3 for example:

$ ./epdip.sh 10.10.10.253-10.10.11.3
Expanding 10.10.10.253-10.10.11.3...
10.10.10.253
10.10.10.254
10.10.10.255
10.10.11.1
10.10.11.2
10.10.11.3
Expanding 10.10.10.253-10.10.11.3 succeeded!

When you have a list of IP ranges:

$ cat ip_ranges.list
10.10.10.255-10.10.11.2
10.10.14.255-10.10.15.2

$ ./epdip.sh -f ip_ranges.list
Expanding 10.10.10.255-10.10.11.2...
10.10.10.255
10.10.11.1
10.10.11.2
Expanding 10.10.10.255-10.10.11.2 succeeded!
Expanding 10.10.14.255-10.10.15.2...
10.10.14.255
10.10.15.1
10.10.15.2
Expanding 10.10.14.255-10.10.15.2 succeeded!

When you feel it's too slow:

$ ./epdip.sh -f ip_ranges.list -m
Expanding 10.10.10.255-10.10.11.2...
Expanding 10.10.14.255-10.10.15.2...
10.10.10.255
10.10.14.255
10.10.11.1
10.10.11.2
Expanding 10.10.10.255-10.10.11.2 succeeded!
10.10.15.1
10.10.15.2
Expanding 10.10.14.255-10.10.15.2 succeeded!

When you need to specify a output file:

$ ./epdip.sh -f ip_ranges.list -o ips.list
Expanding 10.10.10.255-10.10.11.2...
Expanding 10.10.14.255-10.10.15.2...
Expanding 10.10.10.255-10.10.11.2 succeeded!
Expanding 10.10.14.255-10.10.15.2 succeeded!

$ cat ips.list
10.10.10.255
10.10.11.1
10.10.11.2
10.10.14.255
10.10.15.1
10.10.15.2

When you would like to remove the information messages:

$ ./epdip.sh -f ip_ranges.list -s
10.10.10.255
10.10.11.1
10.10.11.2
10.10.14.255
10.10.15.1
10.10.15.2

Performance Increasing

  • Normal Execution:
    $ time ./epdip.sh -f ip_range.list -o ips.list -s
    
    real    0m26,176s
    user    0m19,856s
    sys     0m6,288s
    
  • Multithreading Execution:
    $ time ./epdip.sh -f ip_range.list -o ips.list -m -s
    
    real    0m7,437s
    user    0m25,613s
    sys     0m9,079s
    

epdip's People

Contributors

leviliangtw avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.