Skip to main content

Port Scanner for Python3+

Project description

Python Port Scanner v0.3

Build Status

An easy to use Python3 package that could perform port scanning conveniently.

An output example is showed as following:
Output Example

Installation

Install with pip

pip install pyportscanner

Install with setup scripts

  1. Clone or download this repository.
  2. Install the package using python setup.py install.
  3. Voilà! You are ready to go!

QuickStart

  1. Add from pyportscanner import pyscanner to the beginning of your code.
  2. Initialize a new PortScanner object using scanner = pyscanner.PortScanner(target_ports=100, timeout=10, verbose=True).
  3. Then call scanner.scan(objective) to perform a port scan to a specific target. The target could either be an IPv4 address or a host name.
  4. Note that the total scan time for a target website is highly related to the timeout value set for the Scanner object. Thus for the seek of efficiency, the timeout should not be too long.

Documentation

class pyportscanner.pyscanner.PortScanner(target_ports=None, thread_limit=100, timeout=10, verbose=False)

PortScanner is the class provides methods to execute the port scan request. A PortScanner object is needed for performing the port scan request.

  • target_ports can be a list or int. If this args is a list, then the list of ports specified by it is going to be scanned, default to all ports we have in file. If this args is an int, then it specifies the top X number of ports to be scanned based on usage frequency rank.
  • thread_limit is the number of thread being used for scan.
  • timeout is the timeout for the socket to wait for a response.
  • verbose specifies whether the results would be print out or not. If True, results will be print out.

Functions

PortScanner.scan(objective, message = '')

Scan an objective with the given message included in the packets sent out.

  • objective is the target that is going to be scanned. It could be an IPv4 address or a hostname.
  • message is the message that is going to be included in the scanning packets sent out. If not provided, no message will be included in the packets.

An example usage case is showed in examples/PortScanExample.py.

Unit Test

In order to run unit test, execute the following command under the root directory.

pytest --cov pyportscanner/ tests/

Change logs

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

pyportscanner-0.3.2.tar.gz (214.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyportscanner-0.3.2-py3-none-any.whl (224.2 kB view details)

Uploaded Python 3

File details

Details for the file pyportscanner-0.3.2.tar.gz.

File metadata

  • Download URL: pyportscanner-0.3.2.tar.gz
  • Upload date:
  • Size: 214.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.1

File hashes

Hashes for pyportscanner-0.3.2.tar.gz
Algorithm Hash digest
SHA256 1cc115fb00b4ad7856884ca414035e6bae56bf316aa1325e78600606bcd1c074
MD5 00207b1fe4d876affb275343a7b1e3f0
BLAKE2b-256 2947978a2e9028af2a6686a21e284d93a5790f6910e3c0df5a611333d43476df

See more details on using hashes here.

File details

Details for the file pyportscanner-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pyportscanner-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 224.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.1

File hashes

Hashes for pyportscanner-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d69dd4aa8fbe0b13ec0de370268871562db261acfb9a82ea66cd48d57b1c7aab
MD5 fdd97e4e58982900200adcf66c60e4fe
BLAKE2b-256 35d7b0c4c7a26265fdd9f7b7ceaf20500fe05f87935ab7e602f8384a52bd5bc1

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