|
| 1 | +[](https://deepfence.github.io/PacketStreamer/) |
1 | 2 | [](https://github.com/deepfence/PacketStreamer/blob/master/LICENSE)
|
2 | 3 | [](https://github.com/deepfence/PacketStreamer/stargazers)
|
3 | 4 | [](https://github.com/deepfence/PacketStreamer/issues)
|
4 | 5 | [](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ)
|
5 | 6 |
|
6 |
| - |
7 | 7 | # PacketStreamer
|
8 | 8 |
|
9 |
| -Deepfence PacketStreamer is a high-performance remote packet capture and collection tool. It is used by Deepfence's [ThreatStryker](https://deepfence.io/threatstryker/) security observability platform to gather network traffic on demand from cloud workloads for forensic analysis. |
| 9 | +Deepfence PacketStreamer is a high-performance remote packet capture and |
| 10 | +collection tool. It is used by Deepfence's [ThreatStryker](https://deepfence.io/threatstryker/) |
| 11 | +security observability platform to gather network traffic on demand from cloud |
| 12 | +workloads for forensic analysis. |
10 | 13 |
|
11 | 14 | Primary design goals:
|
12 | 15 |
|
13 | 16 | * Stay light, capture and stream, no additional processing
|
14 |
| -* Portability, works across virtual machines, Kubernetes and AWS Fargate. Linux and Windows. |
15 |
| - |
16 |
| -PacketStreamer **sensors** are started on the target servers. Sensors capture traffic, apply filters, and then stream the traffic to a central reciever. Traffic streams may be compressed and/or encrypted using TLS. |
17 |
| - |
18 |
| -The PacketStreamer **reciever** accepts PacketStreamer streams from multiple remote sensors, and writes the packets to a local `pcap` capture file |
19 |
| - |
20 |
| -<p align="center"><img src="/images/readme/packetstreamer.png" width="66%"/><p> |
21 |
| - |
22 |
| -PacketStreamer sensors collect raw network packets on remote hosts. It selects packets to capture using a BPF filter, and forwards them to a central reciever process where they are written in pcap format. Sensors are very lightweight and impose little performance impact on the remote hosts. PacketStreamer sensors can be run on bare-metal servers, on Docker hosts, and on Kubernetes nodes. |
23 |
| - |
24 |
| -The PacketStreamer receiver accepts network traffic from multiple sensors, collecting it into a single, central `pcap` file. You can then process the pcap file or live feed the traffic to the tooling of your choice, such as `Zeek`, `Wireshark` `Suricata`, or as a live stream for Machine Learning models. |
25 |
| - |
26 |
| -### When to use PacketStreamer |
27 |
| - |
28 |
| -PacketStreamer meets more general use cases than existing alternatives. For example, [PacketBeat](https://github.com/elastic/beats/tree/master/packetbeat) captures and parses the packets on multiple remote hosts, assembles transactions, and ships the processed data to a central ElasticSearch collector. [ksniff](https://github.com/eldadru/ksniff) captures raw packet data from a single Kubernetes pod. |
29 |
| - |
30 |
| -Use PacketStreamer if you need a lightweight, efficient method to collect raw network data from multiple machines for central logging and analysis. |
31 |
| - |
32 |
| -### Who uses PacketStreamer? |
33 |
| - |
34 |
| - * Deepfence [ThreatStryker](https://deepfence.io/threatstryker/) uses PacketStreamer to capture traffic from production platforms for forensics and anomaly detection. |
35 |
| - |
36 |
| - |
37 |
| -# Quickstart: Build and Run PacketStreamer |
38 |
| - |
39 |
| -## Building PacketStreamer |
40 |
| - |
41 |
| -Build the `packetstreamer` binary using the `go` toolchain as follows: |
42 |
| - |
43 |
| -```bash |
44 |
| -make |
45 |
| -``` |
46 |
| - |
47 |
| -## Run a PacketStreamer receiver |
48 |
| - |
49 |
| -```bash |
50 |
| -packetstreamer receiver --config [configuration_file] |
51 |
| -``` |
52 |
| - |
53 |
| -You can use an example configuration file: |
54 |
| - |
55 |
| -```bash |
56 |
| -packetstreamer receiver --config ./contrib/config/receiver-local.yaml |
57 |
| -``` |
58 |
| - |
59 |
| -You can process the `pcap` output in a variety of ways: |
60 |
| - |
61 |
| -```bash |
62 |
| -# pass the output file /tmp/dump_file to tcpdump: |
63 |
| -tail -c +1 -f /tmp/dump_file | tcpdump -r - |
64 |
| -``` |
65 |
| - |
66 |
| -```bash |
67 |
| -# Edit the configuration to write to the special name 'stdout', and pipe output to tcpdump: |
68 |
| -./packet-streamer receiver --config ./contrib/config/receiver-stdout.yaml | tcpdump -r - |
69 |
| -``` |
70 |
| - |
71 |
| -## Run a PacketStreamer sensor |
72 |
| - |
73 |
| -```bash |
74 |
| -sudo packetstreamer sensor --config [configuration_file] |
75 |
| -``` |
76 |
| - |
77 |
| -You can use an example configuration file: |
78 |
| - |
79 |
| -```bash |
80 |
| -sudo packetstreamer sensor --config ./contrib/config/sensor-local.yaml |
81 |
| -``` |
82 |
| - |
83 |
| -When running the sensor remotely, edit the configuration file to target the remote receiver. |
84 |
| - |
85 |
| -## Testing PacketStreamer |
86 |
| - |
87 |
| -You can generate some test traffic using your favorite load generator - `ab`, `wrk`, `httperf`, `vegeta`. For example, to use vegeta: |
88 |
| - |
89 |
| -```bash |
90 |
| -# install vegeta |
91 |
| -go install github.com/tsenart/vegeta@latest |
92 |
| - |
93 |
| -echo 'GET http://some_ip:80' | vegeta attack -rate 100 -duration 5m | tee results.bin | vegeta report |
94 |
| -``` |
95 |
| - |
96 |
| -# Advanced Build Options |
97 |
| - |
98 |
| -Use the `RELEASE` parameter to strip the binary for a production environment: |
99 |
| - |
100 |
| -```bash |
101 |
| -make RELEASE=1 |
102 |
| -``` |
103 |
| - |
104 |
| -Use the `STATIC` parameter to statically-link the binary: |
105 |
| - |
106 |
| -```bash |
107 |
| -make STATIC=1 |
108 |
| -``` |
109 |
| - |
110 |
| -## Build using Docker |
111 |
| - |
112 |
| -Use the `docker-bin` target to build `packetstreamer` with Docker. The binary will be statically linked with `musl` and `libpcap`, making it portable across Linux distributions: |
113 |
| - |
114 |
| -```bash |
115 |
| -make docker-bin |
116 |
| - |
117 |
| -# Alternatively, build a stripped release binary |
118 |
| -make docker-bin RELEASE=1 |
119 |
| -``` |
120 |
| - |
121 |
| -## Build a Container Image |
122 |
| - |
123 |
| -Use the `docker-image` target to build a container image: |
124 |
| - |
125 |
| -```bash |
126 |
| -make docker-image |
127 |
| - |
128 |
| -# Alternatively, build a stripped release binary |
129 |
| -make docker-image RELEASE=1 |
130 |
| -``` |
131 |
| - |
132 |
| -## Deploy on Kubernetes |
133 |
| - |
134 |
| -PacketStreamer can be deployed on Kubernetes using Helm: |
135 |
| - |
136 |
| -```bash |
137 |
| -kubectl apply -f ./contrib/kubernetes/namespace.yaml |
138 |
| -helm install packetstreamer ./contrib/helm/ --namespace packetstreamer |
139 |
| -``` |
140 |
| - |
141 |
| -By default, the Helm chart deploys a DaemonSet with sensor on all nodes and one receiver instance. For the custom configuration values, please refer to the [values.yaml file](/contrib/helm/values.yaml). |
142 |
| - |
143 |
| -# Advanced Test Scenarios |
144 |
| - |
145 |
| -## Testing on Docker |
146 |
| - |
147 |
| -PacketStreamer container images can be tested locally on Docker. |
148 |
| - |
149 |
| -### Receiver side |
150 |
| - |
151 |
| -```bash |
152 |
| -docker run --rm -it \ |
153 |
| - -v $(pwd)/contrib/config:/etc/packetstreamer \ |
154 |
| - -v $HOME/container_tmp:/tmp \ |
155 |
| - -p 8081:8081 \ |
156 |
| - deepfenceio/deepfence_packetstreamer \ |
157 |
| - receiver --config /etc/packetstreamer/receiver.yaml |
158 |
| -``` |
159 |
| - |
160 |
| -### Sensor side |
161 |
| - |
162 |
| -```bash |
163 |
| -docker run --rm -it \ |
164 |
| - --cap-add=NET_ADMIN --net=host \ |
165 |
| - -v $(pwd)/contrib/config:/etc/packetstreamer \ |
166 |
| - deepfenceio/deepfence_packetstreamer \ |
167 |
| - sensor --config /etc/packetstreamer/sensor-local.yaml |
168 |
| -``` |
169 |
| - |
170 |
| -The sensor requires `--net=host` and `NET_ADMIN` capability in order to capture all of the packets on the host. |
171 |
| - |
172 |
| -```bash |
173 |
| -echo 'GET http://some_ip:80' | vegeta attack -rate 100 -duration 5m | tee results.bin | vegeta report |
174 |
| -``` |
175 |
| - |
176 |
| -The `pcap` dump file is available in `$HOME/container_tmp/dump_file`. |
177 |
| - |
178 |
| -## Testing on Vagrant |
179 |
| - |
180 |
| -On a single host, you may use [Vagrant](https://www.vagrantup.com) to run sensor and receiver hosts easily: |
181 |
| - |
182 |
| -Install Vagrant according to [the official instructions](https://www.vagrantup.com/downloads). By default, Vagrant uses Virtualbox; you should install [vagrant-libvirt](https://github.com/vagrant-libvirt/vagrant-libvirt), using `vagrant plugin install vagrant-libvirt`. |
183 |
| - |
184 |
| -Start the two Vagrant VMs, `receiver` and `sensor`: |
185 |
| - |
186 |
| -```bash |
187 |
| -vagrant up |
188 |
| - |
189 |
| -vagrant status |
190 |
| -# Current machine states: |
191 |
| -# |
192 |
| -# receiver running (libvirt) |
193 |
| -# sensor running (libvirt) |
194 |
| -``` |
195 |
| - |
196 |
| -SSH to those VMs (in separate terminals) by using the following commands: |
197 |
| - |
198 |
| -```bash |
199 |
| -vagrant ssh receiver |
200 |
| -``` |
201 |
| - |
202 |
| -```bash |
203 |
| -vagrant ssh sensor |
204 |
| -``` |
205 |
| - |
206 |
| -On each, enter the source code directory: |
| 17 | +* Portability, works across virtual machines, Kubernetes and AWS Fargate. Linux |
| 18 | + and Windows. |
207 | 19 |
|
208 |
| -### Receiver side |
| 20 | +PacketStreamer **sensors** are started on the target servers. Sensors capture |
| 21 | +traffic, apply filters, and then stream the traffic to a central reciever. |
| 22 | +Traffic streams may be compressed and/or encrypted using TLS. |
209 | 23 |
|
210 |
| -```bash |
211 |
| -cd PacketStreamer |
212 |
| -./packetstreamer receiver --config ./contrib/config/receiver-vagrant.yaml |
213 |
| -``` |
| 24 | +The PacketStreamer **receiver** accepts PacketStreamer streams from multiple |
| 25 | +remote sensors, and writes the packets to a local `pcap` capture file |
214 | 26 |
|
215 |
| -### Sensor side |
| 27 | +<p align="center"><img src="https://raw.githubusercontent.com/deepfence/PacketStreamer/main/images/readme/packetstreamer.png"/><p> |
216 | 28 |
|
217 |
| -```bash |
218 |
| -cd PacketStreamer |
219 |
| -sudo ./packetstreamer --config ./contrib/config/sensor-vagrant.yaml |
220 |
| -``` |
| 29 | +PacketStreamer sensors collect raw network packets on remote hosts. It selects packets |
| 30 | +to capture using a BPF filter, and forwards them to a central reciever process |
| 31 | +where they are written in pcap format. Sensors are very lightweight and impose |
| 32 | +little performance impact on the remote hosts. PacketStreamer sensors can be |
| 33 | +run on bare-metal servers, on Docker hosts, and on Kubernetes nodes. |
221 | 34 |
|
222 |
| -Generate some live traffic |
| 35 | +The PacketStreamer receiver accepts network traffic from multiple sensors, |
| 36 | +collecting it into a single, central `pcap` file. You can then process the |
| 37 | +pcap file or live feed the traffic to the tooling of your choice, such as |
| 38 | +`Zeek`, `Wireshark` `Suricata`, or as a live stream for Machine Learning models. |
223 | 39 |
|
224 |
| -```bash |
225 |
| -echo 'GET http://some_ip:80' | vegeta attack -rate 100 -duration 5m | tee results.bin | vegeta report |
226 |
| -``` |
| 40 | +## When to use PacketStreamer |
227 | 41 |
|
228 |
| -# PacketStreamer Configuration |
| 42 | +PacketStreamer meets more general use cases than existing alternatives. For |
| 43 | +example, [PacketBeat](https://github.com/elastic/beats/tree/master/packetbeat) |
| 44 | +captures and parses the packets on multiple remote hosts, assembles |
| 45 | +transactions, and ships the processed data to a central ElasticSearch |
| 46 | +collector. [ksniff](https://github.com/eldadru/ksniff) captures raw packet |
| 47 | +data from a single Kubernetes pod. |
229 | 48 |
|
230 |
| -`packetstreamer` is configured using a yaml-formatted configuration file. |
| 49 | +Use PacketStreamer if you need a lightweight, efficient method to collect raw |
| 50 | +network data from multiple machines for central logging and analysis. |
231 | 51 |
|
232 |
| -```yaml |
233 |
| -input: # required in 'receiver' mode |
234 |
| - address: _ip-address_ |
235 |
| - port: _listen-port_ |
236 |
| -output: |
237 |
| - server: # required in 'sensor' mode |
238 |
| - address: _ip-address_ |
239 |
| - port: _listen-port_ |
240 |
| - file: # required in 'receiver' mode |
241 |
| - path: _filename_|stdout # 'stdout' is a reserved name. Receiver will write to stdout |
242 |
| -tls: # optional |
243 |
| - enable: _true_|_false_ |
244 |
| - certfile: _filename_ |
245 |
| - keyfile: _filename_ |
246 |
| -auth: # optional; receiver and sensor must use same shared key |
247 |
| - enable: _true_|_false_ |
248 |
| - key: _string_ |
249 |
| -compressBlockSize: _integer_ # optional; default: 65 |
250 |
| -inputPacketLen: _integer_ # optional; default: 65535 |
251 |
| -logFilename: _filename_ # optional |
252 |
| -pcapMode: _Allow_|_Deny_|_All_ # optional |
253 |
| -capturePorts: _list-of-ports_ # optional |
254 |
| -captureInterfacesPorts: _map: interface-name:port_ # optional |
255 |
| -ignorePorts: _list-of-ports_ # optional |
256 |
| -``` |
| 52 | +## Who uses PacketStreamer? |
257 | 53 |
|
258 |
| -You can find example configuration files in the [`/contrib/config/`](contrib/config/) folder. |
| 54 | + * Deepfence [ThreatStryker](https://deepfence.io/threatstryker/) uses |
| 55 | + PacketStreamer to capture traffic from production platforms for forensics |
| 56 | + and anomaly detection. |
259 | 57 |
|
260 |
| -# Get in touch |
| 58 | +## Get in touch |
261 | 59 |
|
262 | 60 | Thank you for using PacketStreamer.
|
263 | 61 |
|
264 | 62 | * [< img src= "https://img.shields.io/badge/[email protected]?logo=slack"> ](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ) Got a question, need some help? Find the Deepfence team on Slack
|
265 |
| -* https://github.com/deepfence/PacketStreamer/issues: Got a feature request or found a bug? Raise an issue |
266 |
| -* [productsecurity at deepfence dot io](SECURITY.md): Found a security issue? Share it in confidence |
| 63 | +* https://github.com/deepfence/PacketStreamer/issues: Got a feature request or found a bug? Raise an issue |
| 64 | +* [productsecurity *at* deepfence *dot* io](SECURITY.md): Found a security issue? Share it in confidence |
267 | 65 | * Find out more at [deepfence.io](https://deepfence.io/)
|
268 | 66 |
|
269 |
| -# Security and Support |
| 67 | +## Security and Support |
270 | 68 |
|
271 | 69 | For any security-related issues in the PacketStreamer project, contact [productsecurity *at* deepfence *dot* io](SECURITY.md).
|
272 | 70 |
|
273 | 71 | Please file GitHub issues as needed, and join the Deepfence Community [Slack channel](https://join.slack.com/t/deepfence-community/shared_invite/zt-podmzle9-5X~qYx8wMaLt9bGWwkSdgQ).
|
274 | 72 |
|
275 |
| -# License |
| 73 | +## License |
276 | 74 |
|
277 | 75 | The Deepfence PacketStreamer project (this repository) is offered under the [Apache2 license](https://www.apache.org/licenses/LICENSE-2.0).
|
278 | 76 |
|
|
0 commit comments