Skip to content

Commit 65e6d35

Browse files
committed
CKs Falco
1 parent 1fc2ab3 commit 65e6d35

File tree

6 files changed

+163
-0
lines changed

6 files changed

+163
-0
lines changed

falco/falcohost/Readme.md

Whitespace-only changes.

falco/falcohost/deploy.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: demo3
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: demo3
10+
template:
11+
metadata:
12+
labels:
13+
app: demo3
14+
spec:
15+
nodeName: cplane-01
16+
containers:
17+
- name: busybox
18+
image: busybox
19+
command: ["/bin/sh", "-c", "while true; do cat /dev/mem; sleep 10; done"]
20+
securityContext:
21+
privileged: true

falco/falcohost/rule.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- list: memoryfile
2+
items: [/dev/mem]
3+
- rule: mem
4+
desc: mem
5+
condition: >
6+
fd.name=memoryfile
7+
output: >
8+
Shell (%fd.name,%container.id)
9+
priority: WARNING
10+
tags: [security]

falco/newrule/Readme.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## Install Falco
2+
```
3+
helm repo add falcosecurity https://falcosecurity.github.io/charts
4+
helm repo update
5+
helm install falco falcosecurity/falco -n falco --create-namespace
6+
```
7+
8+
## Cutom Falco Rule `custom-falco-rules.yaml`
9+
```
10+
- rule: Detect /dev/mem Access
11+
desc: Detect processes that attempt to read /dev/mem
12+
condition: (evt.type=open or evt.type=openat) and fd.name=/dev/mem
13+
output: "Process %proc.name accessed /dev/mem (command=%proc.cmdline user=%user.name container=%container.id image=%container.image.repository)"
14+
priority: WARNING
15+
tags: [security]
16+
17+
```
18+
## Apply the rule
19+
20+
```
21+
kubectl create configmap falco-custom-rules --from-file=custom-falco-rules.yaml -n falco
22+
kubectl patch daemonset falco -n falco --type='json' -p='[
23+
{
24+
"op": "add",
25+
"path": "/spec/template/spec/volumes/-",
26+
"value": {
27+
"name": "custom-rules",
28+
"configMap": {
29+
"name": "falco-custom-rules"
30+
}
31+
}
32+
}
33+
]'
34+
35+
kubectl patch daemonset falco -n falco --type='json' -p='[
36+
{
37+
"op": "add",
38+
"path": "/spec/template/spec/containers/0/volumeMounts/-",
39+
"value": {
40+
"name": "custom-rules",
41+
"mountPath": "/etc/falco/rules.d/custom-falco-rules.yaml",
42+
"subPath": "custom-falco-rules.yaml"
43+
}
44+
}
45+
]'
46+
kubectl rollout restart daemonset falco -n falco
47+
48+
```
49+
50+
## check Falco logs
51+
52+
```
53+
kubectl logs -n falco -l app.kubernetes.io/name=falco --tail=50 -f
54+
55+
```

falco/newrule/deploy.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: demo1
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: demo1
10+
template:
11+
metadata:
12+
labels:
13+
app: demo1
14+
spec:
15+
containers:
16+
- name: busybox
17+
image: busybox
18+
command: ["/bin/sh", "-c", "sleep 3600"]
19+
20+
---
21+
apiVersion: apps/v1
22+
kind: Deployment
23+
metadata:
24+
name: demo2
25+
spec:
26+
replicas: 1
27+
selector:
28+
matchLabels:
29+
app: demo2
30+
template:
31+
metadata:
32+
labels:
33+
app: demo2
34+
spec:
35+
containers:
36+
- name: busybox
37+
image: busybox
38+
command: ["/bin/sh", "-c", "sleep 3600"]
39+
40+
---
41+
apiVersion: apps/v1
42+
kind: Deployment
43+
metadata:
44+
name: demo3
45+
spec:
46+
replicas: 1
47+
selector:
48+
matchLabels:
49+
app: demo3
50+
template:
51+
metadata:
52+
labels:
53+
app: demo3
54+
spec:
55+
containers:
56+
- name: busybox
57+
image: busybox
58+
command: ["/bin/sh", "-c", "while true; do cat /dev/mem; sleep 10; done"]
59+
securityContext:
60+
privileged: true
61+

falco/output_change/Readme.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Install Falco
2+
```
3+
curl -L -O https://download.falco.org/packages/bin/x86_64/falco-0.40.0-x86_64.tar.gz
4+
tar -xvf falco-0.40.0-x86_64.tar.gz
5+
cp -R falco-0.40.0-x86_64/* /
6+
apt update -y
7+
apt install -y dkms make linux-headers-$(uname -r)
8+
# If you use falcoctl driver loader to build the eBPF probe locally you need also clang toolchain
9+
apt install -y clang llvm
10+
```
11+
### Run shell inside a container
12+
```
13+
docker run --name ubuntu bash --rm -i -t ubuntu bash
14+
```
15+
### Change Falco Rules
16+
`output: "[%evt.time][%container.id] [%container.name]"`

0 commit comments

Comments
 (0)