From 833a06ce8d39e61d4962538b52da85e74e6222b4 Mon Sep 17 00:00:00 2001 From: alarig Date: Thu, 24 Jan 2019 18:02:59 +0100 Subject: [PATCH] =?UTF-8?q?Send=20ICMP=20to=20update=20ARP/NDP=20target?= =?UTF-8?q?=E2=80=99s=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- creationRoutesVM.sh | 7 +++++++ send-icmp.py | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 send-icmp.py diff --git a/creationRoutesVM.sh b/creationRoutesVM.sh index 8a83279..49249d3 100755 --- a/creationRoutesVM.sh +++ b/creationRoutesVM.sh @@ -194,6 +194,8 @@ for ID_RANGE_V4 in ${ID_RANGES_V4}; do if [ $? = 2 ]; then ip neigh replace ${VM_IPV4} lladdr ${MAC} dev ${IFACE} fi + + GW_IPv4=$(jq -r ".data[] | select(.is_gateway==\"1\") | .ip" ${CHEMIN_CACHE}/${ID_RANGE_V4}) else # En cas d'echec, on continue de parcourir les autres RANGES write_log WARN 'Empty value or doen’t correspond to an IPv4' @@ -237,11 +239,16 @@ for ID_RANGE_V6 in ${ID_RANGES_V6}; do if [ $? = 2 ]; then ip neigh replace ${VM_NH} lladdr ${MAC} dev ${IFACE} fi + + GW_IPv6="fe80::204:92:100:1" else # En cas d'echec, on continue de parcourir les autres RANGES echo "Valeur vide ou ne correspond pas à un range IPV6" fi done +# Send ICMP to update ARP/NDP cache +send-icmp.py ${MAC} ${IFACE} ${VM_IPV4} ${GW_IPv4} ${VM_NH} ${GW_IPv6} + write_log INFO 'Script ended' exit 0 diff --git a/send-icmp.py b/send-icmp.py new file mode 100755 index 0000000..f4c20b1 --- /dev/null +++ b/send-icmp.py @@ -0,0 +1,18 @@ +#!/usr/bin/python3 + +from scapy.all import * + +etherDest= sys.argv[1] +iface= sys.argv[2] + +ipDest= sys.argv[3] +ipSrc= sys.argv[4] + +# send 10 IPv4 ICMP echo requests +sendp(Ether(dst=etherDest)/IP(dst=ipDest, src=ipSrc, ttl=(1,10))/ICMP(), iface=iface) + +ipDest= sys.argv[5] +ipSrc= sys.argv[6] + +# send 10 IPv6 ICMP echo requests +sendp(Ether(dst=etherDest)/IPv6(dst=ipDest, src=ipSrc, hlim=(1,10))/ICMPv6EchoRequest(), iface=iface)