Skip to content

Commit 625568e

Browse files
committed
Refactor default rules and add example rules file
- Updated `default.rules.hcl` to provide a minimal configuration that allows all traffic by default. - Introduced `example.rules.hcl` containing sample rules demonstrating various actions for user customization.
1 parent 555d73a commit 625568e

3 files changed

Lines changed: 141 additions & 57 deletions

File tree

configs/default.rules.hcl

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,13 @@
1-
# Finch Example Rules
2-
# See documentation for full matcher options and schema.
3-
4-
# 1. Allow Chrome traffic identified by a specific JA4H
5-
rule "allow-chrome" {
6-
action = "allow"
7-
8-
when {
9-
http_ja4h = ["ge20nn15engb_74941313fa48_000000000000_000000000000"]
10-
}
11-
}
12-
13-
# 2. Route Safari traffic to example.com
14-
rule "route-safari" {
15-
action = "route"
16-
upstream = "https://example.com/"
17-
18-
when {
19-
tls_ja4 = ["t13i2013h2_a09f3c656075_e42f34c56612"]
20-
}
21-
}
22-
23-
# 3. Tarpit curl‑like requests hitting /yo
24-
rule "tarpit-curl-sus" {
25-
action = "tarpit"
26-
27-
when all {
28-
tls_ja3 = ["4f2655722e37c542ebeaf1eed48cbbbb"]
29-
http_path = ["= /yo"]
30-
}
31-
}
32-
33-
# 4. Deceive any request that triggers a Suricata HTTP rule
34-
rule "deceive-suri-match" {
35-
action = "deceive"
36-
37-
when {
38-
suricata_msg = ["~ .+"] # match if the message is non‑empty
39-
}
40-
}
1+
# Finch default rule set
2+
#
3+
# This file is intentionally minimal so that Finch can be run immediately after
4+
# cloning the repository without requiring additional services. By default, Finch
5+
# will allow all traffic because the main configuration’s `default_action` is set
6+
# to `allow`.
7+
#
8+
# To add your own policies, define rules here using the format described in
9+
# `docs/rule-schema.md`. For example rules demonstrating each action, see
10+
# `configs/example.rules.hcl`.
11+
12+
# No rules are defined in this file. Finch will apply the default action to all
13+
# requests.

configs/example.rules.hcl

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Finch rule examples
2+
#
3+
# This file contains sample rules demonstrating each supported action. Copy
4+
# individual rules into your own rules file and tailor the matching conditions
5+
# to your environment. Refer to the rule schema documentation for further
6+
# details.
7+
#
8+
# Note: The `deceive` action depends on a Galah configuration. Finch will exit
9+
# with an error if a deceive rule is loaded without a corresponding `galah`
10+
# block in your configuration.
11+
12+
# ---------------------------------------------------------------------------
13+
# 1. Allow traffic matching a JA4H fingerprint (e.g. a specific Chrome build).
14+
# Requests matching this rule bypass any downstream filters.
15+
rule "allow-chrome" {
16+
action = "allow"
17+
18+
when {
19+
http_ja4h = ["ge20nn15engb_74941313fa48_000000000000_000000000000"]
20+
}
21+
}
22+
23+
# ---------------------------------------------------------------------------
24+
# 2. Route Safari traffic to a different upstream based on its TLS fingerprint.
25+
rule "route-safari" {
26+
action = "route"
27+
upstream = "https://example.com/"
28+
29+
when {
30+
tls_ja4 = ["t13i2013h2_a09f3c656075_e42f34c56612"]
31+
}
32+
}
33+
34+
# ---------------------------------------------------------------------------
35+
# 3. Deceive requests to admin paths or those that trigger a Suricata HTTP rule.
36+
# Requires a configured Galah deception service.
37+
rule "deceive-admin" {
38+
action = "deceive"
39+
40+
when any {
41+
http_path = ["^ /admin"]
42+
suricata_msg = ["~ .+"]
43+
}
44+
}
45+
46+
# ---------------------------------------------------------------------------
47+
# 4. Deny rules: block common scanning tools by their JA3/JA4 fingerprints.
48+
49+
# Block Nmap TLS fingerprints (no‑SNI and SNI variants)
50+
rule "block-nmap" {
51+
action = "deny"
52+
53+
when all {
54+
tls_ja3 = [
55+
"ee2b1d84fa1d67ced85c6284a724888e",
56+
# no-SNI probe
57+
"2fd66e5dee273eef288bf5efcc10a71a",
58+
]
59+
60+
tls_ja4 = [
61+
"t13d801100_59a17bb9eabe_d41ae481755e",
62+
# no-SNI probe
63+
"t13i801000_59a17bb9eabe_d41ae481755e",
64+
]
65+
}
66+
}
67+
68+
# Block ZAP active‑scan traffic
69+
rule "block-zap" {
70+
action = "deny"
71+
72+
when all {
73+
# TLS fingerprints
74+
tls_ja3 = [
75+
"795a08fe385896aee616d3b7236502da",
76+
"20ee858fb3bcdda802d5f5caaa5e1122",
77+
]
78+
tls_ja4 = [
79+
"t13i371100_db35923f8641_7c76daad20ec",
80+
"t13i371200_db35923f8641_867a32efce91"
81+
]
82+
83+
# HTTP fingerprint
84+
http_ja4h = ["ge11nn040000_d5cb08ea9ac8_000000000000_000000000000"]
85+
}
86+
}
87+
88+
# Block Burp Repeater
89+
rule "block-burp" {
90+
action = "deny"
91+
92+
when all {
93+
tls_ja3 = [
94+
"62f6a6727fda5a1104d5b147cd82e520",
95+
# no-SNI
96+
"c53a2c34afdebeea3d08e9b86e555e7a",
97+
]
98+
99+
tls_ja4 = [
100+
"t13d4913h2_bd868743f55c_aac333855136",
101+
# no-SNI
102+
"t13i4912h2_bd868743f55c_aac333855136",
103+
]
104+
105+
http_http2 = ["3:1000;2:0;4:6291456;1:4096|15663105|0|s,m,p,a"]
106+
}
107+
}

configs/finch.hcl

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
defaults {
2-
rule_file = "default.rules.hcl"
3-
access_log = "../events.jsonl"
4-
default_action = "deny"
2+
# Path to the rule file that will be loaded for all listeners.
3+
# This path is resolved relative to this configuration file's location.
4+
rule_file = "default.rules.hcl"
5+
6+
# Write access logs to a local events file by default. Modify this to suit your
7+
# deployment environment.
8+
access_log = "../events.jsonl"
9+
10+
# Specify the fallback action when no rule matches. For an out‑of‑the‑box
11+
# experience, allow all traffic unless rules dictate otherwise.
12+
default_action = "allow"
513
# upstream_ca_file = "/etc/ssl/private/upstream.pem"
614
# upstream_skip_tls_verify = false
715
}
816

9-
# enable admin API and SSE feed
17+
# Enable the admin API and SSE feed on localhost.
1018
admin {
1119
enabled = true
1220
addr = "127.0.0.1:9035"
@@ -17,25 +25,21 @@ sse {
1725
addr = "127.0.0.1:9036"
1826
}
1927

20-
# example suricata configuration
21-
# suricata {
22-
# enabled = true
23-
# rules_dir = "/etc/suricata/rules"
24-
# }
25-
26-
listener "primary" {
28+
# Example listener definitions. Each listener exposes a TLS service on the
29+
# specified bind address and forwards requests to an upstream. Adjust these to
30+
# match your environment.
31+
listener "server1" {
2732
bind = "0.0.0.0:8443"
2833
upstream = "http://localhost:8080"
2934
tls {}
30-
access_log = "../logs/public.jsonl"
3135
}
3236

33-
listener "honeypot" {
37+
listener "server2" {
3438
bind = "0.0.0.0:9443"
3539
upstream = "http://localhost:8081"
3640
tls {
37-
# cert = "path/to/cert.pem"
38-
# key = "path/to/key.pem"
41+
#cert = "path/to/server.crt"
42+
#key = "path/to/server.key"
3943
}
40-
access_log = "../logs/honeypot.jsonl"
41-
}
44+
#access_log = "../logs/primary.jsonl"
45+
}

0 commit comments

Comments
 (0)