Results 1 to 2 of 2

Thread: PacketStorm Security Exploit Archive Snatcher

  1. #1
    Just burned his ISO
    Join Date
    Jan 2010
    Posts
    3

    Default PacketStorm Security Exploit Archive Snatcher

    The following script was developed because our testers were getting a bit tired of continually going back to Packet Storm Security to download the monthly archives of exploits.

    We felt that it may be of use to someone who wants to keep they're own packet storm security exploit archive tree up to date.


    Code:
    ################################################
    #!/bin/sh
    
    ################################################
    # Packet Storm Security Exploit Archive Retriever  
    #
    # pss-exploit-update.sh v.1.0
    #
    # www proteus-ocm net | Answering the "So What if we get hacked?" 
    #
    # info [at] proteus-ocm [dot] net   
    #
    # Updates welcome
    ################################################
    
    ################################################
    # This script was written to automatically retrieve exploit archives 
    # from the Packet Storm Security Website.  This script is for use by   
    # Penetration Testers who desire to keep their archive of exploits   
    # available from Packet Storm Security up to date and current.       
    #                                                                    
    # While it is true that if you are conducting penetration tests you  
    # more than likely will have access to the Internet (and as a result 
    # access to Packet Storm Security), I have found it handy to have  
    # offline access to the exploits which have been made available.     
    #                                                                    
    # While this started out as a simple script, being that I was sure   
    # that someone else out there may find this useful, 
    # I added in some  additional functionality to the script that allows some 
    # ease of  management and use.                                                
    ################################################
    
    #
    # PacketStorm Security Website (Where the exploit archives live)
    #
    HOST=66.227.17.19
    
    # Because Packet Storm Security only archives after the end of
    # each month, we're actually getting the last archive of exploits
    # that are available.
     i=`date '+%y%m' --date '1 month ago'`
    
    # set the path to the exploit archives for the target month.
    ii=/$i
    p=-exploits/
    f=-exploits.tgz
    
    echo "Thank you for using pss-exploit-update.sh, a tool for penetration"
    echo "testers to keep up to date on Packet Storm Security Exploit Archives."
     
    echo 
    echo "This tool is designed to help penetration testers manage Packet Storm"
    echo "Security Exploit Archives"
    echo "from www packetstormsecurity com."
    echo
    echo "Brought to you by PROTEUS|OCM."
    echo 
    
    # Setup the logging environment
    slog=/var/log/pss-setup.log
    if test ! -e $slog
      then 
          touch $slog
          chmod +w $slog
           echo "pss-setup logfile does not exist. Creating it now." | tee -a $slog
          sleep 2
    fi
    
    log=/var/log/pss.log
    if test ! -e $log
     then
         echo "Logfile does not currently exist.  Creating it now." | tee -a $slog
         echo "The log file is located at $log."  | tee -a $slog
         touch $log
         chmod +w $log
         sleep 2
    fi
    
    
    # Set the destination location for PacketStormSecurity Exploit Archives.
    # Set the path to where you want your exploits to be stored on your local system.
    # If you're running the application blind, user will be prompted to create the
    # default destination director /PSS/exploits.
    
     DEST0=/PSS/exploits/
    DEST1=/PSS/archives/
    
    if test ! -d $DEST0
      then
            echo "PacketStormSecurity exploit destination directory does not exist." | tee -a $slog
            echo 
            echo "Do you wish to create $DEST0 now? <Y or N>" | tee -a $slog
            read CDEST0 
            if [ $CDEST0 = "N" ];
               then
                    echo "PacketStormSecurity exploit directory not created at this time." | tee -a $slog
                    echo "Please create the desired directory and start pss-exploits-update.sh again."  | tee -a $slog
                    echo ""
                    echo "Good bye." | tee -a $slog
                    exit
            fi
            if [ $CDEST0 = "Y" ]; 
               then
                    echo "Creating PacketStormSecurity exploit directory now." | tee -a $slog
                    mkdir -p $DEST0  | tee -a $slog
                    echo "Directory $DEST0 created." | tee -a $slog
                    sleep 2
            fi
    fi
    echo  $CDEST0 >> $slog
    if test ! -d $DEST1
      then
            echo "PacketStormSecurity Exploit Archives do not exist."  | tee -a $slog
            echo "If you want to keep all downloaded archives in their packed format you should" | tee -a $slog
            echo "create this directory." | tee -a $slog
            echo 
            echo "If you do not want to keep downloaded archives (to save space), then select N." | tee -a $slog
            echo
            echo "Do you wish to create $DEST2 now? <Y or N>" | tee -a $slog
            read CDEST1
            # echo $CDEST1 >> $slog
            if [ $CDEST1 = "N" ]; 
               then
                    echo "PacketStormSecurity Exploit Archive directory has not been created." | tee -a $slog
                    sleep 2
            fi
            if [ $CDEST1 = "Y" ]; 
               then
                    echo "Creating PacketStormSecurity Exploit Archive directory now." | tee -a $slog
                    mkdir -p $DEST1 | tee -a $slog
                    echo "Directory $DEST1 created." | tee -a $slog
                    sleep 2
            fi
    fi
    
    # Get the latest and greatest update and upack the files into your exploit
    # directory then clean up the workspace.
    
    sleep 2
    echo
    echo "Checking to see if you have the most recent Exploits installed already...." | tee -a $log
    
    if test -d $DEST0$ii$p
            then
                    echo "It appears that you have the most current Exploit Archive installed.  Please check $DEST0$ii$p for Exploit Archive."
                    echo "Thank you.  Good bye."
                    exit
            else
    
    echo "Now attempting to download the exploit archive file for the" | tee -a $log
    echo "month of `date '+%B %Y' --date '1 month ago'` from PacketStormSecurity.com" | tee -a $log
    echo 
    echo "Depending on the size of the file, this could take a few..." | tee -a $log
    sleep 2
    wget -a $log -P $DEST0 $HOST$ii$p$i$f
    
    if test ! -e $DEST0$i$f
            then 
                    echo "Exploit archive for the month of `date '+%B %Y' --date '1 month ago'` is not currently available from PacketStormSecurity.com" | tee -a $log
                    echo "Please try again later." | tee -a $log
                    echo 
                    echo "Please see $log for further details." | tee -a $log 
                    echo 
                    echo "Now exiting." | tee -a $log 
                    exit
            else
                    echo "Exploits for the month of `date '+%B %Y' --date '1 month ago'` (filename: $i$f) has successfully downloaded." | tee -a $log 
                    echo "`date '+%B %Y' --date '1 month ago'` are now located in  $DEST0." | tee -a $log 
                    sleep 2
    fi
    
    echo "Unpacking $i$f now in $DEST0" | tee -a $log 
    echo
    tar -C $DEST0 -xvpf $DEST0$i$f >> $log 
    
    sleep 2
    
    echo
    echo
    echo "Do you wish to keep the compressed archive for the month of `date '+%B %Y' --date '1 month ago'`?"  | tee -a $log 
    echo "Press <K> to keep or <D> to delete the PacketStormSecurity Exploit Archive"  | tee -a $log 
    read KDARC   
    echo $KDARC >> $log
    
    if [ $KDARC = "D" ]; 
       then
            echo "You have chosen to delete the PacketStormSecurity Exploit Archive." | tee -a $log 
            rm $DEST0$i$f | tee -a $log 
    fi
    
    if [ $KDARC = "K" ]; 
       then
            echo "PacketStormSecurity Exploit Archive is now being moved to $DEST1." | tee -a $log 
            if test ! -d $DEST1
                    then
                            echo "PacketStormSecurity Exploit Archive directory ($DEST1) does not exist."
                            echo "Do you wish to create $DEST1 now? <Y or N>"
                                    read CDEST2
                                    echo CDEST2 >> $log
    
                                            if [ $CDEST2 = "Y" ];
                                                    then
                                                            mkdir $DEST1 | tee -a $slog
                                                            echo "$DEST1 has been created." | tee -a $slog
                                                            mv $DEST0$i$f $DEST1 | tee -a $log 
                                                    else
                                                            echo "Directory not created. Unable to save archive." | tee -a $slog
                                                            rm $DEST0$i$f | tee -a $log
                                            fi
                    else
                            echo "Moving $i$f to $DEST1 now." | tee -a $log
                            mv $DEST0$i$f $DEST1 | tee -a $log
            fi
    fi
    
    echo "Exploits are now available in $DEST0$i$p." | tee -a $log 
    echo 
    echo "Update Summary for PacketStormSecurity Exploit Archive Update Utility:" | tee -a $log 
    echo
    
    if [ $DEST0 = "Y" ]; 
       then
            echo "$DEST0 was created to house PacketStormSecurity Exploits Library." | tee -a $log 
    fi
    
    if [ $DEST1 = "Y" ]; 
       then
            echo "$DEST1 was created to archive PacketStormSecurity Exploits." | tee -a $log 
    fi
    
    if [ $DEST1 = "N" ]; 
       then
            echo "No archive directory was created at this time." | tee -a $log 
    fi
    
    if [ $KDARC = "K" ]; 
       then
            echo "You have decided to keep original compressed exploit archives in $DEST1." | tee -a $log 
    fi
    
    if [ $KDARC = "D" ]; 
       then
            echo "You have decided to delete original compressed exploit archives." | tee -a $log 
    fi
    
    echo 
    echo "Exploits for the month of `date '+%B %Y' --date '1 month ago'` are now available in $DEST0 in the $i$p directory." | tee -a $log 
    echo 
    echo "You can review this session at $log." | tee -a $log 
    echo
    echo "Good bye."
    fi

  2. #2
    My life is this forum thorin's Avatar
    Join Date
    Jan 2010
    Posts
    2,629

    Default

    Just one suggestion for future proofing.

    The very first thing you do in the script is statically assign an IP to $HOST. I suggest that you try to nslookup or host lookup the info and failing that use the hardcoded IP. That way if DNS is available and there's a change in the future you don't have any need to update the script and if DNS is not available it tries the hardcoded value.

    And a question about the sleeps:

    Your ifs around the destination directory check/creation all end in sleep 2, then the next line that runs is a sleep 2, is there any point to the embedded sleeps when the next line in normal flow is sleep? (Note: This isn't meant as a "you messed it up" comment, rather I'm wondering if there really was some type of timing issue with the run of the script).
    I'm a compulsive post editor, you might wanna wait until my post has been online for 5-10 mins before quoting it as it will likely change.

    I know I seem harsh in some of my replies. SORRY! But if you're doing something illegal or posting something that seems to be obvious BS I'm going to call you on it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •