-
Notifications
You must be signed in to change notification settings - Fork 1
/
PKG-INFO
223 lines (179 loc) · 6.2 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
Metadata-Version: 2.1
Name: NetworkScanner
Version: 2.0.0
Summary: This module implements a NetworkScanner.
Home-page: https://github.com/mauricelambert/NetworkScanner
Author: Maurice Lambert
Author-email: [email protected]
Maintainer: Maurice Lambert
Maintainer-email: [email protected]
License: GPL-3.0 License
Project-URL: Documentation, https://mauricelambert.github.io/info/python/security/NetworkScanner.html
Project-URL: Executable, https://mauricelambert.github.io/info/python/security/NetworkScanner.pyz
Keywords: Network,Scanner,Discovery,Host,Ping,nmap,Security,Scapy,ARP
Platform: Windows
Platform: Linux
Platform: MacOS
Classifier: Programming Language :: Python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Natural Language :: English
Classifier: Topic :: System :: Networking
Classifier: Topic :: Security
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt
![NetworkScanner logo](https://mauricelambert.github.io/info/python/security/NetworkScanner_small.png "NetworkScanner logo")
# NetworkScanner
## Description
This package implements an asynchronous network scanner (using scapy or asyncio).
## Requirements
This package require:
- python3
- python3 Standard Library
- PythonToolsKit
Optional:
- Scapy
## Installation
```bash
pip install NetworkScanner
```
## Usages
### Command lines
```bash
# Python executable
python3 NetworkScanner.pyz -h
# or
chmod u+x NetworkScanner.pyz
./NetworkScanner.pyz --help
# Python module
python3 -m NetworkScanner -t 172.18.0.1-172.18.0.15
# Entry point (console)
NetworkScanner -d --noping --hostname --ports 22 80 -p 445 139 443 -T 1 -R -s -t 172.18.0.0/28
NetworkScanner -i 172.18.0. -P -t 172.18.0.0/28 # Passive scan using scapy sniffer
```
### Python3
```python
# Simple usage to print results in your console
from NetworkScanner import NetworkScanner, logger
scanner = NetworkScanner({"172.18.0.1", "172.18.0.3"})
scanner.scan() # Without scapy
# Custom behaviors
def do_IP_UP(ip, reason, detail = None):
print(f"{ip} is UP ({reason} {detail})")
scanner.handle_UP = do_IP_UP
scanner.scan(True) # With scapy
scanner.hosts_up # List of IP addresses used
scanner.hosts_down # List of unused IP addresses
from scapy.all import *
scanner = NetworkScanner({"172.18.0.1"}, False, [22, 80], False, True, False, 1, conf.iface)
scanner.handle_UP = do_IP_UP
scanner.handle_DOWN = print
scanner.scan()
logger.setLevel(10) # debug mode
class CustomNetworkScanner(NetworkScanner):
def handle_UP(self, ip: str, detection_type: str, details = None): # details is a kwarg
print(f"IP: {ip} is UP (detection type: {detection_type}, details: {details}")
def handle_DOWN(self, ip: str):
print(f"IP: {ip} is DOWN")
scanner = NetworkScanner({"172.18.0.1", "172.18.0.3"})
scanner.scan()
scanner.scan(passive=True) # passive mode using scapy sniffer
```
## Useful usages
With scapy, *hosts discovery (best performances)*:
```bash
NetworkScanner --noping -T 1 -t [targets]
```
```python
from NetworkScanner import NetworkScanner
from scapy.all import conf
scanner = NetworkScanner(
{},
ping=False,
ports=[],
arp=True,
hostname=False,
real_time=False,
timeout=1,
iface=conf.iface,
)
scanner.scan(True)
```
Without scapy, *hosts discovery*:
```bash
NetworkScanner -t [targets]
```
```python
from NetworkScanner import NetworkScanner
scanner = NetworkScanner(
{},
ping=True,
ports=[],
arp=True,
hostname=False,
real_time=False,
timeout=1,
)
scanner.scan()
```
Without scapy, *opened port && hosts discovery*:
```python
from NetworkScanner import NetworkScanner
def host_up(ip: str, method: str, port: int = None):
if method == 'tcp':
print(f"{ip}:{port} is open.")
else:
print(f"{ip} is UP.")
scanner = NetworkScanner(
{},
ping=False,
ports=[22, 80, 443],
arp=True,
hostname=False,
real_time=False,
timeout=1,
)
scanner.handle_UP = host_up
scanner.scan(False)
```
## Links
- [Github Page](https://github.com/mauricelambert/NetworkScanner)
- [Pypi](https://pypi.org/project/NetworkScanner/)
- [Documentation](https://mauricelambert.github.io/info/python/security/NetworkScanner.html)
- [Executable](https://mauricelambert.github.io/info/python/security/NetworkScanner.pyz)
## Help
```text
usage: NetworkScanner.py [-h] [--interface INTERFACE] --targets TARGETS [TARGETS ...] [--noping] [--noarp]
[--hostname] [--ports PORTS [PORTS ...]] [--timeout TIMEOUT] [--no-realtime] [--debug]
[--print-ip] [--force-asynchronous] [--passive-scan]
This program scans networks and IP address ranges.
options:
-h, --help show this help message and exit
--interface INTERFACE, -i INTERFACE
Part of the IP, MAC or name of the interface
--targets TARGETS [TARGETS ...], -t TARGETS [TARGETS ...]
Targets from networks and IP address ranges.
--noping, -g No ping detection. [Without scapy ping is required for ARP detection]
--noarp, -A No arp cache.
--hostname, -H Test the hostname resolution to defined if host is UP (longer).
--ports PORTS [PORTS ...], -p PORTS [PORTS ...]
Test the TCP port connections to defined if the host is UP.
--timeout TIMEOUT, -T TIMEOUT
Connections timeout.
--no-realtime, -R Do not print results in real time.
--debug, -d Debug mode (logger level debug).
--print-ip, -I Print only the IP address if UP.
--force-asynchronous, --async, -a
Force asynchronous mode, using asyncio instead of scapy.
--passive-scan, --passive, -P
Passive scan, sniff the network packets to identify who is up. This scan is endless because
you can never be sure to have detected all the IP addresses.
```
## Licence
Licensed under the [GPL, version 3](https://www.gnu.org/licenses/).