{"id":18131727,"url":"https://github.com/mrtc0/ebpf-demo","last_synced_at":"2025-04-06T15:30:03.280Z","repository":{"id":222935944,"uuid":"758774506","full_name":"mrtc0/ebpf-demo","owner":"mrtc0","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-17T06:19:49.000Z","size":836,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T22:05:36.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrtc0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-17T03:36:04.000Z","updated_at":"2024-02-17T03:36:33.000Z","dependencies_parsed_at":"2024-02-17T05:35:09.985Z","dependency_job_id":null,"html_url":"https://github.com/mrtc0/ebpf-demo","commit_stats":null,"previous_names":["mrtc0/ebpf-demo"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtc0%2Febpf-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtc0%2Febpf-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtc0%2Febpf-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrtc0%2Febpf-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrtc0","download_url":"https://codeload.github.com/mrtc0/ebpf-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247502719,"owners_count":20949312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-01T12:08:48.439Z","updated_at":"2025-04-06T15:30:03.262Z","avatar_url":"https://github.com/mrtc0.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eBPF Demos\n\nThis repository contains the code I used for the demo during my [talk](https://speakerdeck.com/mrtc0/kododeli-jie-suru-ebpf-sekiyuriteimonitaringu) @ [\"eBPF \u0026 コンテナ情報交換会 @ 福岡\"](https://engineercafe.connpass.com/event/309223/).  \nThis is a demonstration of using `bpf_override_return()` and `bpf_send_signal()` to stop a process when there is a suspicious network connections.\n\n# Usage\n\n## Requirements\n\n* Ubuntu 22.04 (Kernel \u003e= 5.15)\n* Install `bpftool` and other packages\n\n```shell\n$ sudo apt install build-essential libbpf-dev clang llvm linux-tools-generic\n```\n\n* Kernel was compiled with the following two configurations\n\n```\nCONFIG_FUNCTION_ERROR_INJECTION=y\nCONFIG_BPF_KPROBE_OVERRIDE=y\n```\n\n## Build\n\n```shell\n$ make build\n```\n\n## Run\n\nWanna try to trace connections towards \"https://example.com\" (93.184.216.34):\n\n```shell\n$ sudo ./bin/ebpf-demo tracer\n```\n\nThen, in another terminal:\n\n```shell\n$ curl https://example.com\n```\n\nAnd observe the output in terminal:\n\n```shell\n2024/02/17 04:29:53 INFO ⏫ CONNECT comm=curl addr=93.184.216.34\n```\n\nThen to block the connection:\n\n```shell\n$ sudo ./bin/ebpf-demo enforce\n```\n\nRunning `curl https://example.com` in the same way will block the connection:\n\n```shell\n$ curl https://example.com\nKilled\n```\n\n```shell\n2024/02/17 04:30:32 INFO 🛡 BLOCKED comm=curl addr=93.184.216.34\n```\n\nIf use `wget` instead of `curl`, it will not be blocked.\n\n```shell\n$ wget https://example.com\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtc0%2Febpf-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrtc0%2Febpf-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtc0%2Febpf-demo/lists"}