pcap-transformer 0.1.0__tar.gz
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.
- pcap_transformer-0.1.0/LICENSE +21 -0
- pcap_transformer-0.1.0/PKG-INFO +136 -0
- pcap_transformer-0.1.0/README.md +99 -0
- pcap_transformer-0.1.0/pyproject.toml +51 -0
- pcap_transformer-0.1.0/setup.cfg +4 -0
- pcap_transformer-0.1.0/src/pcap_transformer.egg-info/PKG-INFO +136 -0
- pcap_transformer-0.1.0/src/pcap_transformer.egg-info/SOURCES.txt +37 -0
- pcap_transformer-0.1.0/src/pcap_transformer.egg-info/dependency_links.txt +1 -0
- pcap_transformer-0.1.0/src/pcap_transformer.egg-info/requires.txt +25 -0
- pcap_transformer-0.1.0/src/pcap_transformer.egg-info/top_level.txt +1 -0
- pcap_transformer-0.1.0/src/transforming_framework/__init__.py +5 -0
- pcap_transformer-0.1.0/src/transforming_framework/core/__init__.py +0 -0
- pcap_transformer-0.1.0/src/transforming_framework/core/interfaces.py +16 -0
- pcap_transformer-0.1.0/src/transforming_framework/core/transform.py +783 -0
- pcap_transformer-0.1.0/src/transforming_framework/dataset_transform/BoT_IoT_transform.py +229 -0
- pcap_transformer-0.1.0/src/transforming_framework/dataset_transform/CSE_CIC_IDS2018_transform.py +103 -0
- pcap_transformer-0.1.0/src/transforming_framework/dataset_transform/ToN_IoT_transform.py +40 -0
- pcap_transformer-0.1.0/src/transforming_framework/dataset_transform/UNSW_NB15_transform.py +1823 -0
- pcap_transformer-0.1.0/src/transforming_framework/dataset_transform/__init__.py +0 -0
- pcap_transformer-0.1.0/src/transforming_framework/features/BoT_IoT_features.txt +43 -0
- pcap_transformer-0.1.0/src/transforming_framework/features/CSE_CIC_IDS2018_features.txt +82 -0
- pcap_transformer-0.1.0/src/transforming_framework/features/ToN_IoT_features.txt +43 -0
- pcap_transformer-0.1.0/src/transforming_framework/features/UNSW_NB15_features.txt +47 -0
- pcap_transformer-0.1.0/src/transforming_framework/features/__init__.py +0 -0
- pcap_transformer-0.1.0/src/transforming_framework/label_dataset/BoT_IoT_label.py +92 -0
- pcap_transformer-0.1.0/src/transforming_framework/label_dataset/CSE_CIC_IDS2018_label.py +266 -0
- pcap_transformer-0.1.0/src/transforming_framework/label_dataset/ToN_IoT_label.py +15 -0
- pcap_transformer-0.1.0/src/transforming_framework/label_dataset/UNSW_NB15_label.py +61 -0
- pcap_transformer-0.1.0/src/transforming_framework/label_dataset/__init__.py +0 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/NFStream.py +64 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/__init__.py +0 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/argus.py +215 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/cicflowmeter.py +155 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/nexusflowmeter.py +44 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/own_prep_code.py +237 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/ownprep.py +87 -0
- pcap_transformer-0.1.0/src/transforming_framework/tools/zeek.py +183 -0
- pcap_transformer-0.1.0/src/transforming_framework/utils/__init__.py +269 -0
- pcap_transformer-0.1.0/tests/test_package.py +32 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eva Nagy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pcap-transformer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Transform PCAP captures into flow and intrusion-detection datasets
|
|
5
|
+
Author: Eva Nagy
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: pcap,network-traffic,flow,intrusion-detection,datasets
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.26
|
|
17
|
+
Requires-Dist: pandas>=2.1
|
|
18
|
+
Requires-Dist: pyarrow>=14
|
|
19
|
+
Requires-Dist: python-dateutil>=2.8
|
|
20
|
+
Requires-Dist: pytz>=2023.3
|
|
21
|
+
Provides-Extra: nfstream
|
|
22
|
+
Requires-Dist: nfstream; extra == "nfstream"
|
|
23
|
+
Provides-Extra: cicflowmeter
|
|
24
|
+
Requires-Dist: scapy<2.7,>=2.6.0; extra == "cicflowmeter"
|
|
25
|
+
Provides-Extra: ownprep
|
|
26
|
+
Requires-Dist: pyshark==0.6; extra == "ownprep"
|
|
27
|
+
Requires-Dist: scipy<2.0,>=1.10; extra == "ownprep"
|
|
28
|
+
Provides-Extra: nexusflowmeter
|
|
29
|
+
Requires-Dist: nexusflowmeter==0.1.5; extra == "nexusflowmeter"
|
|
30
|
+
Provides-Extra: all
|
|
31
|
+
Requires-Dist: nfstream; extra == "all"
|
|
32
|
+
Requires-Dist: scapy<2.7,>=2.6.0; extra == "all"
|
|
33
|
+
Requires-Dist: pyshark==0.6; extra == "all"
|
|
34
|
+
Requires-Dist: scipy<2.0,>=1.10; extra == "all"
|
|
35
|
+
Requires-Dist: nexusflowmeter==0.1.5; extra == "all"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# PCAP Transforming Framework
|
|
39
|
+
|
|
40
|
+
Python framework for extracting network flows from PCAP files and transforming
|
|
41
|
+
them into the feature formats used by ToN-IoT, BoT-IoT, UNSW-NB15, and
|
|
42
|
+
CSE-CIC-IDS2018.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
Python 3.12 or later is required.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m pip install pcap-transformer
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Install optional Python dependencies for the flow extractor(s) you plan to use:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m pip install "pcap-transformer[all]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Available extras are `nfstream`, `cicflowmeter`, `ownprep`, and
|
|
59
|
+
`nexusflowmeter`.
|
|
60
|
+
|
|
61
|
+
The extractor tools also depend on system programs. Zeek, Argus, `editcap`,
|
|
62
|
+
`capinfos`, `tcpdump`, and TShark are not installed by pip. CICFlowMeter must
|
|
63
|
+
be installed separately; configure `CICFLOWMETER_BIN` to a compatible wrapper
|
|
64
|
+
that accepts a PCAP path and output directory and creates
|
|
65
|
+
`<pcap-filename>_Flow.csv` in that directory. Check each tool's own installation
|
|
66
|
+
instructions and license. These external tools are generally easiest to run on
|
|
67
|
+
Linux or WSL.
|
|
68
|
+
|
|
69
|
+
To install from a source checkout instead:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python -m pip install .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Input data
|
|
76
|
+
|
|
77
|
+
Place captures under a data directory with this layout:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
data/
|
|
81
|
+
└── pcap/
|
|
82
|
+
└── ToN_IoT/
|
|
83
|
+
├── capture1.pcap
|
|
84
|
+
└── capture2.pcap
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The framework writes generated flow files and datasets under `data/flow/`.
|
|
88
|
+
Pass a different data root with `data_dir`; paths are relative to the current
|
|
89
|
+
working directory unless absolute paths are provided.
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
|
|
93
|
+
Transform PCAPs into a target dataset's feature format:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from transforming_framework import Transform
|
|
97
|
+
|
|
98
|
+
job = Transform(
|
|
99
|
+
src_dataset="ToN_IoT",
|
|
100
|
+
goal_datasets="ToN_IoT",
|
|
101
|
+
data_dir="./data",
|
|
102
|
+
)
|
|
103
|
+
job.run()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Or extract flows with one or more flow tools without applying a target feature
|
|
107
|
+
format:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from transforming_framework import Transform
|
|
111
|
+
|
|
112
|
+
job = Transform(
|
|
113
|
+
src_dataset="ToN_IoT",
|
|
114
|
+
tools=["zeek", "argus"],
|
|
115
|
+
data_dir="./data",
|
|
116
|
+
)
|
|
117
|
+
job.run()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`tools` and `goal_datasets` are mutually exclusive. Supported tools are
|
|
121
|
+
`zeek`, `argus`, `cicflowmeter`, `nexusflowmeter`, `ownprep`, and `nfstream`.
|
|
122
|
+
Supported target datasets are `ToN_IoT`, `BoT_IoT`, `UNSW_NB15`, and
|
|
123
|
+
`CSE_CIC_IDS2018`. Dataset labels are inferred from the source dataset and
|
|
124
|
+
capture filenames; use `do_label=False` to skip labeling or
|
|
125
|
+
`label_binary=False` for multiclass labels.
|
|
126
|
+
|
|
127
|
+
Large captures are split as needed. The default split size is 1,000,000
|
|
128
|
+
packets; configure it with `chunk_size_packets`. Processed files, merged
|
|
129
|
+
Parquet output, and a preview sample are written below `data/flow/`.
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
This project is released under the MIT License. The checked-in CICFlowMeter
|
|
134
|
+
sources and other third-party extractor tools retain their own licenses and
|
|
135
|
+
must be used in accordance with those licenses. Third-party source files are
|
|
136
|
+
not included in the pip distributions.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# PCAP Transforming Framework
|
|
2
|
+
|
|
3
|
+
Python framework for extracting network flows from PCAP files and transforming
|
|
4
|
+
them into the feature formats used by ToN-IoT, BoT-IoT, UNSW-NB15, and
|
|
5
|
+
CSE-CIC-IDS2018.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Python 3.12 or later is required.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
python -m pip install pcap-transformer
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Install optional Python dependencies for the flow extractor(s) you plan to use:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
python -m pip install "pcap-transformer[all]"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Available extras are `nfstream`, `cicflowmeter`, `ownprep`, and
|
|
22
|
+
`nexusflowmeter`.
|
|
23
|
+
|
|
24
|
+
The extractor tools also depend on system programs. Zeek, Argus, `editcap`,
|
|
25
|
+
`capinfos`, `tcpdump`, and TShark are not installed by pip. CICFlowMeter must
|
|
26
|
+
be installed separately; configure `CICFLOWMETER_BIN` to a compatible wrapper
|
|
27
|
+
that accepts a PCAP path and output directory and creates
|
|
28
|
+
`<pcap-filename>_Flow.csv` in that directory. Check each tool's own installation
|
|
29
|
+
instructions and license. These external tools are generally easiest to run on
|
|
30
|
+
Linux or WSL.
|
|
31
|
+
|
|
32
|
+
To install from a source checkout instead:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m pip install .
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Input data
|
|
39
|
+
|
|
40
|
+
Place captures under a data directory with this layout:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
data/
|
|
44
|
+
└── pcap/
|
|
45
|
+
└── ToN_IoT/
|
|
46
|
+
├── capture1.pcap
|
|
47
|
+
└── capture2.pcap
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The framework writes generated flow files and datasets under `data/flow/`.
|
|
51
|
+
Pass a different data root with `data_dir`; paths are relative to the current
|
|
52
|
+
working directory unless absolute paths are provided.
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
Transform PCAPs into a target dataset's feature format:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from transforming_framework import Transform
|
|
60
|
+
|
|
61
|
+
job = Transform(
|
|
62
|
+
src_dataset="ToN_IoT",
|
|
63
|
+
goal_datasets="ToN_IoT",
|
|
64
|
+
data_dir="./data",
|
|
65
|
+
)
|
|
66
|
+
job.run()
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or extract flows with one or more flow tools without applying a target feature
|
|
70
|
+
format:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from transforming_framework import Transform
|
|
74
|
+
|
|
75
|
+
job = Transform(
|
|
76
|
+
src_dataset="ToN_IoT",
|
|
77
|
+
tools=["zeek", "argus"],
|
|
78
|
+
data_dir="./data",
|
|
79
|
+
)
|
|
80
|
+
job.run()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`tools` and `goal_datasets` are mutually exclusive. Supported tools are
|
|
84
|
+
`zeek`, `argus`, `cicflowmeter`, `nexusflowmeter`, `ownprep`, and `nfstream`.
|
|
85
|
+
Supported target datasets are `ToN_IoT`, `BoT_IoT`, `UNSW_NB15`, and
|
|
86
|
+
`CSE_CIC_IDS2018`. Dataset labels are inferred from the source dataset and
|
|
87
|
+
capture filenames; use `do_label=False` to skip labeling or
|
|
88
|
+
`label_binary=False` for multiclass labels.
|
|
89
|
+
|
|
90
|
+
Large captures are split as needed. The default split size is 1,000,000
|
|
91
|
+
packets; configure it with `chunk_size_packets`. Processed files, merged
|
|
92
|
+
Parquet output, and a preview sample are written below `data/flow/`.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
This project is released under the MIT License. The checked-in CICFlowMeter
|
|
97
|
+
sources and other third-party extractor tools retain their own licenses and
|
|
98
|
+
must be used in accordance with those licenses. Third-party source files are
|
|
99
|
+
not included in the pip distributions.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pcap-transformer"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Transform PCAP captures into flow and intrusion-detection datasets"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Eva Nagy" }]
|
|
14
|
+
keywords = ["pcap", "network-traffic", "flow", "intrusion-detection", "datasets"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Scientific/Engineering",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"numpy>=1.26",
|
|
24
|
+
"pandas>=2.1",
|
|
25
|
+
"pyarrow>=14",
|
|
26
|
+
"python-dateutil>=2.8",
|
|
27
|
+
"pytz>=2023.3",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.optional-dependencies]
|
|
31
|
+
nfstream = ["nfstream"]
|
|
32
|
+
cicflowmeter = ["scapy>=2.6.0,<2.7"]
|
|
33
|
+
ownprep = ["pyshark==0.6", "scipy>=1.10,<2.0"]
|
|
34
|
+
nexusflowmeter = ["nexusflowmeter==0.1.5"]
|
|
35
|
+
all = [
|
|
36
|
+
"nfstream",
|
|
37
|
+
"scapy>=2.6.0,<2.7",
|
|
38
|
+
"pyshark==0.6",
|
|
39
|
+
"scipy>=1.10,<2.0",
|
|
40
|
+
"nexusflowmeter==0.1.5",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.setuptools]
|
|
44
|
+
package-dir = { "" = "src" }
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["src"]
|
|
48
|
+
include = ["transforming_framework*"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-data]
|
|
51
|
+
transforming_framework = ["features/*.txt"]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pcap-transformer
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Transform PCAP captures into flow and intrusion-detection datasets
|
|
5
|
+
Author: Eva Nagy
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: pcap,network-traffic,flow,intrusion-detection,datasets
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Science/Research
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering
|
|
13
|
+
Requires-Python: >=3.12
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.26
|
|
17
|
+
Requires-Dist: pandas>=2.1
|
|
18
|
+
Requires-Dist: pyarrow>=14
|
|
19
|
+
Requires-Dist: python-dateutil>=2.8
|
|
20
|
+
Requires-Dist: pytz>=2023.3
|
|
21
|
+
Provides-Extra: nfstream
|
|
22
|
+
Requires-Dist: nfstream; extra == "nfstream"
|
|
23
|
+
Provides-Extra: cicflowmeter
|
|
24
|
+
Requires-Dist: scapy<2.7,>=2.6.0; extra == "cicflowmeter"
|
|
25
|
+
Provides-Extra: ownprep
|
|
26
|
+
Requires-Dist: pyshark==0.6; extra == "ownprep"
|
|
27
|
+
Requires-Dist: scipy<2.0,>=1.10; extra == "ownprep"
|
|
28
|
+
Provides-Extra: nexusflowmeter
|
|
29
|
+
Requires-Dist: nexusflowmeter==0.1.5; extra == "nexusflowmeter"
|
|
30
|
+
Provides-Extra: all
|
|
31
|
+
Requires-Dist: nfstream; extra == "all"
|
|
32
|
+
Requires-Dist: scapy<2.7,>=2.6.0; extra == "all"
|
|
33
|
+
Requires-Dist: pyshark==0.6; extra == "all"
|
|
34
|
+
Requires-Dist: scipy<2.0,>=1.10; extra == "all"
|
|
35
|
+
Requires-Dist: nexusflowmeter==0.1.5; extra == "all"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# PCAP Transforming Framework
|
|
39
|
+
|
|
40
|
+
Python framework for extracting network flows from PCAP files and transforming
|
|
41
|
+
them into the feature formats used by ToN-IoT, BoT-IoT, UNSW-NB15, and
|
|
42
|
+
CSE-CIC-IDS2018.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
Python 3.12 or later is required.
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m pip install pcap-transformer
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Install optional Python dependencies for the flow extractor(s) you plan to use:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m pip install "pcap-transformer[all]"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Available extras are `nfstream`, `cicflowmeter`, `ownprep`, and
|
|
59
|
+
`nexusflowmeter`.
|
|
60
|
+
|
|
61
|
+
The extractor tools also depend on system programs. Zeek, Argus, `editcap`,
|
|
62
|
+
`capinfos`, `tcpdump`, and TShark are not installed by pip. CICFlowMeter must
|
|
63
|
+
be installed separately; configure `CICFLOWMETER_BIN` to a compatible wrapper
|
|
64
|
+
that accepts a PCAP path and output directory and creates
|
|
65
|
+
`<pcap-filename>_Flow.csv` in that directory. Check each tool's own installation
|
|
66
|
+
instructions and license. These external tools are generally easiest to run on
|
|
67
|
+
Linux or WSL.
|
|
68
|
+
|
|
69
|
+
To install from a source checkout instead:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
python -m pip install .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Input data
|
|
76
|
+
|
|
77
|
+
Place captures under a data directory with this layout:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
data/
|
|
81
|
+
└── pcap/
|
|
82
|
+
└── ToN_IoT/
|
|
83
|
+
├── capture1.pcap
|
|
84
|
+
└── capture2.pcap
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The framework writes generated flow files and datasets under `data/flow/`.
|
|
88
|
+
Pass a different data root with `data_dir`; paths are relative to the current
|
|
89
|
+
working directory unless absolute paths are provided.
|
|
90
|
+
|
|
91
|
+
## Usage
|
|
92
|
+
|
|
93
|
+
Transform PCAPs into a target dataset's feature format:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from transforming_framework import Transform
|
|
97
|
+
|
|
98
|
+
job = Transform(
|
|
99
|
+
src_dataset="ToN_IoT",
|
|
100
|
+
goal_datasets="ToN_IoT",
|
|
101
|
+
data_dir="./data",
|
|
102
|
+
)
|
|
103
|
+
job.run()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Or extract flows with one or more flow tools without applying a target feature
|
|
107
|
+
format:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from transforming_framework import Transform
|
|
111
|
+
|
|
112
|
+
job = Transform(
|
|
113
|
+
src_dataset="ToN_IoT",
|
|
114
|
+
tools=["zeek", "argus"],
|
|
115
|
+
data_dir="./data",
|
|
116
|
+
)
|
|
117
|
+
job.run()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`tools` and `goal_datasets` are mutually exclusive. Supported tools are
|
|
121
|
+
`zeek`, `argus`, `cicflowmeter`, `nexusflowmeter`, `ownprep`, and `nfstream`.
|
|
122
|
+
Supported target datasets are `ToN_IoT`, `BoT_IoT`, `UNSW_NB15`, and
|
|
123
|
+
`CSE_CIC_IDS2018`. Dataset labels are inferred from the source dataset and
|
|
124
|
+
capture filenames; use `do_label=False` to skip labeling or
|
|
125
|
+
`label_binary=False` for multiclass labels.
|
|
126
|
+
|
|
127
|
+
Large captures are split as needed. The default split size is 1,000,000
|
|
128
|
+
packets; configure it with `chunk_size_packets`. Processed files, merged
|
|
129
|
+
Parquet output, and a preview sample are written below `data/flow/`.
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
This project is released under the MIT License. The checked-in CICFlowMeter
|
|
134
|
+
sources and other third-party extractor tools retain their own licenses and
|
|
135
|
+
must be used in accordance with those licenses. Third-party source files are
|
|
136
|
+
not included in the pip distributions.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/pcap_transformer.egg-info/PKG-INFO
|
|
5
|
+
src/pcap_transformer.egg-info/SOURCES.txt
|
|
6
|
+
src/pcap_transformer.egg-info/dependency_links.txt
|
|
7
|
+
src/pcap_transformer.egg-info/requires.txt
|
|
8
|
+
src/pcap_transformer.egg-info/top_level.txt
|
|
9
|
+
src/transforming_framework/__init__.py
|
|
10
|
+
src/transforming_framework/core/__init__.py
|
|
11
|
+
src/transforming_framework/core/interfaces.py
|
|
12
|
+
src/transforming_framework/core/transform.py
|
|
13
|
+
src/transforming_framework/dataset_transform/BoT_IoT_transform.py
|
|
14
|
+
src/transforming_framework/dataset_transform/CSE_CIC_IDS2018_transform.py
|
|
15
|
+
src/transforming_framework/dataset_transform/ToN_IoT_transform.py
|
|
16
|
+
src/transforming_framework/dataset_transform/UNSW_NB15_transform.py
|
|
17
|
+
src/transforming_framework/dataset_transform/__init__.py
|
|
18
|
+
src/transforming_framework/features/BoT_IoT_features.txt
|
|
19
|
+
src/transforming_framework/features/CSE_CIC_IDS2018_features.txt
|
|
20
|
+
src/transforming_framework/features/ToN_IoT_features.txt
|
|
21
|
+
src/transforming_framework/features/UNSW_NB15_features.txt
|
|
22
|
+
src/transforming_framework/features/__init__.py
|
|
23
|
+
src/transforming_framework/label_dataset/BoT_IoT_label.py
|
|
24
|
+
src/transforming_framework/label_dataset/CSE_CIC_IDS2018_label.py
|
|
25
|
+
src/transforming_framework/label_dataset/ToN_IoT_label.py
|
|
26
|
+
src/transforming_framework/label_dataset/UNSW_NB15_label.py
|
|
27
|
+
src/transforming_framework/label_dataset/__init__.py
|
|
28
|
+
src/transforming_framework/tools/NFStream.py
|
|
29
|
+
src/transforming_framework/tools/__init__.py
|
|
30
|
+
src/transforming_framework/tools/argus.py
|
|
31
|
+
src/transforming_framework/tools/cicflowmeter.py
|
|
32
|
+
src/transforming_framework/tools/nexusflowmeter.py
|
|
33
|
+
src/transforming_framework/tools/own_prep_code.py
|
|
34
|
+
src/transforming_framework/tools/ownprep.py
|
|
35
|
+
src/transforming_framework/tools/zeek.py
|
|
36
|
+
src/transforming_framework/utils/__init__.py
|
|
37
|
+
tests/test_package.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
numpy>=1.26
|
|
2
|
+
pandas>=2.1
|
|
3
|
+
pyarrow>=14
|
|
4
|
+
python-dateutil>=2.8
|
|
5
|
+
pytz>=2023.3
|
|
6
|
+
|
|
7
|
+
[all]
|
|
8
|
+
nfstream
|
|
9
|
+
scapy<2.7,>=2.6.0
|
|
10
|
+
pyshark==0.6
|
|
11
|
+
scipy<2.0,>=1.10
|
|
12
|
+
nexusflowmeter==0.1.5
|
|
13
|
+
|
|
14
|
+
[cicflowmeter]
|
|
15
|
+
scapy<2.7,>=2.6.0
|
|
16
|
+
|
|
17
|
+
[nexusflowmeter]
|
|
18
|
+
nexusflowmeter==0.1.5
|
|
19
|
+
|
|
20
|
+
[nfstream]
|
|
21
|
+
nfstream
|
|
22
|
+
|
|
23
|
+
[ownprep]
|
|
24
|
+
pyshark==0.6
|
|
25
|
+
scipy<2.0,>=1.10
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
transforming_framework
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Tool:
|
|
6
|
+
def run(self, pcap_file: Path, output_dir: Path) -> None:
|
|
7
|
+
pass
|
|
8
|
+
tool_name = None
|
|
9
|
+
|
|
10
|
+
class Label:
|
|
11
|
+
def labelling(self, df: pd.DataFrame, name:str, label_binary: bool) -> pd.DataFrame:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
class DatasetTransform:
|
|
15
|
+
def transform(self, parquet_file: pd.DataFrame, goal_features: list) -> pd.DataFrame:
|
|
16
|
+
pass
|