-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathfind_oduv6.sh
More file actions
66 lines (54 loc) · 1.83 KB
/
Copy pathfind_oduv6.sh
File metadata and controls
66 lines (54 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/ash
# Check for MAC argument
if [ $# -ne 1 ]; then
echo "Usage: $0 <MAC_ADDRESS>"
exit 1
fi
mac=$(echo "$1" | tr 'A-F' 'a-f')
# Validate MAC format (12 hex digits, no separators)
case "$mac" in
[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) ;;
*)
echo "Invalid MAC address format. Must be 12 hex digits, no colons or dashes."
exit 1
;;
esac
# Split into bytes
m1=${mac:0:2}
m2=${mac:2:2}
m3=${mac:4:2}
m4=${mac:6:2}
m5=${mac:8:2}
m6=${mac:10:2}
# Flip 7th bit of first byte
flip_byte=$(printf "%02x" $((0x$m1 ^ 0x02)))
# Construct link-local IPv6 (EUI-64)
ipv6="fe80::${flip_byte}${m2}:${m3}ff:fe${m4}:${m5}${m6}"
echo "[*] Generated IPv6 from MAC: $ipv6"
# Try interfaces eth0 to eth5
for i in 0 1 2 3 4 5; do
iface="eth$i"
echo "[*] Trying interface: $iface"
result=$(curl -g -6 -v --interface "$iface" "https://[$ipv6]/" --insecure --max-time 5 2>&1)
code=$(echo "$result" | sed -n 's/.*< HTTP\/[^ ]* \([0-9][0-9][0-9]\).*/\1/p')
case "$code" in
''|*[!0-9]*) code=0 ;;
esac
if [ "$code" -ge 200 ] 2>/dev/null && [ "$code" -lt 400 ] 2>/dev/null; then
echo ""
echo "[+] SUCCESS on interface: $iface (HTTP $code)"
echo "------------------------------------------------------------"
echo "✅ ODU Web UI is accessible at:"
echo " https://[$ipv6%$iface]:443"
echo ""
echo "🔐 To create an SSH tunnel from your local device, run:"
echo " ssh -L 8443:[$ipv6%$iface]:443 root@192.168.31.1"
echo "Then access it at https://localhost:8443"
echo "------------------------------------------------------------"
exit 0
else
echo "[-] Failed on $iface (HTTP $code)"
fi
done
echo "[!] Could not reach ODU on any interface."
exit 1