Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Find default passwords for certain network devices' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Find default passwords for certain network devices
Authored by: gubluntu on Jun 01, '07 06:35:04AM
Script Heavily Improved with lots'o'comment goodness for the eager newbie

#!/bin/sh
#
# This is a script to retrieve default passwords for network devices
# Original script by: gubluntu
# Modifications by: jeo

# First we want to make sure the user has supplied an argument
# If not, we tell them what the script expects with a "usage"
# line and exit

if [ $# == 0 ]; then
  echo "usage: $(basename $0) <mfg.> or <model#>"
  echo "Lists possible default passwords for network devices"
  exit 0
fi


# Here we'll set the URL.  I assume at this point that if the
# URL changes, the entire script will have to change, but still...

URL="http://www.phenoelit.de/dpl/dpl.html"


# Now let's grab the list from our URL, convert it into a
# comma seperated list, grab only lines containing commas (to
# get rid of any irrelevant info), and store it in memory
# in the form of a variable.  We'll call it "DATA".

DATA="$(curl -s $URL|sed s/"<\/TD>"/","/g | sed s/"<TD>"/""/g |grep ",")"

# From our comma seperated list, let's extract the
# column headers and store them in a variable

HEADER="$(echo "$DATA"| head -n1)"


# And now let's grab the lines that we're looking for

RESULT="$(echo "$DATA"| grep -i $1)"


# We can also say something useful if we don't find
# what we're looking for

if [ -z "$RESULT" ]; then
  echo "Sorry, couldn't find anything for \"$1\""
  exit
else

# Still part of our "if"
# And last but not least, we pipe our processed list
# (including headers) through "column" to get a pretty
# print-out.  Problem here is if your terminal isn't wide
# enough, some word-wrapping happens...  Perhaps we could
# pipe this to a text viewer that doesn't do wraping?

  echo -e "$HEADER"\\n"$RESULT" | column -ntx -s","

fi

exit 0 


[ Reply to This | # ]