Giter VIP home page Giter VIP logo

nmapthon2's Introduction

Nmapthon2

A modern Nmap automation library for Python

Built with ❤︎ by Christian Barral.

Table of Contents

Features

  • Launch Nmap scans both synchronous and asynchronously.
  • Get information: from every single scan detail.
  • Extend Nmap's NSE with Python functions.
  • Automate NSE sciripts output parsing.
  • Check scan statuses: and save different output formats.
  • Use a set of built-in utilities.
  • Cross-platform module!

Prerequisites

  • Install the latest version from Nmap on your system
  • Make sure you have Python 3.5+

Installation

After installing Nmap, open a terminal or a Powershell and install the library:

pip install nmapthon2
  
# Or
pip3 install nmapthon2

Example

This is just a little example, check all the features in the official documentation

import nmapthon2 as nm2
  
scanner = nm2.NmapScanner()
result = scanner.scan(['192.168.0.0/24', 'localhost'], ports='1-1024', arguments='-sS -sV')

for host in result:
    print(f'I discovered {host.ipv4}!')
    os = host.most_accurate_os()
    if os:
        print(f'O.S: {os.name}')
    
    for port in host:
        if port.service:
            print(f'  Executed scripts from {port.number}/{port.protocol})')
            for script_name, script_output in port.service.all_scripts():
                print(f'{script_name} - {script_output}')

NSE

Register your own NSE parsers, host scripts and port scripts as Python code. with a single line of code.

import nmapthon2 as nm2

scanner = nm2.NmapScanner()
engine = nm2.NSE()
  
# Example of host script
@engine.host_script('my-host-script')
def my_host_script(host):
    try:
        target = host.hostnames()[0]
    except IndexError:
        target = host.ipv4
    print(f'Launching security check number 1 against {target}')
    
    return 'Vulnerable'
  
@engine.port_script('is-nginx', [80, 443, 8080], proto='tcp')
def my_port_script(host, port, service):
    if service and 'nginx' in service.name.lower():
        return True
    else:
        return False
  
@engine.global_parser
def global_parser_example(output):
    # Remove all HTML-encoded < >
    return output.replace('&lt;', '<').replace('&gt;', '>')
  
result = scanner.scan('localhost', engine=engine)
...

License

Apache 2.0

nmapthon2's People

Contributors

cblopez avatar fabaff avatar

Stargazers

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

Watchers

 avatar  avatar

nmapthon2's Issues

Tag the source

It would be very helpful if you could tag releases. This would enable distributions who want to run your tests to fetch the package from GitHub instead of Pypi, where the tests are excluded.

Thanks

Releases

On PyPI is 0.1.5 available. On GitHub is the latest tagged release is 0.1.3.

You started to publish only wheels and no source tarball on PyPI. This will probably break the build process of the distribution which are shipping nmapthon2 as package.

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.