Giter Site home page Giter Site logo

0xc0da / cymru-asnmap Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 4.0 8 KB

Bulk IP to ASN submission to the Team Cymru Whois server. More info: http://www.team-cymru.org/IP-ASN-mapping.html

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

cymru-asnmap's People

Contributors

0xc0da avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cymru-asnmap's Issues

Python 2 to 3 incompatibilities

Since Python 2.7 and 3.5 are deprecated, the wrapper script breaks in some obvious and some less obvious places. If nothing else I wanted to share this in the hopes of saving you (or others who use this wrapper) some debugging time:

The obvious:
print statements print x statements need to be replaced with print(x)

The not so obvious:

  • bytes vs. strings:

The actual cymru WHOIS query requires that the data passed in be a bytearray, and returns the bulk query results as a bytearray.
In current versions of Python this means the code breaks when passing in a .txt file (using the -f option).

However, the csv.writer module (used in the to_csv() function) is no longer compatible with bytes arrays; csv.writer() now only supports iterables of strings or numbers. (See https://docs.python.org/3/library/csv.html#writer-objects)

These both result in TypeErrors:
Unable to proceed Error: a bytes-like object is required, not 'str'

Make queries faster

Queries take an averange of 1m30 to complete. With netcat, the average time is less than 1s.

Example:

$ time python cymru-asnmap.py <redacted>

real    1m21.474s
user    0m0.040s
sys 0m0.012s

$ time netcat whois.cymru.com 43 < ips.txt | sort -n > list02

real    0m0.299s
user    0m0.000s
sys 0m0.008s

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.