Last active
April 11, 2022 10:03
-
-
Save filippolauria/1ea3717ce68bcd31eafe3fc747e18239 to your computer and use it in GitHub Desktop.
A simple bash one-liner that, relying on nmap and snmpget, scans for available printers on a given network. The results are sent to standard output and saved in the /tmp directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N="192.168.1.0/24" && \ | |
H=$(sudo nmap -sS -sU -T5 -PE -pU:524,631,8611-8614,T:515,524,631,8611-8614,9100 -oG - --open -n $N | grep "/open" | cut -d' ' -f2 | tr '\n' ' ') && \ | |
for p in $(sudo nmap -Pn -T5 -sU -p 161 -oG - --open -n $H | grep "/open" | cut -d' ' -f2); do \ | |
S=$((snmpget -v1 -Ov -cpublic -t0.5 $p .1.3.6.1.2.1.1.1.0 | sed 's/^STRING:\s\+//') 2> /dev/null); \ | |
if [ "$S" ]; then echo -e "$p\t: $S"; fi; \ | |
done | tee /tmp/`date '+%Y-%m-%d'`-printers.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment