lanscape 1.2.8a2__py3-none-any.whl → 1.2.9a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lanscape/libraries/subnet_scan.py +16 -15
- lanscape/tests/test_library.py +1 -1
- lanscape/ui/app.py +0 -2
- lanscape/ui/blueprints/api/scan.py +1 -1
- lanscape/ui/blueprints/web/routes.py +1 -1
- lanscape/ui/main.py +16 -5
- lanscape/ui/templates/base.html +1 -1
- {lanscape-1.2.8a2.dist-info → lanscape-1.2.9a1.dist-info}/METADATA +2 -12
- {lanscape-1.2.8a2.dist-info → lanscape-1.2.9a1.dist-info}/RECORD +12 -12
- {lanscape-1.2.8a2.dist-info → lanscape-1.2.9a1.dist-info}/LICENSE +0 -0
- {lanscape-1.2.8a2.dist-info → lanscape-1.2.9a1.dist-info}/WHEEL +0 -0
- {lanscape-1.2.8a2.dist-info → lanscape-1.2.9a1.dist-info}/top_level.txt +0 -0
|
@@ -27,7 +27,14 @@ TCNT_DEVICE_ISALIVE = 256
|
|
|
27
27
|
class ScanConfig:
|
|
28
28
|
subnet: str
|
|
29
29
|
port_list: str
|
|
30
|
-
|
|
30
|
+
t_multiplier: float = 1.0
|
|
31
|
+
t_cnt_port_scan: int = 10
|
|
32
|
+
t_cnt_port_test: int = 128
|
|
33
|
+
t_cnt_isalive: int = 256
|
|
34
|
+
|
|
35
|
+
def t_cnt(self, id: str) -> int:
|
|
36
|
+
return int(int(getattr(self, f't_cnt_{id}')) * float(self.t_multiplier))
|
|
37
|
+
|
|
31
38
|
|
|
32
39
|
|
|
33
40
|
|
|
@@ -40,8 +47,9 @@ class SubnetScanner:
|
|
|
40
47
|
self.port_list = config.port_list
|
|
41
48
|
self.ports: list = PortManager().get_port_list(config.port_list).keys()
|
|
42
49
|
self.running = False
|
|
43
|
-
self.parallelism: float = float(config.parallelism)
|
|
44
50
|
self.subnet_str = config.subnet
|
|
51
|
+
|
|
52
|
+
self.cfg = config
|
|
45
53
|
self.job_stats = JobStats()
|
|
46
54
|
self.uid = str(uuid.uuid4())
|
|
47
55
|
self.results = ScannerResults(self)
|
|
@@ -58,7 +66,7 @@ class SubnetScanner:
|
|
|
58
66
|
"""
|
|
59
67
|
self._set_stage('scanning devices')
|
|
60
68
|
self.running = True
|
|
61
|
-
with ThreadPoolExecutor(max_workers=self.
|
|
69
|
+
with ThreadPoolExecutor(max_workers=self.cfg.t_cnt('isalive')) as executor:
|
|
62
70
|
futures = {executor.submit(self._get_host_details, str(ip)): str(ip) for ip in self.subnet}
|
|
63
71
|
for future in futures:
|
|
64
72
|
ip = futures[future]
|
|
@@ -104,7 +112,7 @@ class SubnetScanner:
|
|
|
104
112
|
remaining_isalive_sec = (self.results.devices_total - self.results.devices_scanned) * avg_host_detail_sec
|
|
105
113
|
total_isalive_sec = self.results.devices_total * avg_host_detail_sec
|
|
106
114
|
|
|
107
|
-
isalive_multiplier = self.
|
|
115
|
+
isalive_multiplier = self.cfg.t_cnt('isalive')
|
|
108
116
|
|
|
109
117
|
# --- Port scanning calculations ---
|
|
110
118
|
device_ports_scanned = self.job_stats.finished.get('_test_port', 0)
|
|
@@ -116,7 +124,7 @@ class SubnetScanner:
|
|
|
116
124
|
remaining_port_test_sec = device_ports_unscanned * avg_port_test_sec
|
|
117
125
|
total_port_test_sec = est_subnet_devices * len(self.ports) * avg_port_test_sec
|
|
118
126
|
|
|
119
|
-
port_test_multiplier = self.
|
|
127
|
+
port_test_multiplier = self.cfg.t_cnt('port_scan') * self.cfg.t_cnt('port_test')
|
|
120
128
|
|
|
121
129
|
# --- Overall progress ---
|
|
122
130
|
est_total_time = (total_isalive_sec / isalive_multiplier) + (total_port_test_sec / port_test_multiplier)
|
|
@@ -157,7 +165,7 @@ class SubnetScanner:
|
|
|
157
165
|
|
|
158
166
|
@terminator
|
|
159
167
|
def _scan_network_ports(self):
|
|
160
|
-
with ThreadPoolExecutor(max_workers=self.
|
|
168
|
+
with ThreadPoolExecutor(max_workers=self.cfg.t_cnt('port_scan')) as executor:
|
|
161
169
|
futures = {executor.submit(self._scan_ports, device): device for device in self.results.devices}
|
|
162
170
|
for future in futures:
|
|
163
171
|
future.result()
|
|
@@ -167,7 +175,7 @@ class SubnetScanner:
|
|
|
167
175
|
def _scan_ports(self, device: Device):
|
|
168
176
|
self.log.debug(f'[{device.ip}] Initiating port scan')
|
|
169
177
|
device.stage = 'scanning'
|
|
170
|
-
with ThreadPoolExecutor(max_workers=self.
|
|
178
|
+
with ThreadPoolExecutor(max_workers=self.cfg.t_cnt('port_test')) as executor:
|
|
171
179
|
futures = {executor.submit(self._test_port, device, int(port)): port for port in self.ports}
|
|
172
180
|
for future in futures:
|
|
173
181
|
future.result()
|
|
@@ -192,13 +200,6 @@ class SubnetScanner:
|
|
|
192
200
|
"""
|
|
193
201
|
return host.is_alive(host.ip)
|
|
194
202
|
|
|
195
|
-
def _t_cnt(self, base_threads: int) -> int:
|
|
196
|
-
"""
|
|
197
|
-
Calculate the number of threads to use based on the base number
|
|
198
|
-
of threads and the parallelism factor.
|
|
199
|
-
"""
|
|
200
|
-
return int(base_threads * self.parallelism)
|
|
201
|
-
|
|
202
203
|
def _set_stage(self,stage):
|
|
203
204
|
self.log.debug(f'[{self.uid}] Moving to Stage: {stage}')
|
|
204
205
|
self.results.stage = stage
|
|
@@ -210,7 +211,6 @@ class ScannerResults:
|
|
|
210
211
|
self.scan = scan
|
|
211
212
|
self.port_list: str = scan.port_list
|
|
212
213
|
self.subnet: str = scan.subnet_str
|
|
213
|
-
self.parallelism: float = scan.parallelism
|
|
214
214
|
self.uid = scan.uid
|
|
215
215
|
|
|
216
216
|
self.devices_total: int = len(list(scan.subnet))
|
|
@@ -249,6 +249,7 @@ class ScannerResults:
|
|
|
249
249
|
out = vars(self).copy()
|
|
250
250
|
out.pop('scan')
|
|
251
251
|
out.pop('log')
|
|
252
|
+
out['cfg'] = vars(self.scan.cfg)
|
|
252
253
|
|
|
253
254
|
devices: List[Device] = out.pop('devices')
|
|
254
255
|
sortedDevices = sorted(devices, key=lambda obj: ipaddress.IPv4Address(obj.ip))
|
lanscape/tests/test_library.py
CHANGED
lanscape/ui/app.py
CHANGED
|
@@ -22,7 +22,7 @@ def index():
|
|
|
22
22
|
scan = scanner.results.export()
|
|
23
23
|
subnet = scan['subnet']
|
|
24
24
|
port_list = scan['port_list']
|
|
25
|
-
parallelism = scan['
|
|
25
|
+
parallelism = scan['cfg']['t_multiplier']
|
|
26
26
|
else:
|
|
27
27
|
log.debug(f'Redirecting, scan {scan_id} doesnt exist in memory')
|
|
28
28
|
return redirect('/')
|
lanscape/ui/main.py
CHANGED
|
@@ -13,6 +13,7 @@ configure_logging(args.loglevel, args.logfile)
|
|
|
13
13
|
|
|
14
14
|
from ..libraries.version_manager import get_installed_version, is_update_available
|
|
15
15
|
from .app import start_webserver
|
|
16
|
+
import socket
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
log = logging.getLogger('core')
|
|
@@ -27,9 +28,12 @@ def main():
|
|
|
27
28
|
if not IS_FLASK_RELOAD:
|
|
28
29
|
log.info(f'LANscape v{get_installed_version()}')
|
|
29
30
|
try_check_update()
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
else:
|
|
31
33
|
log.info('Flask reloaded app.')
|
|
32
34
|
|
|
35
|
+
args.port = get_valid_port(args.port)
|
|
36
|
+
|
|
33
37
|
|
|
34
38
|
try:
|
|
35
39
|
|
|
@@ -63,9 +67,8 @@ def open_browser(url: str,wait=2):
|
|
|
63
67
|
time.sleep(wait)
|
|
64
68
|
webbrowser.open(url, new=2)
|
|
65
69
|
except:
|
|
66
|
-
srv_url = f"0.0.0.0:{url.split(':')[1]}"
|
|
67
70
|
log.debug(traceback.format_exc())
|
|
68
|
-
log.info(f'
|
|
71
|
+
log.info(f'Unable to open web browser, server running on {url}')
|
|
69
72
|
|
|
70
73
|
threading.Thread(target=do_open).start()
|
|
71
74
|
|
|
@@ -74,13 +77,21 @@ def no_gui(args: RuntimeArgs):
|
|
|
74
77
|
# if it was, dont open the browser again
|
|
75
78
|
if not IS_FLASK_RELOAD:
|
|
76
79
|
open_browser(f'http://127.0.0.1:{args.port}')
|
|
77
|
-
|
|
78
|
-
log.info(f'Server started: http://127.0.0.1:{args.port}')
|
|
80
|
+
log.info(f'Flask started: http://127.0.0.1:{args.port}')
|
|
79
81
|
|
|
80
82
|
start_webserver(
|
|
81
83
|
args
|
|
82
84
|
)
|
|
83
85
|
|
|
86
|
+
def get_valid_port(port: int):
|
|
87
|
+
"""
|
|
88
|
+
Get the first available port starting from the specified port
|
|
89
|
+
"""
|
|
90
|
+
while True:
|
|
91
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
92
|
+
if s.connect_ex(('localhost', port)) != 0:
|
|
93
|
+
return port
|
|
94
|
+
port += 1
|
|
84
95
|
|
|
85
96
|
if __name__ == "__main__":
|
|
86
97
|
main()
|
lanscape/ui/templates/base.html
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lanscape
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.9a1
|
|
4
4
|
Summary: A python based local network scanner
|
|
5
5
|
Author-email: Michael Dennis <michael@dipduo.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/mdennis281/py-lanscape
|
|
@@ -32,17 +32,15 @@ python -m lanscape
|
|
|
32
32
|
|
|
33
33
|
## Flags
|
|
34
34
|
- `--port <port number>` port of the flask app (default: 5001)
|
|
35
|
-
- `--nogui` run in web mode (default: false)
|
|
36
35
|
- `--reloader` essentially flask debug mode- good for local development (default: false)
|
|
37
36
|
- `--logfile` save log output to lanscape.log
|
|
38
37
|
- `--loglevel <level>` set the logger's log level (default: INFO)
|
|
39
|
-
- `--headless` similar to nogui but doesnt try to open a browser (default: false)
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
Examples:
|
|
43
41
|
```shell
|
|
44
42
|
python -m lanscape --reloader
|
|
45
|
-
python -m lanscape --
|
|
43
|
+
python -m lanscape --port 5002
|
|
46
44
|
python -m lanscape --logfile --loglevel DEBUG
|
|
47
45
|
```
|
|
48
46
|
|
|
@@ -57,14 +55,6 @@ can sometimes require admin-level permissions to retrieve accurate results.
|
|
|
57
55
|
This is a missing dependency related to the ARP lookup. This is handled in the code, but you would get marginally faster/better results with this installed: [npcap download](https://npcap.com/#download)
|
|
58
56
|
|
|
59
57
|
|
|
60
|
-
### Unable to start webview client. Try --nogui (Linux)
|
|
61
|
-
Linux and QT (GUI package) dont seem to play well with each other very well. If you really want the gui (`python -m lanscape --nogui` is almost as good) I had success on ubuntu desktop by running these:
|
|
62
|
-
```sh
|
|
63
|
-
sudo apt install libcairo2-dev libxt-dev libgirepository1.0-dev
|
|
64
|
-
pip install pycairo PyGObject qtpy PyQt5 PyQtWebEngine
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
|
|
68
58
|
### Something else
|
|
69
59
|
Feel free to submit a github issue detailing your experience.
|
|
70
60
|
|
|
@@ -9,7 +9,7 @@ lanscape/libraries/mac_lookup.py,sha256=jejM0NHLbxB9G2hfge2qt0qcNgnSlZERbiTP-RLU
|
|
|
9
9
|
lanscape/libraries/net_tools.py,sha256=zWWvKon46i3ImhaGg2IpCV-Cx01-jFBBZCIHHHyFmqg,10112
|
|
10
10
|
lanscape/libraries/port_manager.py,sha256=fNext3FNfGnGYRZK9RhTEwQ2K0e0YmmMlhK4zVAvoCw,1977
|
|
11
11
|
lanscape/libraries/runtime_args.py,sha256=JJTzWgQ-0aRh7Ce5efIwBmHZv1LfWjFagtNUNlLN7Uo,1660
|
|
12
|
-
lanscape/libraries/subnet_scan.py,sha256=
|
|
12
|
+
lanscape/libraries/subnet_scan.py,sha256=6b2zrsBVGwIc0V54nnLXPB5XBmBCcMahwtMYFWB1l8E,11095
|
|
13
13
|
lanscape/libraries/version_manager.py,sha256=wdB5DPW8IjHJfgvT4mUKz7ndEV922WgVEqbwd6jfun4,1599
|
|
14
14
|
lanscape/resources/mac_addresses/convert_csv.py,sha256=w3Heed5z2mHYDEZNBep3_hNg4dbrp_N6J54MGxnrq4s,721
|
|
15
15
|
lanscape/resources/mac_addresses/mac_db.json,sha256=ygtFSwNwJzDlg6hmAujdgCyzUjxt9Di75J8SO4xYIs8,2187804
|
|
@@ -22,16 +22,16 @@ lanscape/tests/__init__.py,sha256=xYPeceOF-ppTS0wnq7CkVYQMwupmeSHxbYLbGj_imZ0,11
|
|
|
22
22
|
lanscape/tests/_helpers.py,sha256=wXJfUwzL3Fq4XBsC3dValCbXsf0U8FisuM_yo1de4QQ,371
|
|
23
23
|
lanscape/tests/test_api.py,sha256=fIVIA6O9ssPRjofTHLS6z7XPNTkvv2rl2jDaxVCjFGU,5669
|
|
24
24
|
lanscape/tests/test_env.py,sha256=ivFhCcemJ9vbe0_KtUkbqDY4r9nsDB8rVLUVjV-sNj8,673
|
|
25
|
-
lanscape/tests/test_library.py,sha256=
|
|
26
|
-
lanscape/ui/app.py,sha256=
|
|
27
|
-
lanscape/ui/main.py,sha256=
|
|
25
|
+
lanscape/tests/test_library.py,sha256=OPcTsUoR5IureSNDbePxid2BG98mfNNIJmCIY0BVz3w,1553
|
|
26
|
+
lanscape/ui/app.py,sha256=hGmzoyH4YW2WmQsqZ6v-9r5DYzWi2KYP6_toZSxQqFg,3186
|
|
27
|
+
lanscape/ui/main.py,sha256=HMQythH0fijX1Mt9fGQBcqmY37dQQ19ROC99JbCNAvs,2701
|
|
28
28
|
lanscape/ui/blueprints/__init__.py,sha256=agvgPOSVbrxddaw6EY64ZZr1CQi1Qzwcs1t0lZMv5oY,206
|
|
29
29
|
lanscape/ui/blueprints/api/__init__.py,sha256=t0QOq3vHFWmlZm_3YFPQbQzCn1a_a5cmRchtIxwy4eY,103
|
|
30
30
|
lanscape/ui/blueprints/api/port.py,sha256=2UA38umzXE8pMitx1E-_wJHyL1dYYbtM6Kg5zVtfj6A,1019
|
|
31
|
-
lanscape/ui/blueprints/api/scan.py,sha256=
|
|
31
|
+
lanscape/ui/blueprints/api/scan.py,sha256=S1KswiAtkUF0fbPosBxzuMpAGEW6-FhFdOnpYBsq8Ok,2062
|
|
32
32
|
lanscape/ui/blueprints/api/tools.py,sha256=CD0NDSX8kN6_lpl0jEw-ULLsDx7pKODCMFQiaK4GCzM,1153
|
|
33
33
|
lanscape/ui/blueprints/web/__init__.py,sha256=-WRjENG8D99NfaiSDk9uAa8OX6XJq9Zmq1ck29ARL-w,92
|
|
34
|
-
lanscape/ui/blueprints/web/routes.py,sha256=
|
|
34
|
+
lanscape/ui/blueprints/web/routes.py,sha256=Cd_XpDCSt02_K1hoJoegacA_eMhmqZdz0R0QMsZ2K0s,2174
|
|
35
35
|
lanscape/ui/static/lanscape.webmanifest,sha256=0aauJk_Bybd0B2iwzJfvPcs7AX43kVHs0dtpV6_jSWk,459
|
|
36
36
|
lanscape/ui/static/css/style.css,sha256=LbQ4O98uttwY2Msxv9XnniOTzZApGsqkFg8PCoe1ZcQ,15801
|
|
37
37
|
lanscape/ui/static/img/ico/android-chrome-192x192.png,sha256=DxM2E9GjpKX-hSaSmAoW0GxLJ2fdXKJ-WOgoxYlDybw,24130
|
|
@@ -48,7 +48,7 @@ lanscape/ui/static/js/quietReload.js,sha256=_mHzpUsGL4Lm1hNsr3VYSOGVcgGA2y1-eZHa
|
|
|
48
48
|
lanscape/ui/static/js/shutdown-server.js,sha256=WkO7_SNSHM_6kReUoCoExIdCf7Sl7IPiSiNxpbI-r0s,469
|
|
49
49
|
lanscape/ui/static/js/subnet-info.js,sha256=aytt0LkBx4FVq36TxiMEw3aM7XQLHg_ng1U2WDwZVF4,577
|
|
50
50
|
lanscape/ui/static/js/subnet-selector.js,sha256=OG01pDaSOPLq3Ial0aO0CqPcob9tPZA1MZKGmQG0W7Q,366
|
|
51
|
-
lanscape/ui/templates/base.html,sha256=
|
|
51
|
+
lanscape/ui/templates/base.html,sha256=P5xnMlvDXYkYSXdSZUWaRfhsszNuZPP7A56hemBrAFs,1498
|
|
52
52
|
lanscape/ui/templates/error.html,sha256=zXFO0zPIfQORWq1ZMiSZ8G7FjfhVVr-aaYC0HeBl4Rs,1068
|
|
53
53
|
lanscape/ui/templates/info.html,sha256=oCC59keGEfgUB4WaCozaeZEfNb8Nr7y61DmkRBMqs18,2461
|
|
54
54
|
lanscape/ui/templates/main.html,sha256=M12xJSN6Ga565vIPhdCiqcr1tYgDrqzuQTeuXtk-8yo,3759
|
|
@@ -61,8 +61,8 @@ lanscape/ui/templates/scan/ip-table-row.html,sha256=ptY24rxJRaA4PEEQRDncaq6Q0ql5
|
|
|
61
61
|
lanscape/ui/templates/scan/ip-table.html,sha256=ds__UP9JiTKf5IxCmTMzw--eN_yg1Pvn3Nj1KvQxeZg,940
|
|
62
62
|
lanscape/ui/templates/scan/overview.html,sha256=Q0gmkVI-xNLZ-zWA9qm4H14cv_eF_bQs1KYPyAaoHLY,1141
|
|
63
63
|
lanscape/ui/templates/scan/scan-error.html,sha256=Q4eZM5ThrxnFaWOSTUpK8hA2ksHwhxOBTaVUCLALhyA,1032
|
|
64
|
-
lanscape-1.2.
|
|
65
|
-
lanscape-1.2.
|
|
66
|
-
lanscape-1.2.
|
|
67
|
-
lanscape-1.2.
|
|
68
|
-
lanscape-1.2.
|
|
64
|
+
lanscape-1.2.9a1.dist-info/LICENSE,sha256=cCO-NbS01Ilwc6djHjZ7LIgPFRkRmWdr0fH2ysXKioA,1090
|
|
65
|
+
lanscape-1.2.9a1.dist-info/METADATA,sha256=sFA9CAR9210_WSIXbusPmrIVCL_TElYK3KXS-EZD4W0,2046
|
|
66
|
+
lanscape-1.2.9a1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
67
|
+
lanscape-1.2.9a1.dist-info/top_level.txt,sha256=E9D4sjPz_6H7c85Ycy_pOS2xuv1Wm-ilKhxEprln2ps,9
|
|
68
|
+
lanscape-1.2.9a1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|