Skip to main content

A multiprocessing async ping scanner

Project description

Intro

My attempt at making a ping scanner using python.

Basically I needed a good tool to quickly scan large IP ranges, so I rolled my own.

Packet building is in cython, sending the packets is done with multiprocessing, while receiving and processing is done in async.

At the moment only working on Linux, for IPv4.

Code is probably quite rough around the edges, and while I don’t expect it to break dramatically, you could encounter issues. Feel free to report anything.

Installation

To install first make sure you have the required header files to compile the C extensions:

Apt (Ubuntu, Debian): sudo apt-get install python3-dev

Yum (CentOS, RHEL): sudo yum install python36-devel

Then install from pypi as usual:

pip install pingscan

Usage

You need root or CAP_NET_RAW to send pings

You can scan either a combination of ip/netmask, or a list of networks in shortened form (e.g. ‘192.168.0.0/24’)

import pingscan

pingscan.scan('192.168.0.0', '255.255.255.0')

OR

pingscan.scan(['192.168.0.0/24', '192.168.1.0/24', '127.0.0.1'])

Will return a list of ip addresses that answered the ping - e.g. [‘192.168.0.1’, ‘192.168.0.2’]

Contributions/Feedback

Feel free to comment, report issues, give feedback or contribute in any way

Feature requests are also welcome

Not supported

Multithreading and multiprocessing - possible, but I didn’t see a reason

Response time of each host - if anyone requests this I can add it

Performance Tuning

Some generic commands in case you run into trouble with linux sockets and the netstack

Increasing socket read and write memory:

sysctl -w net.core.wmem_max=134217728

sysctl -w net.core.rmem_max=134217728

If you’re going for a large local segment with > 256 hosts you may need to configure this (so you ARP table doesn’t fill up) (feel free to play with these values)

net.ipv4.neigh.default.gc_thresh1 = 4096

net.ipv4.neigh.default.gc_thresh2 = 8192

net.ipv4.neigh.default.gc_thresh3 = 65535

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pingscan-1.0.2.tar.gz (31.7 kB view details)

Uploaded Source

File details

Details for the file pingscan-1.0.2.tar.gz.

File metadata

  • Download URL: pingscan-1.0.2.tar.gz
  • Upload date:
  • Size: 31.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pingscan-1.0.2.tar.gz
Algorithm Hash digest
SHA256 2b7633e197ea412daf375f1bff288691e36c5d830dadfa56e28a48aad74228cb
MD5 895475aeba2d631bf5d0ffaa85f061b4
BLAKE2b-256 1fd89be77b21160fb4660b83c39a578acbc8afde99f715c8b2d3175bc8328d29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page