aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarKrytarik Raido <krytarik@tuxgarage.com>2015-07-14 19:10:56 +0200
committerLibravatarKrytarik Raido <krytarik@tuxgarage.com>2015-07-14 19:10:56 +0200
commit53511f6b635ccdf0fdcf1f4ec31bf986a749d5bc (patch)
tree6f8eed5d9adc9e159b22c0963ee864ad4eca7287
parent1da993829245a97ca0845614d4cbb4c553a24e55 (diff)
downloadwireless-info-53511f6b635ccdf0fdcf1f4ec31bf986a749d5bc.tar.bz2
wireless-info-53511f6b635ccdf0fdcf1f4ec31bf986a749d5bc.tar.xz
wireless-info-53511f6b635ccdf0fdcf1f4ec31bf986a749d5bc.tar.zst
Mask IPv6 addresses derived from MAC addresses too.
-rwxr-xr-xwireless-info26
1 files changed, 22 insertions, 4 deletions
diff --git a/wireless-info b/wireless-info
index a07637b..84a4b56 100755
--- a/wireless-info
+++ b/wireless-info
@@ -25,7 +25,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-SCRIPTDATE="2015-05-21 11:10 +0200"
+SCRIPTDATE="2015-07-14 19:04 +0200"
FILEBASE="wireless-info"
OUTPUTDIR="$PWD"
OUTPUTDIRFB="/tmp"
@@ -42,6 +42,8 @@ PMUTILSEXCL="/etc/pm/(power.d/(95hdparm-apm|intel-audio-powersave|sata_alpm)|sle
NETMGRNAMES=("NetworkManager" "Wicd" "ConnMan")
NETMGRPATHS=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand")
+DEC2BI=({0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1})
+DEC2HEX=($(printf "%02x " {0..255}))
export LANG="en_US.UTF-8"
export LANGUAGE="en_US:en"
@@ -118,6 +120,16 @@ dialog_question () {
esac
}
+ip6-mac () {
+ for MAC in "$@"; do
+ OCT1BI=${DEC2BI[0x${MAC:0:2}]}
+ OCT1BI7=$((${OCT1BI:6:1} - 1))
+ OCT1BIM="${OCT1BI:0:6}${OCT1BI7#-}${OCT1BI:7}"
+ IP6S+=${IP6S:+$'\n'}"${DEC2HEX[2#$OCT1BIM]}${MAC:3:2}:${MAC:6:2}ff:fe${MAC:9:2}:${MAC:12:2}${MAC:15:2}"
+ done
+ sed 's/\(^\|:\)0\+\([[:alnum:]]\)/\1\2/g;s/^\([0:]\+\)/\\(::\\|\1\\)/' <<< "$IP6S"
+}
+
exec 3>&1 4>&2
exec 1> "$OUTPUTDIR/$FILEBASE.txt" || {
dialog_error "${TERMOUT+\n}Cannot write output file in \"$OUTPUTDIR\",${DIALOGBREAK}trying in \"$OUTPUTDIRFB\" instead.${TERMOUT+\n}"
@@ -163,7 +175,7 @@ else
fi
printf "\n##### lspci #############################\n\n"
-lspci -nnk | grep -iA 2 '^[^[:space:]].*net' | sed '/^--$/d;/^[^[:space:]]/ i\\'
+lspci -nnk | grep -iA 2 '^[^[:space:]].*net' | sed '/^--$/d; /^[^[:space:]]/ i\\'
printf "\n##### lsusb #############################\n\n"
lsusb
@@ -363,30 +375,36 @@ IFS=$'\n'
IFACESRAW=$(sed -n '/^##### ifconfig #####/,/^##### /p' <<< "$RESULTS")
IFACESIDS=($(sed -n "s/^\([^ ]\+\)[ ]\+.*HWaddr.*/'\1' [IF]/p" <<< "$IFACESRAW"))
IFACESMACS=($(sed -n 's/^[^ ]\+[ ]\+.*HWaddr \([^ ]\+\)[ ]*/\1/p' <<< "$IFACESRAW"))
+IFACESIP6S=($(ip6-mac "${IFACESMACS[@]}"))
WLAPSIWLRAW=$(sed -n '/^##### iwlist scan #####/,/^##### /p' <<< "$RESULTS")
-WLAPSIWLIDS=($(sed -n "/^[ ]*Cell [0-9]\+/,/^[ ]*ESSID:/ {/^[ ]*Cell [0-9]\+/h;/^[ ]*ESSID:/ {H;g;s/^[ ]*Cell 0\?\([0-9]\+\).*ESSID:\"\(.*\)\"$/'\2' [AC\1]/p}}" <<< "$WLAPSIWLRAW"))
+WLAPSIWLIDS=($(sed -n "/^[ ]*Cell [0-9]\+/,/^[ ]*ESSID:/ {/^[ ]*Cell [0-9]\+/h; /^[ ]*ESSID:/ {H;g;s/^[ ]*Cell 0\?\([0-9]\+\).*ESSID:\"\(.*\)\"$/'\2' [AC\1]/p}}" <<< "$WLAPSIWLRAW"))
WLAPSIWLMACS=($(sed -n 's/^[ ]*Cell [0-9]\+.*Address: \([^ ]\+\)/\1/p' <<< "$WLAPSIWLRAW"))
+WLAPSIWLIP6S=($(ip6-mac "${WLAPSIWLMACS[@]}"))
WLAPSNMRAW=$(sed -n '/^##### NetworkManager info #####/,/^##### / {/^[ ]*Wireless Access Points/,/^$/ {/Wireless Access Points/d;s/^[ ]\+\*\?//;s/:[ ]\+/\t/;p}; /^SSID[ ]\+BSSID[ ]\+/,/^$/ {/^SSID[ ]\{2,\}BSSID[ ]\{2,\}/d;s/[ ]\{2,\}/\t/;p}}' <<< "$RESULTS")
WLAPSNMIDS=($(awk -F '\t' '{printf "'\''%s'\'' [AN%d]\n", $1, NR}' <<< "$WLAPSNMRAW"))
WLAPSNMMACS=($(grep -o '\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}' <<< "$WLAPSNMRAW"))
+WLAPSNMIP6S=($(ip6-mac "${WLAPSNMMACS[@]}"))
IFS="$ORIGIFS"
for IFACENR in "${!IFACESMACS[@]}"; do
MACMASKSED+="s;${IFACESMACS[$IFACENR]};<MAC ${IFACESIDS[$IFACENR]-address}>;I;"
+ MACMASKSED+=" /${IFACESIP6S[$IFACENR]}/ s;${IFACESIP6S[$IFACENR]/#\\(::/\(};<IP6 ${IFACESIDS[$IFACENR]-from MAC}>;I;"
done
for WLAPIWLNR in "${!WLAPSIWLMACS[@]}"; do
MACMASKSED+="s;${WLAPSIWLMACS[$WLAPIWLNR]};<MAC ${WLAPSIWLIDS[$WLAPIWLNR]-address}>;I;"
+ MACMASKSED+=" /${WLAPSIWLIP6S[$WLAPIWLNR]}/ s;${WLAPSIWLIP6S[$WLAPIWLNR]/#\\(::/\(};<IP6 ${WLAPSIWLIDS[$WLAPIWLNR]-from MAC}>;I;"
done
for WLAPNMNR in "${!WLAPSNMMACS[@]}"; do
MACMASKSED+="s;${WLAPSNMMACS[$WLAPNMNR]};<MAC ${WLAPSNMIDS[$WLAPNMNR]-address}>;I;"
+ MACMASKSED+=" /${WLAPSNMIP6S[$WLAPNMNR]}/ s;${WLAPSNMIP6S[$WLAPNMNR]/#\\(::/\(};<IP6 ${WLAPSNMIDS[$WLAPNMNR]-from MAC}>;I;"
done
-sed "$MACMASKSED/\([[:alnum:]]\{2\}:\)\{6,\}/! s/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/<MAC address>/" <<< "$RESULTS" > "$OUTPUTDIR/$FILEBASE.txt"
+sed "$MACMASKSED /\([[:alnum:]]\{2\}:\)\{6,\}/! s/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/<MAC address>/" <<< "$RESULTS" > "$OUTPUTDIR/$FILEBASE.txt"
##### The End #####