__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
import pytest
from netaddr import valid_nmap_range, iter_nmap_range, IPAddress, AddrFormatError
def test_valid_nmap_range_with_valid_target_specs():
assert valid_nmap_range('192.0.2.1')
assert valid_nmap_range('192.0.2.0-31')
assert valid_nmap_range('192.0.2-3.1-254')
assert valid_nmap_range('0-255.0-255.0-255.0-255')
assert valid_nmap_range('192.168.3-5,7.1')
assert valid_nmap_range('192.168.3-5,7,10-12,13,14.1')
assert valid_nmap_range('fe80::1')
assert valid_nmap_range('::')
assert valid_nmap_range('192.0.2.0/24')
def test_valid_nmap_range_with_invalid_target_specs():
assert not valid_nmap_range('192.0.2.0/255.255.255.0')
assert not valid_nmap_range(1)
assert not valid_nmap_range('1')
assert not valid_nmap_range([])
assert not valid_nmap_range({})
assert not valid_nmap_range('fe80::/64')
assert not valid_nmap_range('255.255.255.256')
assert not valid_nmap_range('0-255.0-255.0-255.0-256')
assert not valid_nmap_range('0-255.0-255.0-255.-1-0')
assert not valid_nmap_range('0-255.0-255.0-255.256-0')
assert not valid_nmap_range('0-255.0-255.0-255.255-0')
assert not valid_nmap_range('a.b.c.d-e')
assert not valid_nmap_range('255.255.255.a-b')
def test_iter_nmap_range():
assert list(iter_nmap_range('192.0.2.1')) == [IPAddress('192.0.2.1')]
ip_list = list(iter_nmap_range('192.0.2.0-31'))
assert len(ip_list) == 32
assert ip_list == [
IPAddress('192.0.2.0'),
IPAddress('192.0.2.1'),
IPAddress('192.0.2.2'),
IPAddress('192.0.2.3'),
IPAddress('192.0.2.4'),
IPAddress('192.0.2.5'),
IPAddress('192.0.2.6'),
IPAddress('192.0.2.7'),
IPAddress('192.0.2.8'),
IPAddress('192.0.2.9'),
IPAddress('192.0.2.10'),
IPAddress('192.0.2.11'),
IPAddress('192.0.2.12'),
IPAddress('192.0.2.13'),
IPAddress('192.0.2.14'),
IPAddress('192.0.2.15'),
IPAddress('192.0.2.16'),
IPAddress('192.0.2.17'),
IPAddress('192.0.2.18'),
IPAddress('192.0.2.19'),
IPAddress('192.0.2.20'),
IPAddress('192.0.2.21'),
IPAddress('192.0.2.22'),
IPAddress('192.0.2.23'),
IPAddress('192.0.2.24'),
IPAddress('192.0.2.25'),
IPAddress('192.0.2.26'),
IPAddress('192.0.2.27'),
IPAddress('192.0.2.28'),
IPAddress('192.0.2.29'),
IPAddress('192.0.2.30'),
IPAddress('192.0.2.31'),
]
assert len(list(iter_nmap_range('192.0.2-3.1-7'))) == 14
assert list(iter_nmap_range('192.0.2.1-3,5,7-9')) == [
IPAddress('192.0.2.1'),
IPAddress('192.0.2.2'),
IPAddress('192.0.2.3'),
IPAddress('192.0.2.5'),
IPAddress('192.0.2.7'),
IPAddress('192.0.2.8'),
IPAddress('192.0.2.9'),
]
def test_iter_nmap_range_with_multiple_targets_including_cidr():
assert list(iter_nmap_range('192.168.0.0/29', '192.168.3-5,7.1', 'fe80::1')) == [
IPAddress('192.168.0.0'),
IPAddress('192.168.0.1'),
IPAddress('192.168.0.2'),
IPAddress('192.168.0.3'),
IPAddress('192.168.0.4'),
IPAddress('192.168.0.5'),
IPAddress('192.168.0.6'),
IPAddress('192.168.0.7'),
IPAddress('192.168.3.1'),
IPAddress('192.168.4.1'),
IPAddress('192.168.5.1'),
IPAddress('192.168.7.1'),
IPAddress('fe80::1'),
]
def test_iter_nmap_range_invalid():
with pytest.raises(AddrFormatError):
list(iter_nmap_range('fe80::/64'))
def test_iter_nmap_range_remove_duplicates():
assert list(iter_nmap_range('10.0.0.42,42-42')) == [IPAddress('10.0.0.42')]
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 0 B | 0644 |
|
| test_cidr_v4.py | File | 7.4 KB | 0644 |
|
| test_cidr_v6.py | File | 4.56 KB | 0644 |
|
| test_dns.py | File | 320 B | 0644 |
|
| test_ip.py | File | 625 B | 0644 |
|
| test_ip_categories.py | File | 4.04 KB | 0644 |
|
| test_ip_comparisons.py | File | 1.39 KB | 0644 |
|
| test_ip_globs.py | File | 2.09 KB | 0644 |
|
| test_ip_network_categories.py | File | 547 B | 0644 |
|
| test_ip_ranges.py | File | 8.57 KB | 0644 |
|
| test_ip_rfc1924.py | File | 512 B | 0644 |
|
| test_ip_sets.py | File | 22.68 KB | 0644 |
|
| test_ip_splitter.py | File | 2.21 KB | 0644 |
|
| test_ip_v4.py | File | 15.07 KB | 0644 |
|
| test_ip_v4_v6_conversions.py | File | 1.22 KB | 0644 |
|
| test_ip_v6.py | File | 5.95 KB | 0644 |
|
| test_network_ops.py | File | 2.37 KB | 0644 |
|
| test_nmap.py | File | 3.62 KB | 0644 |
|
| test_old_specs.py | File | 6.37 KB | 0644 |
|
| test_platform_osx.py | File | 5.29 KB | 0644 |
|
| test_socket_module_fallback.py | File | 1.48 KB | 0644 |
|