A system-indipendent network protocol manipulation and evaluation library.
Project description
netprot
A system-independent network protocol manipulation and evaluation library. netprod wants to be a library capable of standardizing and evaluating a list of strings representing Network Protocols. The idea is to provide a tool similar to netaddr that can help to enhance and simplify code logic wherever is required.
Installation
pip3 install netprod
Package available here
HOW TO
First thing, we need to initialize an instance of Netprod class, passing as arguments a list of strings - where each string should represent a network protocol and corresponding port. A separator argument is also possible to pass as kwarg and will be used to standardize our strings. By default, separator is equal to /
>>> from netprot.netprot import Netprot
>>> my_list = ['tcp-443-https', 'UDP/53', 'tcp/1024-1026', 'TCPP-80', 'tcp/443']
>>> my_protocols = Netprot(my_list, exceptions=['ICMP', 'any'], separator='/')
Once the instance of the class is created, we can call standardize method which will return a tuple containing pontential unlegal protocols and ports, duplicates - if any, and a standardize list of protocols and port.
>>> my_protocols.standardize()
(['TCPP/80'], ['TCP/443'], ['ANY', 'ICMP', 'TCP/1024', 'TCP/1025', 'TCP/1026', 'TCP/443', 'UDP/53'])
As we can see, we have:
- Strings using the same
separator. - Trailing words such as
httpsis removed as not needed - Protocols defined as
tcp/1024-1026are unpacked for each port in range defined - Illegal protocols such as TCPP/80 are removed
- Duplicates are also removed
- All strings are upper cases
- List is sorted
ICMPandANYare recognized as legal - because defined underexceptionsargument - and passed through
Netprod not only standardizes data, but also evaluates them. Let's have a look to the other methods
:warning: List of protocols must be standardized first.
Let's check if the ports are part of well known range of ports (0 to 1024)
>>> my_protocols.is_well_known()
(False, [False, False, True, False, False, True, True])
As we can see, some ports are failing to be lower than 1024, hence we return False plus a list of bools for each ports.
What about if we want to find those are TCP...
>>> my_protocols.is_tcp()
(False, [False, False, True, True, True, True, False])
... or UDP?
>>> my_protocols.is_udp()
(False, [False, False, False, False, False, False, True])
Great! What if we want figure out if our port and protocols are safe or not?
Let's define a list of safe - or unsafe - ports and protocols and passed them to is_safe or is_unsafe method.
>>> my_safe_applications = ['TCP/443', 'UDP/53']
>>> my_protocols.is_safe(my_safe_applications)
[False, False, False, False, False, True, True]
>>> my_unsafe_applications = ['ICMP', 'ANY']
>>> my_protocols.is_unsafe(my_unsafe_applications)
[True, True, False, False, False, False, False]
And that's all, folks!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netprot-0.1.2.tar.gz.
File metadata
- Download URL: netprot-0.1.2.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7d3e2cd39bfd19eb8d8263cf231614b043d8de084db97ef210eede40bc002ec
|
|
| MD5 |
10856cb2ff59ecbacf43c24cbaeb3412
|
|
| BLAKE2b-256 |
e132d4ff5ba348edb5baad2ed2d97cebe7029363c0a50a7286c60b6883bdfc99
|
File details
Details for the file netprot-0.1.2-py3-none-any.whl.
File metadata
- Download URL: netprot-0.1.2-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2062d8a4252323c2e37d5b0a8b299cfea32a560cf91074859d3e65c7eff55134
|
|
| MD5 |
2a3eca835bc5176ce72a44218c9550ab
|
|
| BLAKE2b-256 |
7344985397dc340d656af35cc6e5ea2d59808bc28085fe22a4d370ea806d6ea4
|