├── README.md
├── helpers
└── country-code-check
└── wireless-info
/README.md:
--------------------------------------------------------------------------------
1 | # Wireless Info
2 |
3 | This script gathers the infos necessary for troubleshooting a wireless connection
4 | and saves them in a text file, wrapping it in an archive if it exceeds the 19.5 kB
5 | size limit for `.txt` attachments on the Ubuntu Forums.
6 |
7 | ## Details
8 |
9 | - Creates the file `wireless-info.txt` at the location it is run from.
10 | - Additionally creates the archive `wireless-info.tar.gz` if the file exceeds 19.5 kB in size.
11 | - Masks all sensitive info, like MAC addresses and WPA/WEP keys, automatically in a meaningful way.
12 | - Offers to post the results to your default `pastebinit` provider if the program is installed,
13 | and a sufficiently reliable internet connection is available.
14 |
15 | ## Run from CLI
16 |
17 | You can either run it from the command line with these commands:
18 |
19 | wget -N -t 5 -T 10 https://github.com/UbuntuForums/wireless-info/raw/master/wireless-info && \
20 | chmod +x wireless-info && \
21 | ./wireless-info
22 |
23 | This will download the script, make it executable, and run it, all in a row.
24 |
25 | ## Run from GUI
26 |
27 | Or, if `zenity` or `kdialog` is installed, run it from the GUI this way:
28 |
29 | 1. [Download][1] the script
30 | 2. Make it executable
31 | 3. Run it from your file browser or a Run dialog
32 |
33 | [1]: https://github.com/UbuntuForums/wireless-info/raw/master/wireless-info
34 |
35 | ## Disconnected
36 |
37 | If you cannot connect to the internet with the affected system, including via a wired connection,
38 | you will have to move files between it and a system connected to the internet.
39 |
--------------------------------------------------------------------------------
/helpers/country-code-check:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright (c) 2017
4 | #
5 | # Author: Hadaka, Krytarik
6 | #
7 | # This script parses the output of the wireless info script
8 | # and suggests changes if the country code is either unset or
9 | # does not match the location indicated by the set time zone.
10 | #
11 | #######################################################################
12 | #
13 | # This program is free software: you can redistribute it and/or modify
14 | # it under the terms of the GNU General Public License as published by
15 | # the Free Software Foundation, either version 3 of the License, or
16 | # (at your option) any later version.
17 | #
18 | # This program is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | # GNU General Public License for more details.
22 | #
23 | # You should have received a copy of the GNU General Public License
24 | # along with this program. If not, see .
25 | #
26 |
27 | read -rd '' tz ccc < <(
28 | if [ -f wireless-info.txt ]; then
29 | cat wireless-info.txt
30 | elif [ -f wireless-info.tar.gz ]; then
31 | tar -xzOf wireless-info.tar.gz
32 | fi | sed -n '/^##### iw reg get #####/,/^##### / {
33 | s/^\(Region:\|country\) \([^ :]\+\).*$/\2/p
34 | }')
35 |
36 | ORIGIFS="$IFS"
37 | IFS=$'\t'
38 | zi=($(grep "$tz" /usr/share/zoneinfo/zone.tab))
39 | IFS="$ORIGIFS"
40 | cc="${zi[0]}"
41 |
42 | if [ "$ccc" = "00" ]; then
43 | setword="currently \e[1;31munset\e[0m"
44 | cmdprt="yes"
45 | elif [ "$ccc" != "$cc" ]; then
46 | setword="currently set to '\e[1;31m$ccc\e[0m'"
47 | cmdprt="yes"
48 | else
49 | setword="set \e[1;32mcorrectly\e[0m"
50 | fi
51 |
52 | printf "\n\e[1;34m%s\e[0m" "$cc"
53 | printf "\t%s" "${zi[@]:1}"
54 | printf "\n\nCountry code is %b.\n\n" "$setword"
55 |
56 | if [ "$cmdprt" = "yes" ]; then
57 | printf \
58 | "To set it correctly:\n
59 | sudo iw reg set %s
60 | sudo sed -i '"'s/^\\(REGDOMAIN\\)=.*$/\\1=%s/'"' /etc/default/crda\n
61 | " "$cc" "$cc"
62 | fi
63 |
--------------------------------------------------------------------------------
/wireless-info:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Copyright (c) 2012
4 | #
5 | # Authors: Wild Man, Krytarik
6 | # Helpers: chili555
7 | #
8 | # This script gathers the infos necessary for troubleshooting a wireless
9 | # connection and saves them in a text file, wrapping it in an archive if it
10 | # exceeds the 19.5 kB size limit for ".txt" attachments on the Ubuntu Forums.
11 | #
12 | ##############################################################################
13 | #
14 | # This program is free software: you can redistribute it and/or modify
15 | # it under the terms of the GNU General Public License as published by
16 | # the Free Software Foundation, either version 3 of the License, or
17 | # (at your option) any later version.
18 | #
19 | # This program is distributed in the hope that it will be useful,
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 | # GNU General Public License for more details.
23 | #
24 | # You should have received a copy of the GNU General Public License
25 | # along with this program. If not, see .
26 | #
27 |
28 | SCRIPTDATE="2024-8-27 3:55 -0700"
29 | FILEBASE="wireless-info"
30 | OUTPUTDIR="$PWD"
31 | OUTPUTDIRFB="/tmp"
32 |
33 | MODMATCHES="(air|ar5|at7|ath[^3]?|b43|bcma|brcm|carl|ipw|iwl|ndis|r(818|8192[eu]|871|92su)|8(188|189|192|723|812)[acde][esu]|rt[23567]|rtl|ssb|wl|rtw8|(cfg|mac)80211)"
34 | LSMODMATCHES="(wmi|(dell|ideapad)[-_]laptop)"
35 | IFACEMATCHES="(wlan[0-9]|eth[0-9])"
36 | DMESGMATCHES="(firmware|[nN]etwork|sdio|SDIO)"
37 | NMPROFMATCHES="\(\[connection\]\|id=\|type=\|permissions=\|autoconnect=\|\[802-11-wireless\]\|\[wifi\]\|ssid=\|bssid=\|mac-address\(-blacklist\)\?=\|mtu=\|\[802-1x\]\|[[:graph:]]*ca-certs\?=\|\[ipv[46]\]\|method=\)"
38 |
39 | DMESGEXCL="apparmor|(cfg|mac)80211"
40 | MODINFOINCL="filename|license|description|depends|retpoline|intree|name|vermagic|parm"
41 | MODPROBEXCL="(alsa-base|blacklist-(firewire|framebuffer|modem|oss|watchdog)|fglrx|nvidia|fbdev|bumblebee)"
42 | PMUTILSEXCL="/etc/pm/(power.d/(95hdparm-apm|intel-audio-powersave|sata_alpm)|sleep.d/(10_grub-common|10_unattended-upgrades.*|novatel_3g.*))"
43 |
44 | NETMGRNAMES=("NetworkManager" "Wicd" "ConnMan")
45 | NETMGRPATHS=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand")
46 | DEC2BI=({0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1})
47 | DEC2HEX=($(printf "%02x " {0..255}))
48 |
49 | export LANG="en_US.UTF-8"
50 | export LANGUAGE="en_US:en"
51 | export LC_ALL="en_US.UTF-8"
52 |
53 | if [ -t 0 ]; then
54 | DIALOGAPP="terminal"
55 | DIALOGBREAK=" "
56 | TERMOUT="yes"
57 | elif [ -x /usr/bin/zenity ]; then
58 | DIALOGAPP="zenity"
59 | DIALOGBREAK="\n"
60 | elif [ -x /usr/bin/kdialog ]; then
61 | DIALOGAPP="kdialog"
62 | DIALOGBREAK="\n"
63 | else
64 | exit 1
65 | fi
66 |
67 | if [ -t 0 ]; then
68 | SUDO="sudo"
69 | elif [ -x /usr/bin/pkexec ]; then
70 | SUDO="pkexec"
71 | elif [ -x /usr/bin/gksudo ]; then
72 | SUDO="gksudo"
73 | GKSUDO="yes"
74 | elif [ -x /usr/bin/kdesudo ]; then
75 | SUDO="kdesudo"
76 | KDESUDO="yes"
77 | KDESUDOCMT=" needs administrative privileges. Please enter your password."
78 | fi
79 |
80 | dialog_info () {
81 | case $DIALOGAPP in
82 | terminal)
83 | printf "%b\n" "$1"
84 | ;;
85 | zenity)
86 | zenity --info --text="$1"
87 | ;;
88 | kdialog)
89 | kdialog --msgbox "$1"
90 | ;;
91 | esac
92 | }
93 |
94 | dialog_error () {
95 | case $DIALOGAPP in
96 | terminal)
97 | printf "%b\n" "$1" >&2
98 | ;;
99 | zenity)
100 | zenity --error --text="$1"
101 | ;;
102 | kdialog)
103 | kdialog --error "$1"
104 | ;;
105 | esac
106 | }
107 |
108 | dialog_question () {
109 | case $DIALOGAPP in
110 | terminal)
111 | local INPUT
112 | read -r -p "$1 [Y/n]: " INPUT
113 | echo "${INPUT,,}"
114 | ;;
115 | zenity)
116 | zenity --question --text="$1" || echo "no"
117 | ;;
118 | kdialog)
119 | kdialog --yesno "$1" || echo "no"
120 | ;;
121 | esac
122 | }
123 |
124 | ip6-mac () {
125 | for MAC in "$@"; do
126 | OCT1BI=${DEC2BI[0x${MAC:0:2}]}
127 | OCT1BI7=$((${OCT1BI:6:1} - 1))
128 | OCT1BIM="${OCT1BI:0:6}${OCT1BI7#-}${OCT1BI:7}"
129 | IP6S+=${IP6S:+$'\n'}"${DEC2HEX[2#$OCT1BIM]}${MAC:3:2}:${MAC:6:2}ff:fe${MAC:9:2}:${MAC:12:2}${MAC:15:2}"
130 | done
131 | sed 's/\(^\|:\)0\+\([[:alnum:]]\)/\1\2/g;s/^\([0:]\+\)/\\(::\\|\1\\)/' <<< "$IP6S"
132 | }
133 |
134 | exec 3>&1 4>&2
135 | exec 1> "$OUTPUTDIR/$FILEBASE.txt" || {
136 | dialog_error "${TERMOUT+\n}Cannot write output file in \"$OUTPUTDIR\",${DIALOGBREAK}trying in \"$OUTPUTDIRFB\" instead.${TERMOUT+\n}"
137 | OUTPUTDIR="$OUTPUTDIRFB"
138 | exec 1> "$OUTPUTDIR/$FILEBASE.txt" || {
139 | dialog_error "${TERMOUT+\n}Cannot write output file in \"$OUTPUTDIR\" either, aborting.${TERMOUT+\n}"
140 | exit 1
141 | }
142 | }
143 | exec 2>&1
144 |
145 | printf "\n########## wireless info START ##########\n\n"
146 | REPORTDATE=$(date +"%d %b %Y %H:%M %Z %z")
147 | SCRIPTDATE=$(date -u -d "$SCRIPTDATE" +"%d %b %Y %H:%M %Z %z")
148 | LASTBOOTDT=$(last -FRn 1 reboot | sed -n 's/.*system boot[ ]\+\(.\+\) - .*/\1/p')
149 | LASTBOOTDT=$(date -d "$LASTBOOTDT" +"%d %b %Y %H:%M %Z %z")
150 | printf "Report from: %s\n\n" "$REPORTDATE"
151 | printf "Booted last: %s\n\n" "$LASTBOOTDT"
152 | printf "Script from: %s\n" "$SCRIPTDATE"
153 |
154 | printf "\n##### release ###########################\n\n"
155 | lsb_release -idrc
156 |
157 | printf "\n##### kernel ############################\n\n"
158 | uname -srvmpio
159 | echo
160 | sed 's/root=[^ ]*//;s/[ ]\+/, /g;s/^BOOT_IMAGE=[^ ]*/Parameters:/' /proc/cmdline
161 |
162 | printf "\n##### desktop ###########################\n\n"
163 | if [ -n "$DESKTOP_SESSION" ]; then
164 | DESKTOP="$DESKTOP_SESSION"
165 | else
166 | DESKTOP=$(sed -n 's/^Session=\(.\+\)$/\1/p' "$HOME/.dmrc")
167 | DESKDMRC=" (from ~/.dmrc)"
168 | fi
169 | if [ -n "$DESKTOP" ]; then
170 | if [ -f "/usr/share/xsessions/$DESKTOP.desktop" ]; then
171 | DESKTOP=$(sed -n 's/^Name=\(.\+\)$/\1/p' "/usr/share/xsessions/$DESKTOP.desktop")
172 | fi
173 | echo "${DESKTOP/ Session/}${DESKDMRC}"
174 | else
175 | printf "\nCould not be determined.\n"
176 | fi
177 |
178 | printf "\n##### lspci #############################\n\n"
179 | lspci -nnk | grep -iA 3 '^[^[:space:]].*net' | sed '/^--$/d; /^[^[:space:]]/ i\\'
180 |
181 | printf "\n##### lsusb #############################\n\n"
182 | lsusb
183 |
184 | printf "\n##### PCMCIA card info ##################\n\n"
185 | if [ -x /sbin/pccardctl ]; then
186 | pccardctl info
187 | else
188 | echo "'pccardctl' is not installed (package \"pcmciautils\")."
189 | fi
190 |
191 | printf "\n##### rfkill ############################\n\n"
192 | rfkill list all
193 |
194 | printf "\n##### secure boot #######################\n\n"
195 | if [ -x /usr/bin/mokutil ]; then
196 | mokutil --sb
197 | else
198 | echo "'mokutil' is not installed (package \"mokutil\")."
199 | fi
200 |
201 | printf "\n##### lsmod #############################\n\n"
202 | LSMOD=$(lsmod | egrep "(^|[[:punct:] ])($MODMATCHES|$LSMODMATCHES)[^[:punct:] ]*([[:punct:] ]|$)")
203 | echo "$LSMOD"
204 |
205 | printf "\n##### dkms #############################\n\n"
206 | dkms status
207 |
208 | printf "\n##### interfaces ########################\n\n"
209 | for IFACESFILE in $(find /etc/network/interfaces{,.d} -type f 2> /dev/null | sort); do
210 | IFACESFLCNT=$(sed '/^#/d;s/^wpa-psk [[:graph:]]\+/wpa-psk /' $IFACESFILE)
211 | if [ -n "$IFACESFLCNT" ]; then
212 | printf "[%s]\n%s\n\n" "$IFACESFILE" "$IFACESFLCNT"
213 | fi
214 | done
215 |
216 | printf "\n##### ifconfig ##########################\n\n"
217 | if [ -x /bin/ip ]; then
218 | IFCONFIG=$(ip address show)
219 | elif [ -x /sbin/ifconfig ]; then
220 | IFCONFIG=$(ifconfig -a)
221 | else
222 | echo "'ip' is not installed (package \"iproute2\")."
223 | fi
224 | echo "$IFCONFIG"
225 | IFCONFIG=$(sed -n '1h; 1!H; ${g;s/\n /\\ /g;p}' <<< "$IFCONFIG")
226 | IFACESETH=($(sed -n 's#^[0-9]\+: \([^ :]\+\):.* link/ether.*#\1#p; s/^\([^ :]\+\):\?.* \(Link encap:Ethernet\|ether\).*/\1/p' <<< "$IFCONFIG"))
227 | if (( ${#IFACESETH[@]} > 0 )); then
228 | IFETHMATCHES=${IFACESETH[@]}
229 | IFACEMATCHES="($IFACEMATCHES|(${IFETHMATCHES// /|}))"
230 | fi
231 |
232 | printf "\n##### iwconfig ##########################\n\n"
233 | iwconfig
234 |
235 | printf "\n##### route #############################\n\n"
236 | if [ -x /bin/ip ]; then
237 | ip route show
238 | elif [ -x /sbin/route ]; then
239 | route -n
240 | else
241 | echo "'ip' is not installed (package \"iproute2\")."
242 | fi
243 |
244 | printf "\n##### resolv.conf #######################\n\n"
245 | stat -c "[%a %U %N]" /etc/resolv.conf
246 | grep -v '^#' /etc/resolv.conf
247 |
248 | printf "\n##### network managers ##################\n\n"
249 | printf "Installed:\n\n"
250 | for NETMGRNR in "${!NETMGRPATHS[@]}"; do
251 | if [ -f "${NETMGRPATHS[$NETMGRNR]}" ]; then
252 | NETMGRINST+=("${NETMGRNAMES[$NETMGRNR]}")
253 | fi
254 | done
255 | printf "\t%s\n" "${NETMGRINST[@]:-None found.}"
256 | NETMGRMATCHES=${NETMGRPATHS[@]/#*\//|}
257 | NETMGRMATCHES=${NETMGRMATCHES// |/|}
258 | NETMGRMATCHES="(${NETMGRMATCHES#|})"
259 | printf "\nRunning:\n\n"
260 | ps -ef | egrep "( |/)$NETMGRMATCHES($| )" || printf "\tNone found.\n"
261 |
262 | printf "\n##### NetworkManager info ###############\n\n"
263 | if [ -x /usr/bin/nm-tool ]; then
264 | nm-tool
265 | elif [ -x /usr/bin/nmcli ]; then
266 | nmcli -f all device show | sed '/^GENERAL.DEVICE:[ ]\+lo$/,/^$/d; /^AP\[[0-9]\+\]\./d'
267 | echo
268 | nmcli -f SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,BARS,SECURITY,ACTIVE,IN-USE device wifi list
269 | else
270 | echo "NetworkManager is not installed (package \"network-manager\")."
271 | fi
272 |
273 | printf "\n##### NetworkManager.state ##############\n\n"
274 | "$SUDO" cat -s /var/lib/NetworkManager/NetworkManager.state
275 |
276 | printf "\n##### NetworkManager config #############\n\n"
277 | for NMCONFFILE in $(find /{etc,usr/lib}/NetworkManager/{NetworkManager.conf,conf.d} -name "*.conf" 2> /dev/null | sort); do
278 | NMCONFCNT=$(egrep -v '^(#|$)' $NMCONFFILE)
279 | if [ -n "$NMCONFCNT" ]; then
280 | printf "[[%s]]\n%s\n\n" "$NMCONFFILE" "$NMCONFCNT"
281 | fi
282 | done
283 |
284 | printf "\n##### NetworkManager profiles ###########\n\n"
285 | if [ -d /etc/NetworkManager/system-connections ]; then
286 | if [ -n "$SUDO" ]; then
287 | trap "" 2 3
288 | NMPROFILES=$(find /etc/NetworkManager/system-connections -maxdepth 1 -type f -exec $SUDO${GKSUDO+ -D grep --}${KDESUDO+ -d --comment "grep$KDESUDOCMT" --} grep -vH '^$' {} +) && SUDOSUCCESS="yes" || SUDOSUCCESS="no"
289 | trap 2 3
290 | if [ "$SUDOSUCCESS" = "yes" ]; then
291 | ORIGIFS="$IFS"
292 | IFS=$'\n'
293 | for NMWLPRFFILE in $(sed -n 's/^\(.\+\):type=\(802-11-wireless\|wifi\).*$/\1/p' <<< "$NMPROFILES"); do
294 | NMWLPRFFLPERMS=$(stat -c "%a %U" "$NMWLPRFFILE")
295 | NMWLPROFILE=($(sed -n "s;^$NMWLPRFFILE:\($NMPROFMATCHES.*\)$;\1 |;p" <<< "$NMPROFILES"))
296 | NMWLPROFSOUT+="[[$NMWLPRFFILE]] ($NMWLPRFFLPERMS)"$'\n'"${NMWLPROFILE[@]}"$'\n\n'
297 | done
298 | IFS="$ORIGIFS"
299 | sed 's# | \[#\n\[#g;s#\] |#\]#g;s/ |$//' <<< "$NMWLPROFSOUT" | sed '/^\[[^]]*\]$/d'
300 | else
301 | printf "\nAcquisition of admin privileges failed.\n"
302 | fi
303 | else
304 | echo "No way to acquire admin privileges found."
305 | fi
306 | else
307 | echo "No NetworkManager profiles found."
308 | fi
309 |
310 | printf "\n##### Netplan config ####################\n\n"
311 | for NPLANFILE in $(find /{lib,etc,run}/netplan -name "*.yaml" 2> /dev/null | sort); do
312 | NPLANFLCNT=$(egrep -v '^(#|$)' $NPLANFILE)
313 | if [ -n "$NPLANFLCNT" ]; then
314 | printf "[%s]\n%s\n\n" "$NPLANFILE" "$NPLANFLCNT"| egrep -v "password|mac|MAC"
315 | fi
316 | done
317 |
318 | printf "\n##### iw reg get ########################\n\n"
319 | if [ -x /sbin/iw ]; then
320 | if IWREGGET=$(iw reg get 2>&1) && [ -f /etc/timezone ]; then
321 | REGION=$(cat /etc/timezone)
322 | printf "Region: %s (based on set time zone)\n\n" "$REGION"
323 | fi
324 | echo "$IWREGGET"
325 | else
326 | echo "'iw' is not installed (package \"iw\")."
327 | fi
328 |
329 | printf "\n##### iwlist channels ###################\n\n"
330 | if [ -x /sbin/iwlist ]; then
331 | iwlist chan
332 | else
333 | echo "'iwlist' is not installed (package \"wireless-tools\")."
334 | fi
335 |
336 | printf "\n##### iwlist scan #######################\n\n"
337 | if [ -x /sbin/iwlist ]; then
338 | if [ -n "$SUDO" ]; then
339 | trap "" 2 3
340 | IWLISTSCAN=$($SUDO${KDESUDO+ -d} iwlist scan) && SUDOSUCCESS="yes" || SUDOSUCCESS="no"
341 | trap 2 3
342 | if [ "$SUDOSUCCESS" = "yes" ]; then
343 | if [[ $IWLISTSCAN = *Frequency:* ]]; then
344 | printf "Channel occupancy:\n\n"
345 | grep '^[ ]*Frequency:' <<< "$IWLISTSCAN" | sort | uniq -c | sed 's/^[ ]\+\([ ][0-9]\+\)[ ]\+/ \1 APs on /'
346 | echo
347 | fi
348 | grep -v '^[ ]*IE: Unknown:' <<< "$IWLISTSCAN"
349 | else
350 | printf "\nAcquisition of admin privileges failed.\n"
351 | fi
352 | else
353 | echo "No way to acquire admin privileges found."
354 | fi
355 | else
356 | echo "'iwlist' is not installed (package \"wireless-tools\")."
357 | fi
358 |
359 | printf "\n##### module infos ######################\n\n"
360 | MODULES=$(egrep -o "^$MODMATCHES[^ ]*" <<< "$LSMOD")
361 | for MODULE in $MODULES; do
362 | MODINFO=$(modinfo $MODULE | egrep -i "^$MODINFOINCL:")
363 | printf "[%s]\n%s\n\n" "$MODULE" "$MODINFO"
364 | done
365 |
366 | printf "\n##### module parameters #################\n\n"
367 | for MODULE in $MODULES; do
368 | if [ -d /sys/module/$MODULE/parameters ]; then
369 | MODPARAMS=$(grep -H '^[[:graph:]]' /sys/module/$MODULE/parameters/* | sed 's#^.*/##;s/:/: /')
370 | printf "[%s]\n%s\n\n" "$MODULE" "$MODPARAMS"
371 | fi
372 | done
373 |
374 | printf "\n##### /etc/modules ######################\n\n"
375 | grep -v '^#' /etc/modules
376 |
377 | printf "\n##### modprobe options ##################\n\n"
378 | for MODPROBEFILE in $(find /etc/modprobe.{conf,d} -name "*.conf" -regextype posix-egrep -not -regex ".*$MODPROBEXCL.*" 2> /dev/null | sort); do
379 | MODPROBEOPTS=$(egrep -v '^(#|$)' $MODPROBEFILE)
380 | if [ -n "$MODPROBEOPTS" ]; then
381 | printf "[%s]\n%s\n\n" "$MODPROBEFILE" "$MODPROBEOPTS"
382 | fi
383 | done
384 |
385 | printf "\n##### rc.local ##########################\n\n"
386 | grep -v '^#' /etc/rc.local
387 |
388 | printf "\n##### pm-utils ##########################\n\n"
389 | for PMUTILSFILE in $(find /etc/pm/*.d \( -type f -o -type l \) -regextype posix-egrep -not -regex "$PMUTILSEXCL" | sort); do
390 | PMUTFLCONT=$(egrep -v '^(#|$)' $PMUTILSFILE)
391 | if [ -n "$PMUTFLCONT" ]; then
392 | PMUTFLPERMS=$(stat -c "%a %U" $PMUTILSFILE)
393 | printf "[%s] (%s)\n%s\n\n" "$PMUTILSFILE" "$PMUTFLPERMS" "$PMUTFLCONT"
394 | fi
395 | done
396 |
397 | printf "\n##### udev rules ########################\n\n"
398 | for UDEVRLFILE in $(find /etc/udev/rules.d -name "*net*.rules" | sort); do
399 | UDEVRULES=$(grep -B1 '^[^#]' $UDEVRLFILE | egrep -v '^(--)?$')
400 | if [ -n "$UDEVRULES" ]; then
401 | printf "[%s]\n%s\n\n" "$UDEVRLFILE" "$UDEVRULES"
402 | fi
403 | done
404 |
405 | printf "\n##### dmesg #############################\n\n"
406 | "$SUDO" dmesg | tail -n 100 | egrep "[[:punct:] ]($MODMATCHES|$IFACEMATCHES|$DMESGMATCHES)[^[:punct:] ]*[[:punct:] ]" | egrep -v "$DMESGEXCL" | uniq -cf 2 | sed 's/^[ ]\+1[ ]\+//;s/^[ ]\+\([0-9]\+\)[ ]\+\(.\+\)$/\2 (repeated \1 times)/'
407 |
408 | printf "\n########## wireless info END ############\n\n"
409 |
410 | exec 2>&4 4>&-
411 | exec 1>&3 3>&-
412 |
413 | ##### MAC address masking #####
414 |
415 | RESULTS=$(cat -s "$OUTPUTDIR/$FILEBASE.txt")$'\n'
416 |
417 | ORIGIFS="$IFS"
418 | IFS=$'\n'
419 |
420 | IFACESIDS=($(sed -n "/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}/ {/\(00:\)\{5\}00/! {s/^[0-9]\+: \([^ :]\+\):.*/'\1'/p; s/^\([^ :]\+\):\? .*/'\1'/p}}" <<< "$IFCONFIG"))
421 | IFACESMACS=($(sed -n '/\(00:\)\{5\}00/! s#.*\(HWaddr\|link/[^ ]\+\|ether\) \(\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}\).*#\2#p' <<< "$IFCONFIG"))
422 | IFACESIP6S=($(ip6-mac "${IFACESMACS[@]}"))
423 |
424 | WLAPSIWLIDS=($(sed -n "/^[ ]*Cell [0-9]\+/,/^[ ]*ESSID:/ {/^[ ]*Cell [0-9]\+/h; /^[ ]*ESSID:/ {H;g;s/^[ ]*Cell 0\?\([0-9]\+\).*ESSID:\"\(.*\)\"$/'\2' [AC\1]/p}}" <<< "$IWLISTSCAN"))
425 | WLAPSIWLMACS=($(sed -n 's/^[ ]*Cell [0-9]\+.*Address: \([^ ]\+\)/\1/p' <<< "$IWLISTSCAN"))
426 | WLAPSIWLIP6S=($(ip6-mac "${WLAPSIWLMACS[@]}"))
427 |
428 | 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")
429 | WLAPSNMIDS=($(awk -F '\t' '{print "'\''" $1 "'\''"}' <<< "$WLAPSNMRAW"))
430 | WLAPSNMMACS=($(grep -o '\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}' <<< "$WLAPSNMRAW"))
431 | WLAPSNMIP6S=($(ip6-mac "${WLAPSNMMACS[@]}"))
432 |
433 | IFS="$ORIGIFS"
434 |
435 | for IFACENR in "${!IFACESMACS[@]}"; do
436 | MACMASKSED+="s;${IFACESMACS[$IFACENR]};;I;"
437 | MACMASKSED+=" /${IFACESIP6S[$IFACENR]}/ s;${IFACESIP6S[$IFACENR]/#\\(::/\(};;I;"
438 | IFACEMACC=${IFACESMACS[$IFACENR]//:/}
439 | if [[ ${IFACESIDS[$IFACENR],,} =~ ${IFACEMACC,,} ]]; then
440 | MACMASKSED+="s;\(${IFACESIDS[$IFACENR]:1:3}\)$IFACEMACC;\1;Ig;"
441 | fi
442 | done
443 |
444 | for WLAPIWLNR in "${!WLAPSIWLMACS[@]}"; do
445 | MACMASKSED+="s;${WLAPSIWLMACS[$WLAPIWLNR]};;I;"
446 | MACMASKSED+=" /${WLAPSIWLIP6S[$WLAPIWLNR]}/ s;${WLAPSIWLIP6S[$WLAPIWLNR]/#\\(::/\(};;I;"
447 | done
448 |
449 | for WLAPNMNR in "${!WLAPSNMMACS[@]}"; do
450 | MACMASKSED+="s;${WLAPSNMMACS[$WLAPNMNR]};;I;"
451 | MACMASKSED+=" /${WLAPSNMIP6S[$WLAPNMNR]}/ s;${WLAPSNMIP6S[$WLAPNMNR]/#\\(::/\(};;I;"
452 | done
453 |
454 | sed "$MACMASKSED /\([[:alnum:]]\{2\}:\)\{6,\}/! s/\([[:alnum:]]\{2\}:\)\{5\}[[:alnum:]]\{2\}//g" <<< "$RESULTS" > "$OUTPUTDIR/$FILEBASE.txt"
455 |
456 | ##### The End #####
457 |
458 | dialog_info "${TERMOUT+\n}Results saved in \"$OUTPUTDIR/$FILEBASE.txt\".${TERMOUT+\n}"
459 |
460 | if (( $(stat -c %s "$OUTPUTDIR/$FILEBASE.txt") > 19968 )); then
461 | tar -czf "$OUTPUTDIR/$FILEBASE.tar.gz" -C "$OUTPUTDIR" "$FILEBASE.txt" && \
462 | dialog_info "Results also archived in \"$OUTPUTDIR/$FILEBASE.tar.gz\",${DIALOGBREAK}as they exceed the 19.5 kB size limit for \".txt\" attachments${DIALOGBREAK}on the Ubuntu Forums.${TERMOUT+\n}" || \
463 | dialog_error "Results exceed the 19.5 kB size limit for \".txt\" attachments${DIALOGBREAK}on the Ubuntu Forums, but archive could not be created.${TERMOUT+\n}"
464 | fi
465 |
466 | if [ -x /usr/bin/pastebinit ]; then
467 | PASTEBIN=$(dialog_question "Do you also want to post them${DIALOGBREAK}to your default 'pastebinit' provider?")
468 | if [[ ! $PASTEBIN =~ ^no?$ ]]; then
469 | PASTERESULT=$(pastebinit -i "$OUTPUTDIR/$FILEBASE.txt" -f text 2>&1) && PASTESUCCESS="yes"
470 | if [ "$PASTESUCCESS" = "yes" ]; then
471 | dialog_info "${TERMOUT+\n}Pastebin successful:\n\n${PASTERESULT}${TERMOUT+\n}"
472 | else
473 | if [ -n "$PASTERESULT" ]; then
474 | dialog_error "${TERMOUT+\n}Pastebin failed, error message is:\n\n${PASTERESULT}${TERMOUT+\n}"
475 | else
476 | dialog_error "${TERMOUT+\n}Pastebin failed, no error message given.${TERMOUT+\n}"
477 | fi
478 | fi
479 | else
480 | echo
481 | fi
482 | fi
483 |
--------------------------------------------------------------------------------