-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from jwhb/synproxy
Implement SynProxy
- Loading branch information
Showing
6 changed files
with
405 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,299 @@ | ||
{ | ||
"nftables": [ | ||
{ | ||
"metainfo": { | ||
"version": "1.0.6", | ||
"release_name": "Lester Gooch #5", | ||
"json_schema_version": 1 | ||
} | ||
}, | ||
{ | ||
"table": { | ||
"family": "ip", | ||
"name": "synproxy_anonymous", | ||
"handle": 1 | ||
} | ||
}, | ||
{ | ||
"chain": { | ||
"family": "ip", | ||
"table": "synproxy_anonymous", | ||
"name": "PREROUTING", | ||
"handle": 1, | ||
"type": "filter", | ||
"hook": "prerouting", | ||
"prio": -300, | ||
"policy": "accept" | ||
} | ||
}, | ||
{ | ||
"chain": { | ||
"family": "ip", | ||
"table": "synproxy_anonymous", | ||
"name": "INPUT", | ||
"handle": 2, | ||
"type": "filter", | ||
"hook": "input", | ||
"prio": 0, | ||
"policy": "accept" | ||
} | ||
}, | ||
{ | ||
"rule": { | ||
"family": "ip", | ||
"table": "synproxy_anonymous", | ||
"chain": "PREROUTING", | ||
"handle": 3, | ||
"expr": [ | ||
{ | ||
"match": { | ||
"op": "==", | ||
"left": { | ||
"payload": { | ||
"protocol": "tcp", | ||
"field": "dport" | ||
} | ||
}, | ||
"right": 8080 | ||
} | ||
}, | ||
{ | ||
"match": { | ||
"op": "in", | ||
"left": { | ||
"payload": { | ||
"protocol": "tcp", | ||
"field": "flags" | ||
} | ||
}, | ||
"right": "syn" | ||
} | ||
}, | ||
{ | ||
"notrack": null | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"rule": { | ||
"family": "ip", | ||
"table": "synproxy_anonymous", | ||
"chain": "INPUT", | ||
"handle": 4, | ||
"expr": [ | ||
{ | ||
"match": { | ||
"op": "==", | ||
"left": { | ||
"payload": { | ||
"protocol": "tcp", | ||
"field": "dport" | ||
} | ||
}, | ||
"right": 8080 | ||
} | ||
}, | ||
{ | ||
"match": { | ||
"op": "in", | ||
"left": { | ||
"ct": { | ||
"key": "state" | ||
} | ||
}, | ||
"right": [ | ||
"invalid", | ||
"untracked" | ||
] | ||
} | ||
}, | ||
{ | ||
"synproxy": { | ||
"mss": 1460, | ||
"wscale": 7, | ||
"flags": [ | ||
"timestamp", | ||
"sack-perm" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"rule": { | ||
"family": "ip", | ||
"table": "synproxy_anonymous", | ||
"chain": "INPUT", | ||
"handle": 5, | ||
"expr": [ | ||
{ | ||
"match": { | ||
"op": "in", | ||
"left": { | ||
"ct": { | ||
"key": "state" | ||
} | ||
}, | ||
"right": "invalid" | ||
} | ||
}, | ||
{ | ||
"drop": null | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"table": { | ||
"family": "ip", | ||
"name": "synproxy_named", | ||
"handle": 2 | ||
} | ||
}, | ||
{ | ||
"synproxy": { | ||
"family": "ip", | ||
"name": "synproxy_named_1", | ||
"table": "synproxy_named", | ||
"handle": 3, | ||
"mss": 1460, | ||
"wscale": 7, | ||
"flags": [ | ||
"timestamp", | ||
"sack-perm" | ||
] | ||
} | ||
}, | ||
{ | ||
"synproxy": { | ||
"family": "ip", | ||
"name": "synproxy_named_2", | ||
"table": "synproxy_named", | ||
"handle": 4, | ||
"mss": 1460, | ||
"wscale": 5 | ||
} | ||
}, | ||
{ | ||
"chain": { | ||
"family": "ip", | ||
"table": "synproxy_named", | ||
"name": "PREROUTING", | ||
"handle": 1, | ||
"type": "filter", | ||
"hook": "prerouting", | ||
"prio": -300, | ||
"policy": "accept" | ||
} | ||
}, | ||
{ | ||
"chain": { | ||
"family": "ip", | ||
"table": "synproxy_named", | ||
"name": "FORWARD", | ||
"handle": 2, | ||
"type": "filter", | ||
"hook": "forward", | ||
"prio": 0, | ||
"policy": "accept" | ||
} | ||
}, | ||
{ | ||
"rule": { | ||
"family": "ip", | ||
"table": "synproxy_named", | ||
"chain": "PREROUTING", | ||
"handle": 5, | ||
"expr": [ | ||
{ | ||
"match": { | ||
"op": "==", | ||
"left": { | ||
"payload": { | ||
"protocol": "tcp", | ||
"field": "dport" | ||
} | ||
}, | ||
"right": 8080 | ||
} | ||
}, | ||
{ | ||
"match": { | ||
"op": "in", | ||
"left": { | ||
"payload": { | ||
"protocol": "tcp", | ||
"field": "flags" | ||
} | ||
}, | ||
"right": "syn" | ||
} | ||
}, | ||
{ | ||
"notrack": null | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"rule": { | ||
"family": "ip", | ||
"table": "synproxy_named", | ||
"chain": "FORWARD", | ||
"handle": 7, | ||
"expr": [ | ||
{ | ||
"match": { | ||
"op": "in", | ||
"left": { | ||
"ct": { | ||
"key": "state" | ||
} | ||
}, | ||
"right": [ | ||
"invalid", | ||
"untracked" | ||
] | ||
} | ||
}, | ||
{ | ||
"synproxy": { | ||
"map": { | ||
"key": { | ||
"payload": { | ||
"protocol": "ip", | ||
"field": "saddr" | ||
} | ||
}, | ||
"data": { | ||
"set": [ | ||
[ | ||
{ | ||
"prefix": { | ||
"addr": "192.168.1.0", | ||
"len": 24 | ||
} | ||
}, | ||
"synproxy_named_1" | ||
], | ||
[ | ||
{ | ||
"prefix": { | ||
"addr": "192.168.2.0", | ||
"len": 24 | ||
} | ||
}, | ||
"synproxy_named_2" | ||
] | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
table ip synproxy_anonymous { | ||
|
||
chain PREROUTING { | ||
type filter hook prerouting priority raw; policy accept; | ||
tcp dport 8080 tcp flags syn notrack | ||
} | ||
|
||
chain INPUT { | ||
type filter hook input priority filter; policy accept; | ||
tcp dport 8080 ct state invalid,untracked synproxy mss 1460 wscale 7 timestamp sack-perm | ||
ct state invalid drop | ||
} | ||
} | ||
|
||
table ip synproxy_named { | ||
|
||
synproxy synproxy_named_1 { | ||
mss 1460 | ||
wscale 7 | ||
timestamp sack-perm | ||
} | ||
|
||
synproxy synproxy_named_2 { | ||
mss 1460 | ||
wscale 5 | ||
} | ||
|
||
chain PREROUTING { | ||
type filter hook prerouting priority raw; policy accept; | ||
tcp dport 8080 tcp flags syn notrack | ||
} | ||
|
||
chain FORWARD { | ||
type filter hook forward priority filter; policy accept; | ||
|
||
ct state invalid,untracked synproxy name ip saddr map { | ||
192.168.1.0/24 : "synproxy_named_1", | ||
192.168.2.0/24 : "synproxy_named_2", | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.