f-76: e2e: filtrage par VM dans 35, serveur DHCP diskless dans 33 #76
35 : les known #76 deviennent des contrôles ; IP, MAC, ARP usurpés, 0.0.0.0 hors DHCP et type non IP bloqués à la sortie de t35-a, avec témoins ; t35-c en dhcp_server ; watchdog et retrait des règles. Côté fabric, les trames usurpées partent d'un port d'injection non filtré. 33 : t33-px sert le DHCP sur le segment, t33-a1 non. Helpers frames udp, ns_frames, nft_tap_of. Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
74bfda7004
commit
e62c283370
6 changed files with 156 additions and 33 deletions
|
|
@ -139,6 +139,8 @@ if cmd == 'arp':
|
|||
emit(a[0], arp_req(ifmac(a[0]), a[1], a[2]), int(a[3]))
|
||||
elif cmd == 'dhcp':
|
||||
emit(a[0], udp_bcast(ifmac(a[0]), a[1], 67, int(a[2]), b'two-e2e-dhcp'.ljust(240, b'\0')), int(a[3]))
|
||||
elif cmd == 'udp':
|
||||
emit(a[0], udp_bcast(a[5] if len(a) > 5 else ifmac(a[0]), a[1], int(a[2]), int(a[3]), b'two-e2e-udp'.ljust(46, b'\0')), int(a[4]))
|
||||
elif cmd == 'garp':
|
||||
emit(a[0], garp(ifmac(a[0]), a[1]), int(a[2]))
|
||||
elif cmd == 'marker':
|
||||
|
|
@ -166,6 +168,12 @@ vm_frames () {
|
|||
vm_ssh "${vpc}" "${ip}" "echo $(frames_py | base64 | tr -d '\n') | base64 -d > /tmp/frames.py && sudo python3 /tmp/frames.py $*"
|
||||
}
|
||||
|
||||
ns_frames () {
|
||||
local ns="${1}"
|
||||
shift
|
||||
frames_py | ip netns exec "${ns}" python3 - "$@"
|
||||
}
|
||||
|
||||
sniff_start () {
|
||||
local out="${1}"
|
||||
shift
|
||||
|
|
@ -209,6 +217,10 @@ nft_dhcp_drop () {
|
|||
[ "$(nft_count "${1}" "${2}" "ip saddr ${3} udp sport 67-68 udp dport 67-68 drop")" -gt 0 ]
|
||||
}
|
||||
|
||||
nft_tap_of () {
|
||||
nft_table "${1}" | awk -v r="ether saddr != $(tr 'A-F' 'a-f' <<<"${2}") drop" '$1 == "chain" {c = $2; next} {line = $0; sub(/^[ \t]+/, "", line)} line == r && c ~ /^pre-tap/ {print substr(c, 5)}'
|
||||
}
|
||||
|
||||
nft_handle () {
|
||||
ip netns exec "${1}" nft -a list chain bridge two "${2}" | awk -v r="${3}" '{line = $0; sub(/^[ \t]+/, "", line); if (sub(/ # handle [0-9]+$/, "", line) && line == r) print $NF}'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ vm_json () {
|
|||
sn=${2%%=*}; rest=${2#*=}; ip=${rest%%=*}; mac=$(mac_for_ip "${ip}")
|
||||
[ "${rest}" != "${ip}" ] && mac=${rest#*=}
|
||||
nics=$(jq -c --arg s "${sn}" --arg ip "${ip}" --arg m "${mac}" --argjson p "${primary}" '. + [{subnet: $s, ip: $ip, mac: $m, primary: $p}]' <<<"${nics}"); primary=false; shift 2 ;;
|
||||
--dhcp-server) nics=$(jq -c '.[-1].dhcp_server = true' <<<"${nics}"); shift ;;
|
||||
--disk) disks=$(jq -c --arg d "${2%%=*}" --arg p "${2#*=}" '. + [{path: $p, dev: $d}]' <<<"${disks}"); shift 2 ;;
|
||||
--sshkey) meta=$(jq -c --arg v "${2}" '. + {sshkey: $v}' <<<"${meta}"); shift 2 ;;
|
||||
--password) meta=$(jq -c --arg v "${2}" '. + {password: $v}' <<<"${meta}"); shift 2 ;;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue