Fake router to simulate an internet connection within an isolated environment e.g. to inspect malicious software
Find a file
Peter b94961739a
Some checks failed
continuous-integration/drone/pr Build is failing
chore(deps): update module github.com/datadog/ebpf-manager to v0.3.6
2023-11-10 00:24:30 +00:00
.concourse chore: run Renovate on any worker 2023-02-08 22:09:33 +00:00
.run Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
api Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
assets Cleanup 2021-05-06 12:31:55 +02:00
build fix(deps): update module golang.org/x/net to v0.8.0 2023-03-06 00:31:13 +00:00
cmd feat: replace multierr with errors.Join 2023-02-08 20:32:18 +01:00
deploy chore(deps): update module github.com/docker/docker to v23 (#212) 2023-02-28 19:48:05 +00:00
docs Add advanced matching options to HTTP handler 2020-12-26 13:11:49 +00:00
internal fix(deps): update module github.com/dgraph-io/badger/v3 to v4 2023-03-01 08:02:18 +00:00
multiplexing Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
netflow fix: resolve linter issues 2023-02-15 20:23:10 +01:00
pkg chore(deps): update module github.com/docker/docker to v23 (#212) 2023-02-28 19:48:05 +00:00
protocols chore(deps): update module github.com/docker/docker to v23 (#212) 2023-02-28 19:48:05 +00:00
scripts Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
testdata chore(deps): update module github.com/docker/docker to v23 (#212) 2023-02-28 19:48:05 +00:00
.dockerignore Add health API and basic CLI support 2020-06-15 12:32:18 +02:00
.drone.yml refactor(ci): run on arm and skip feature branches in favor of PRs 2023-07-19 19:33:40 +00:00
.editorconfig fix: pull CI image to get latest version 2023-02-07 21:23:44 +01:00
.gitattributes Initial working version 2020-04-01 04:08:21 +02:00
.gitignore Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
.golangci.yml fix: resolve linter issues 2023-02-15 20:23:10 +01:00
.goreleaser.yml fix(deps): update golang.org/x/exp digest to 4b8118a (#189) 2023-01-17 20:14:52 +00:00
.ko.yaml fix(deps): update golang.org/x/exp digest to 4b8118a (#189) 2023-01-17 20:14:52 +00:00
.pre-commit-config.yaml Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
buf.gen.yaml Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
buf.work.yaml Implement profiling service 2021-11-17 16:42:37 +01:00
config-container.yaml Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
config.yaml Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
go.mod chore(deps): update module github.com/datadog/ebpf-manager to v0.3.6 2023-11-10 00:24:30 +00:00
go.sum chore(deps): update module github.com/datadog/ebpf-manager to v0.3.6 2023-11-10 00:24:30 +00:00
go.work feat: rework integration tests 2023-02-24 18:56:47 +01:00
go.work.sum chore(deps): update module github.com/docker/docker to v23 (#212) 2023-02-28 19:48:05 +00:00
LICENSE Create LICENSE 2020-04-11 12:17:15 +02:00
README.md Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00
renovate.json Update renovate config to not ignore vendor/ directory 2022-03-10 16:15:42 +01:00
Taskfile.yml Add network monitoring through eBPF 2022-12-21 21:15:05 +01:00

INetMock

pipeline status coverage report Go Report Card

INetMock is kind of a fork of INetSim. "Kind of" in terms that both applications overlap in their functionality to serve as "fake internet" routers.

INetMock right now does not implement so many protocols like INetSim. In fact it is only able to respond to HTTP, HTTPS, DNS, DNS-over-TLS (DoT) requests and to act as an HTTP proxy. The most notable advantage of INetMock over INetSim is that it issues proper TLS certificates on the fly signed by a CA certificate that can be deployed to client systems to achieve "proper" TLS encryption - as long as the client does not use certificate pinning or something similar.

A second advantage is that INetMock is a complete rewrite in Go. It has a way smaller memory footprint and far better startup and shutdown times. It also does not enforce root privileges as it is also possible to run the application with the required capabilities to open ports e.g. with SystemD (a sample unit file can be found in the deploy/ directory).

This project is still heavy work-in-progress. There may be breaking changes at any time. There's no guarantee for anything except no kittens will be harmed!

Use cases

While the original use case was to simulate an internet connection both server and client might be used for other things too:

  • serving as a mock API while developing an HTTP client library where you exactly know which requests should return which responses because you can match requests exactly with path and headers and return inline JSON, JSON from files, set status codes, ...
  • serving as an advanced client CLI if you design an HTTP server application because you can run integration tests very easy including validation of results
  • serving as an advanced client CLI if you design a custom DNS server because it's very easy to run queries (also from scripts) including support for custom ports - DoT and DoH client support is planned soon

Qickstart

So you're asking 'how do I get started to see what this thing can do for me?!' - then this is for you!

Docker/Podman

The probably easiest way to get started is to use the pre-built container image. The current tags can be found in the releases. The pre-built container image is configured with the config-container.yaml but you can always mount your own config. Because the default config binds to the ports 53, 80 and 443 it requires some additional capabilities:

docker/podman run --rm -ti --cap-add CAP_NET_RAW --cap-add CAP_NET_BIND_SERVICE --cap-add CAP_SYS_ADMIN registry.gitlab.com/inetmock/inetmock:latest

Depending on your use case it makes either sense to publish the ports of the container, run it in network mode host or isolate it to an internal network with the workload you're analyzing. A very basic example how to run a Vagrant VM with an INetMock instanced running with Podman in a 'private' network can be found here.

To run the container with a custom config just override the existing one like so:

docker/podman run --rm -ti -v `pwd`/config.yaml:/etc/inetmock/config.yaml:ro --cap-add CAP_NET_RAW --cap-add CAP_NET_BIND_SERVICE --cap-add CAP_SYS_ADMIN  registry.gitlab.com/inetmock/inetmock:latest

Note: The pre-built container image is based on the 'distroless/static:nonroot'. In consequence every file or directory you expect the container to access/modify needs corresponding access rights or you have to run the container with a different user.

Note: CAP_SYS_ADMIN is only required if you want to use the eBPF based network monitoring

Binaries

Binaries can also be found on the releases page. Due to dependencies to some Linux sub-systems (e.g. the whole PCAP recording stuff) there is only a Linux binary of the INetMock server. The client CLI imctl is available for Linux, MacOS and Windows (while it has to be noted that Windows and MacOS are not tested).

By default the server looks for config.yaml files in the following places:

  • /etc/inetmock/config.yaml
  • $HOME/.inetmock/config.yaml
  • ./config.yaml

Because INetMock requires a lot of setup it's not possible to configure it completely from flags hence you need a config in any of the aforementioned places. If you don't know where to start the default config.yaml from this repository might be a good start because it's also the one that is used during development and therefore always up-to-date.

imctl

To interact with the gRPC API of INetMock without having to write your own application imctl helps you to control your INetMock instance. imctl can be used to (probably not exhaustive):

  • interact with the audit API - the audit API allows you to monitor which requests INetMock handled in near-realtime, register an audit monitoring file to get a structured log, read those protobuf files to JSON and to remove an audit sink
  • interact with the health API - runs the defined health checks on the server side and returns the result including an exit code != 0 if any check fails
  • interact with the PCAP API - start/stop recording of network interface traffic to PCAP files, list available interfaces, list active recordings
  • run check scripts like the integration test or run single check commands like imctl check run "http.GET('https://google.com/favicon.ico') => Status(200)"

Everything that can be done from the CLI is documented with --help switches hence no huge documentation that will be outdated as soon as it is pushed here.

In general it always is a good idea to check the Taskfile.yml and the .gitlab-ci.yml files for examples on how to use client and server for different use cases.

Docs

Docs are available either in the docs/ directory or as rendered markdown book at the GitLab pages.

Contribution/feature requests

Please create an issue for any proposal, feature requests, found bug,... I'm glad for every kind of feedback!

Right now I've no special workflow for pull requests but I will look into every proposed change.