CICFlowMeter V3 Python Implementation
Project description
Python CICFlowMeter (PyFlowmeter)
This project is cloned from Python Wrapper CICflowmeter and customized to fit my need. Therefore, it is not maintained actively. If there are any problems, please create an issue or a pull request.
Installation
pip install --upgrade pip
pip install pyflowmeter
Usage
from pyflowmeter.sniffer import create_sniffer
This function returns a scapy.sendrecv.AsyncSniffer object.
Parameters
-
input_file[default=None]- A .pcap file where capture offline data from. If it is set to ´None´, the data will be capture from
input_interface
- A .pcap file where capture offline data from. If it is set to ´None´, the data will be capture from
-
input_interface[default=None]- Interface or list of interfaces (default: None for sniffing on all interfaces).
-
server_endpoint[default=None]- A server endpoint where the data of the flow will be sent. If it is set to
None, no data will be sent.
- A server endpoint where the data of the flow will be sent. If it is set to
-
verbose[default=False]- Wheather or not to print a message when a new packet is read.
-
to_csv[defalut=Fasle]- Wheather or not to save the output flows as csv. The data will be saved on
output_file.
- Wheather or not to save the output flows as csv. The data will be saved on
-
output_file[default=None]- File to store the data. If
to_csvis set toFalse, this parameter will be ignored.
- File to store the data. If
-
sending_interval[defalut=1]- The frequency, in seconds, at which data will be sent to the server. If
server_endpointis None, this parameter will be ignored.
- The frequency, in seconds, at which data will be sent to the server. If
Examples
Sniff packets real-time from interface and send the flow to a server every 5 seconds(need root permission):
from pyflowmeter.sniffer import create_sniffer
sniffer = create_sniffer(
server_endpoint='http://127.0.0.1:5000/send_traffic',
verbose=True,
sending_interval=5
)
sniffer.start()
try:
sniffer.join()
except KeyboardInterrupt:
print('Stopping the sniffer')
sniffer.stop()
finally:
sniffer.join()
Get CSV analysis from a pcap file:
from pyflowmeter.sniffer import create_sniffer
sniffer = create_sniffer(
input_file='path_to_the_file.pcap',
to_csv=True,
output_file='./flows_test.csv',
)
sniffer.start()
try:
sniffer.join()
except KeyboardInterrupt:
print('Stopping the sniffer')
sniffer.stop()
finally:
sniffer.join()
Simulate offline traffic from a file and send the data to a server:
from pyflowmeter.sniffer import create_sniffer
sniffer = create_sniffer(
input_file='path_to_the_file.pcap',
server_endpoint='http://127.0.0.1:5000/send_traffic',
)
sniffer.start()
try:
sniffer.join()
except KeyboardInterrupt:
print('Stopping the sniffer')
sniffer.stop()
finally:
sniffer.join()
Project details
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 pyflowmeter-0.2.4.tar.gz.
File metadata
- Download URL: pyflowmeter-0.2.4.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19cef455665e4c48ef2caa314f3c2e02dc928aeb7e7634255eee593409e7aa00
|
|
| MD5 |
10d9d1178876e598a62dfb638bc99080
|
|
| BLAKE2b-256 |
ee2b5789610d9468314e5c6a26e5f82380fcde685506cfad24a7fe386c5b986c
|
File details
Details for the file pyflowmeter-0.2.4-py3-none-any.whl.
File metadata
- Download URL: pyflowmeter-0.2.4-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d1508026c1e0d806f60b92d3ce7a1d1ac335c8da9a0392d6f5f56c1a3721b2c
|
|
| MD5 |
583a31ab604f5b7db42dc430268966ce
|
|
| BLAKE2b-256 |
50380458e49d9a362bdc496f3c488f1642b4b385b0582ed9c6fb890dbcc68317
|