Added nmap integration (closes #99)
This commit is contained in:
parent
1e342cc8a5
commit
f5b010c15c
5 changed files with 41 additions and 0 deletions
5
docs/source/platypush/plugins/nmap.rst
Normal file
5
docs/source/platypush/plugins/nmap.rst
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
``platypush.plugins.nmap``
|
||||||
|
==========================
|
||||||
|
|
||||||
|
.. automodule:: platypush.plugins.nmap
|
||||||
|
:members:
|
|
@ -78,6 +78,7 @@ Plugins
|
||||||
platypush/plugins/music.rst
|
platypush/plugins/music.rst
|
||||||
platypush/plugins/music.mpd.rst
|
platypush/plugins/music.mpd.rst
|
||||||
platypush/plugins/music.snapcast.rst
|
platypush/plugins/music.snapcast.rst
|
||||||
|
platypush/plugins/nmap.rst
|
||||||
platypush/plugins/pihole.rst
|
platypush/plugins/pihole.rst
|
||||||
platypush/plugins/ping.rst
|
platypush/plugins/ping.rst
|
||||||
platypush/plugins/printer.cups.rst
|
platypush/plugins/printer.cups.rst
|
||||||
|
|
30
platypush/plugins/nmap.py
Normal file
30
platypush/plugins/nmap.py
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
from typing import Dict, Any
|
||||||
|
|
||||||
|
from platypush.plugins import Plugin, action
|
||||||
|
|
||||||
|
|
||||||
|
class NmapPlugin(Plugin):
|
||||||
|
"""
|
||||||
|
Nmap network scanner/mapper integration.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
|
@action
|
||||||
|
def scan(self, hosts: str, ports: str, args: str, sudo: bool = False) -> Dict[str, Any]:
|
||||||
|
"""
|
||||||
|
Perform a port scan towards a certain host or network.
|
||||||
|
|
||||||
|
:param hosts: Host name/IP or IP subnet to scan (e.g. ``192.168.1.0/24``).
|
||||||
|
:param ports: Port number, (comma-separated) list or (dash-separated) range to scan (default: all).
|
||||||
|
:param args: Additional command line arguments for nmap.
|
||||||
|
:param sudo: Execute nmap as root through sudo (default: ``False``).
|
||||||
|
:return: Scan results, as an ip -> host map.
|
||||||
|
"""
|
||||||
|
import nmap
|
||||||
|
nm = nmap.PortScanner()
|
||||||
|
return nm.scan(hosts=hosts, ports=ports, arguments=args, sudo=sudo).get('scan')
|
||||||
|
|
||||||
|
|
||||||
|
# vim:sw=4:ts=4:et:
|
|
@ -221,3 +221,6 @@ croniter
|
||||||
# py-cpuinfo
|
# py-cpuinfo
|
||||||
# psutil
|
# psutil
|
||||||
|
|
||||||
|
# Support for nmap integration
|
||||||
|
# python-nmap
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -275,5 +275,7 @@ setup(
|
||||||
'graphite': ['graphyte'],
|
'graphite': ['graphyte'],
|
||||||
# Support for CPU and memory monitoring and info
|
# Support for CPU and memory monitoring and info
|
||||||
'sys': ['py-cpuinfo', 'psutil'],
|
'sys': ['py-cpuinfo', 'psutil'],
|
||||||
|
# Support for nmap integration
|
||||||
|
'nmap': ['python-nmap'],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue