Audit your egress connections and finally populate this OUTPUT chain !

egress-auditor

Audit your egress connections and finally populate this OUTPUT chain !

Summary

egress-auditor will monitor new outbound connections and generate appropriate iptables rules (or report, or ... depending on output plugin).

Connections can be detected using several methods.

This is early alpha stuff.

Quick start

# add an iptable rules on OUTPUT to send new connections to NFLOG
sudo iptables -I OUTPUT -m state --state NEW -p tcp -j NFLOG --nflog-group 100
go build . 
# start egress-auditor using the nflog input and the same group id used in iptables
sudo ./egress-auditor -i nflog -I nflog:group:100 -o iptables -O iptables:verbose:2
egress-auditor is running... press ctrl-c to stop
new TCP connection 192.168.1.229:60166 -> 146.148.13.123:443(https) by curl
^C # <- Ctrl+C pressed here
# [nflog] Line generated for curl running as ubuntu with command "curl https://www.devops.works"
# [nflog] Parent of this process was bash running as ubuntu
iptables -I OUTPUT -d 146.148.13.123 -p tcp -m tcp --dport 443 -j ACCEPT -m comment --comment "curl"

Usage

See -h for help, and -l for the list of input/outpup plugins.

In a nutshell, inputs are added using -i, outputs using -o.

If plugins need option, they are passed using -I for inputs and -O for outputs. For those options, the required format is pluginame:optionname:optionvalue.

For instance, to set verbosity tp 2 for the iptables output plugin, the proper invocation is:

... -O iptables:verbose:2

Of course, this implies the iptables output module has been loaded using -i iptables in the same CLI.

The -R option can be used to hide egress-auditor and it's arguments from ps output. This allows for more sneaky auditing, preventing someone to spot the program too easily and kill it.

For instance, when running:

sudo ./egress-auditor -R '[loop25]' ...

a call to ps auwx | grep egress | grep -v grep won't return any results, since the process has been renamed to [loop25] (and hangs out with its other loop kernel-threads friends).

TODO:

  • -C : how many cnx to capture before bailing out
  • -t: duration to capture before exiting
  • -debug

Building

go build .

If you're lazy and do not want to type sudo when running egress-auditor, you can give it some capabilities:

sudo setcap 'cap_net_admin=+ep' ./egress-auditor 

TODO:

  • Makefile
  • goreleaser
  • pass down a logger to prevent logging mess

Loki stack

If you want to play with egress captured logs in loki, you can start a docker-compose stack in the _misc directory, then point egress-auditor at loki.

cd _misc
docker-compose up -d
cd ..
sudo iptables -I OUTPUT -m state --state NEW -p tcp -j NFLOG --nflog-group 100
sudo ./egress-auditor -i nflog -I nflog:group:100 -o loki -O loki:url:http://127.0.0.1:3100 -O loki:label:test=true,lokirules=yes,fizz=buzz

Then :

  • login with admin:admin,
  • create a datasource with type 'Loki' and URL http://loki:3100
  • click save and test, and got to the Explore panel to start playing

Available modules

Run egress-auditor -l to get an up to date list and their options.

Inputs

  • nflog: captures using nflog iptable target
  • [] nfqueue (+ auto-allow per process ?)
  • [] ebpf
  • [] pcap (device + file)

Outputs

  • iptables
  • [] json (file + stdout)
  • loki

Caveats

  • supports only TCP for now
  • responsible process might not be found for really short lived connections

Licence

MIT

Contributions welcome.

Owner
Similar Resources

Censors or hides shell / Bash / console output based on defined patterns - great for hiding secrets in demos!

Censors or hides shell / Bash / console output based on defined patterns - great for hiding secrets in demos!

censor-shell Installation go install Usage Make the file ~/.censor-shell as an INI file with the following content: [nameofmyreplacement] pattern = b

Nov 11, 2022

k6 prometheus output extension

xk6-prometheus A k6 extension implements Prometheus HTTP exporter as k6 output extension. Using xk6-prometheus output extension you can collect metric

Nov 22, 2022

Netpoltool - CLI evaluation of Kubernetes NetworkPolicys with detailed output to aid debugging.

netpoltool CLI evaluation of Kubernetes NetworkPolicys with detailed output helpful for debugging. Given source and destination pods, identify the Net

Jan 8, 2022

Supporting your devops by shortening your strings using common abbreviations and clever guesswork

abbreviate Shorten your strings using common abbreviations. Supported by Tidelift Motivation This tool comes out of a frustration of the name of resou

Dec 14, 2022

A simple download file manager that sorts your files into your desired folders, This was meant to be a small project and nothing big.

GoDFM Simply go to the tags and download the .exe file (or compile it yourself by running go build). Add it to your environment paths by going to sett

Aug 9, 2022

💓 小米手环实时心率数据采集 - Your Soul, Your Beats!

💓 mebeats 小米手环实时心率数据采集 - Your Soul, Your Beats! cmd/mebeats-client: the mebeats client. It collects the heart rate data from Mi Band and reports to s

Dec 31, 2022

Kusk makes your OpenAPI definition the source of truth for API resources in your cluster

Kusk makes your OpenAPI definition the source of truth for API resources in your cluster

Kusk - use OpenAPI to configure Kubernetes What is Kusk? Developers deploying their REST APIs in Kubernetes shouldn't have to worry about managing res

Dec 16, 2022

A shields.io API for your youtube channel to protect your api key

A shields.io API for your youtube channel to protect your api key

Youtube-Channel-Badge A shields.io API for your youtube channel to protect your

Dec 23, 2021

Download your Fitbit weight history and connect to InfluxDB and Grafana

WemonFit Weight monitoring for Fitbit, using InfluxDB and Grafana Generating a new certificate openssl req -new -newkey rsa:2048 -nodes -keyout lo

Oct 22, 2022
Open Source runtime scanner for OpenShift cluster and perform security audit checks based on CIS RedHat OpenShift Benchmark specification
Open Source runtime scanner for OpenShift cluster and perform security audit checks based on CIS RedHat OpenShift Benchmark specification

OpenShift-Ordeal Scan your Openshift cluster !! OpenShift-Ordeal is an open source audit scanner who perform audit check on OpenShift Cluster and outp

Sep 6, 2022
Open Source runtime scanner for Linux containers (LXD), It performs security audit checks based on CIS Linux containers Benchmark specification
Open Source runtime scanner for Linux containers (LXD), It performs security audit checks based on CIS Linux containers  Benchmark specification

lxd-probe Scan your Linux container runtime !! Lxd-Probe is an open source audit scanner who perform audit check on a linux container manager and outp

Dec 26, 2022
kubetnl tunnels TCP connections from within a Kubernetes cluster to a cluster-external endpoint, e.g. to your local machine. (the perfect complement to kubectl port-forward)

kubetnl kubetnl (kube tunnel) is a command line utility to tunnel TCP connections from within a Kubernetes to a cluster-external endpoint, e.g. to you

Dec 16, 2022
A replacement for "kubectl exec" that works over WebSocket connections.

kubectl-execws A replacement for "kubectl exec" that works over WebSocket connections. Kubernetes API server has support for exec over WebSockets, but

Sep 23, 2022
Output all versions of a local git repo, which could be used as test data for your ML program.

gitwalker Output all versions of a local git repo, which could be used as test data for your ML program. Notice This program is under development. Cur

Dec 27, 2021
preflight helps you verify scripts and executables to mitigate chain of supply attacks such as the recent Codecov hack.
preflight helps you verify scripts and executables to mitigate chain of supply attacks such as the recent Codecov hack.

?? Mitigate chain of supply attacks ?? Verify your curl scripts and executables ?? What is it? preflight helps you verify scripts and executables to m

Nov 18, 2022
Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.
Monitor your Website and APIs from your Computer. Get Notified through Slack, E-mail when your server is down or response time is more than expected.

StatusOK Monitor your Website and APIs from your computer.Get notified through Slack or E-mail when your server is down or response time is more than

Dec 27, 2022
Automatically capture all potentially useful information about each executed command (as well as its output) and get powerful querying mechanism
Automatically capture all potentially useful information about each executed command (as well as its output) and get powerful querying mechanism

nhi is a revolutionary tool which automatically captures all potentially useful information about each executed command and everything around, and delivers powerful querying mechanism.

Nov 29, 2022
Bitrise step to parse a JaCoCo generated report and output the code coverage percentages to be used by other steps.

JaCoCo Report Parser This step parses a JaCoCo generated XML report in the jacoco_report_path and outputs the coverage percentages in a String format

Dec 6, 2021
colorizes kubectl output
colorizes kubectl output

kubecolor Colorize your kubectl output get pods describe pods something wrong You can change color theme for light-backgrounded environment What's thi

Jan 8, 2023