Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Oct 25th, 2010  |  syntax: Bash  |  size: 17.95 KB  |  hits: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. #  Back|Track 4 Update Utility
  4.  
  5. #  (C)opyright 2010 Scamentology
  6. vs="1.8"
  7. clear
  8. #---License------------------------------------------------------------------------------------#
  9. #  This program is free software: you can redistribute it and/or modify it under the terms     #
  10. #  of the GNU General Public License as published by the Free Software Foundation, either      #
  11. #  version 3 of the License, or (at your option) any later version.                            #
  12. #                                                                                              #
  13. #  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;   #
  14. #  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   #
  15. #  See the GNU General Public License for more details.                                        #
  16. #                                                                                              #
  17. #  You should have received a copy of the GNU General Public License along with this program.  #
  18. #  If not, see <http://www.gnu.org/licenses/>.                                                 #
  19. #----------------------------------------------------------------------------------------------#
  20. ################################################################################################
  21. #                                                                                              #
  22. #    ~ btupdate.sh ( options ) ~                                                               #
  23. #    Updates the following...                                                                  #
  24. #    apt-get everything ( -d )                                                                 #
  25. #    Metasploit ( -m )                                                                         #
  26. #    aircrack-ng ( -a )                                                                        #
  27. #    exploitdb ( -e )                                                                          #
  28. #    Social Engineering Toolkit ( -s )                                                         #
  29. #    Fasttrack ( -f )                                                                          #
  30. #    SQLMap ( -S )                                                                             #
  31. #    Nikto ( -n )                                                                              #
  32. #    Nessus ( - N )                                                                            #
  33. #    w3af ( -w )                                                                               #
  34. #                                                                                              #
  35. #    ~Known Issues~                                                                            #
  36. #    Let me know                                                                               #
  37. #                                                                                              #
  38. #    SQLMaps SVN asks for passwords - Just keep hitting enter if you did this update           #
  39. #    !!!This program runs apt-get clean - so if you want to keep downloaded updates then       #
  40. #    # line 181                                                                                #
  41. #                                                                                              #
  42. ################################################################################################
  43.  
  44. #                 Variables
  45.  
  46. # Default install paths (Change these if your install path is different)
  47.      framework3_path="/pentest/exploits/framework3/"         # Metasploit framework 3
  48.      framework2_path="/pentest/exploits/framework2/"         # Metasploit framework 2
  49.        aircrack_path="/pentest/wireless/aircrack-ng/"        # aircrack-ng
  50.       exploitdb_path="/pentest/exploits/exploitdb/"          # Exploitdb
  51.             set_path="/pentest/exploits/SET/"                # Social Engineering Toolkit
  52.       fasttrack_path="/pentest/exploits/fasttrack/"          # Fasttrack
  53.          sqlmap_path="/pentest/database/sqlmap/"             # SQLMap
  54.           nikto_path="/pentest/scanners/nikto/"              # Nikto
  55.          nessus_path="/opt/nessus/sbin"                      # Nessus
  56.            w3af_path="/pentest/web/w3af"                     # w3af
  57.  
  58. # Online SVN Checks (Change these if the SVN link changes)
  59.       framework3_svn="https://www.metasploit.com/svn/framework3/trunk"
  60.       framework2_svn="https://www.metasploit.com/svn/framework2/trunk"
  61.         aircrack_svn="http://trac.aircrack-ng.org/svn/trunk"
  62.        exploitdb_svn="svn://www.exploit-db.com/exploitdb"
  63.              set_svn="http://svn.thepentest.com/social_engineering_toolkit"
  64.        fasttrack_svn="http://svn.secmaniac.com/fasttrack"
  65.           sqlmap_svn="http://svn.sqlmap.org/sqlmap/trunk/sqlmap"
  66.             w3af_svn="https://w3af.svn.sourceforge.net/svnroot/w3af/trunk"
  67.  
  68. # Update Commands (Change these if the build design changes - or they are wrong)
  69.   framework3_command="svn update"
  70.   framework2_command="svn update"
  71.     aircrack_command="svn update"
  72.    exploitdb_command="svn update"
  73.          set_command="./set-update"
  74.    fasttrack_command="svn update"
  75.       sqlmap_command="svn update"
  76.        nikto_command="perl nikto.pl -update"
  77.       nessus_command="./nessus-update-plugins"
  78.         w3af_command="svn update"
  79.  
  80. #-- Nothing to change below this line --------------------------------------------------
  81.  
  82. # Temporary log location
  83.                  log="/tmp/btupdate.log"
  84. # Borders
  85.              border1="echo "############################""
  86.              border2="echo "################################################################""
  87.  
  88. function help() { #help
  89.    echo "(C)opyright 2010 Scamentology ~
  90. ######################################
  91. #           btupdate $vs             #
  92. # A script for updating Back|Track 4 #
  93. ######################################
  94.  
  95. Usage: update.sh [options]
  96.  
  97. Options:
  98.   -d [Dist-up]            ---  apt-get everything
  99.   -m [Metasploit]         ---  Update Metasploit 2 and 3 (svn update)
  100.   -a [aircrack-ng]        ---  Update aircrack-ng
  101.   -e [exploitdb]          ---  Update exploitdb
  102.   -s [SET]                ---  Update Social Engineering Toolkit
  103.   -S [SQLMap]             ---  Update SQLMap
  104.   -f [Fasttrack]          ---  Update Fasttrack
  105.   -n [Nikto]              ---  Update Nikto
  106.   -N [Nessus]             ---  Update Nessus Plugins
  107.   -w [w3af]               ---  Update w3af
  108.   -x [Everything]         ---  Do all actions in script
  109.   -z [Almost Everything]  ---  Do all actions in script except apt-get upgrade/dist-upgrade
  110.   -h [Help]               ---  Help menu
  111.  
  112. Example:
  113.   ./btupdate.sh -x              (updates everything including apt-get
  114.   ./btupdate.sh -d              (apt-get update & upgrade & dist-upgrade)
  115.   ./btupdate.sh -m -a -s -f     (updates Metasploit Aircrack-ng SET and Fasttrack)
  116.  
  117. "
  118.    exit 1
  119. }
  120. while getopts "dmaesSfnNwxhz" OPTIONS; do
  121.    case ${OPTIONS} in
  122.       d ) dup="true" ;;                         # apt-get everything
  123.       m ) metasploit="true" ;;                  # Update Metasploit 2 and 3 (svn co)
  124.       a ) aircrack="true" ;;                    # Update aircrack-ng
  125.       e ) exploitdb="true" ;;                   # Update exploitdb
  126.       s ) SET="true" ;;                         # Update Social Engineering Toolkit
  127.       S ) SQLMap="true" ;;                      # Update SQLMap
  128.       n ) nikto="true" ;;                       # Update Nikto plugins
  129.       N ) nessus="true" ;;                      # Update Nessus plugins
  130.       f ) fasttrack="true" ;;                   # Update Fasttrack
  131.       w ) w3af="true" ;;                        # Update w3af
  132.       x ) all="true" ;;                         # Do all actions in script
  133.           z ) partall="true";;                                          # Do all actions in script exept apt-get upgrade & dist-upgrade
  134.       h ) help ;;                               # Help menu
  135.       * ) help ;;                               # Default
  136.    esac
  137. done
  138.  
  139. #__ If the -x switch is chosen______________________________________________
  140. if [ "$all" == "true" ] ; then
  141.    metasploit="true"
  142.      aircrack="true"
  143.           dup="true"
  144.           SET="true"
  145.     exploitdb="true"
  146.     fasttrack="true"
  147.        SQLMap="true"
  148.         nikto="true"
  149.        nessus="true"
  150.          w3af="true"
  151. fi
  152.  
  153. #__ If the -z switch is chosen_______________________________________________
  154. if [ "$partall" == "true" ] ; then
  155.    metasploit="true"
  156.      aircrack="true"
  157.           dup="false"
  158.       partapt="true"
  159.           SET="true"
  160.     exploitdb="true"
  161.     fasttrack="true"
  162.        SQLMap="true"
  163.         nikto="true"
  164.        nessus="true"
  165.          w3af="true"
  166. fi
  167.        
  168.  
  169. echo "   (C)opyright 2010 Scamentology ~"
  170. echo "######################################"
  171. echo "#           btupdate $vs             #"
  172. echo "# A script for updating Back|Track 4 #"
  173. echo "######################################"
  174.  
  175. #__ Check if Root __________________________________________________________
  176. if [ "$(id -u)" != "0" ] ; then echo "Run as root" ; exit 1 ; fi
  177.  
  178. #__ If no choices are made _________________________________________________
  179. if [ "$all" == "" ] && [ "$metasploit" == "" ] && [ "$aircrack" == "" ] && [ "$dup" == "" ] && [ "$SET" == "" ] && [ "$SQLMap" == "" ] && [ "$exploitdb" == "" ] && [ "$fasttrack" == "" ] && [ "$nikto" == "" ] && [ "$nessus" == "" ] && [ "$w3af" == "" ] ; then echo "Please choose an option" ; exit 1 ; fi
  180.  
  181. #__  _________________________
  182. if [ "$cleanup" == "true" ] ; then clean="apt-get clean" ; fi
  183.  
  184. #__ Checking for Internet___________________________________________________
  185. clear
  186. $border1
  187. echo "#[i] Checking for internet"
  188. $border1
  189. for (( ; ; ))
  190. do
  191.    ping -c 1 www.google.com >/dev/null
  192.    return_val=$?
  193.    if [ $return_val != "0" ] ; then
  194.       clear
  195.       $border2
  196.       echo "[!] Internet access: Failed..."
  197.       $border2
  198.       echo "[i] Click yes to start networking then close wicd to continue"
  199.       $border2
  200.       read -p "[?] Would you like to open WICD now? [Y/n]: "
  201.          if [[ "$REPLY" =~ ^[Yy]$ ]] ; then
  202.          wicd-gtk --no-tray
  203.       else
  204.          clear
  205.          $border1
  206.          echo "[!] No internet access available"
  207.          $border1
  208.          exit 1
  209.          fi
  210.    else
  211.       clear
  212.       $border1
  213.       echo "[i] Internet access: Success" ;
  214.       $border1
  215.       break;
  216.    fi
  217. done
  218.  
  219. #__ Distribution and apt-get _______________________________________________
  220. if [ "$dup" == "true" ] ; then
  221.    clear
  222.    echo " -- Updating Distribution --------------------" >> $log
  223.    $border1
  224.    echo "[i] Updating Distribution..."
  225.    $border1
  226.    apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade | grep "newly installed" >> $log
  227.    $clean
  228. fi
  229.  
  230. #__ Updating apt Cache _______________________________________________
  231. if [ "$partapt" == "true" ] ; then
  232.    clear
  233.    echo " -- Updating apt Cache --------------------" >> $log
  234.    $border1
  235.    echo "[i] Updating apt Cache..."
  236.    $border1
  237.    apt-get update >> $log
  238.    $clean
  239. fi
  240.  
  241. #__ MSF Framework 3 ________________________________________________________
  242. if [ "$metasploit" == "true" ] ; then
  243.    clear
  244.    echo " -- Framework 3 ------------------------------" >> $log
  245.    $border1
  246.    echo "[i] Updating Framework 3..."
  247.    $border1
  248.    cd $framework3_path
  249.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  250.    newsvn=$(svn info $framework3_svn | grep "Revision" | cut -c11-)
  251.    if [ "$newsvn" == "$oldsvn" ] ; then  
  252.       echo "You are up to date already (SVN $newsvn)" >> $log
  253.    else
  254.       svn update
  255.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  256.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  257.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  258.    fi
  259. fi
  260.  
  261. if [ "$metasploit" == "true" ] ; then
  262.    clear
  263.    echo " -- Framework 2 ------------------------------" >> $log
  264.    $border1
  265.    echo "[i] Updating Framework 2..."
  266.    $border1
  267.    cd $framework2_path
  268.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  269.    newsvn=$(svn info $framework2_svn | grep "Revision" | cut -c11-)
  270.    if [ "$newsvn" == "$oldsvn" ] ; then  
  271.       echo "You are up to date already (SVN $newsvn)" >> $log
  272.    else
  273.       svn update
  274.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  275.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  276.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  277.    fi
  278. fi
  279.  
  280. #__ Aircrack-ng ____________________________________________________________
  281. if [ "$aircrack" == "true" ] ; then
  282.    clear
  283.    echo " -- Aircrack-ng ------------------------------" >> $log
  284.    $border1
  285.    echo "[i] Updating aircrack-ng..."
  286.    $border1
  287.    cd $aircrack_path
  288.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  289.    newsvn=$(svn info $aircrack_svn | grep "Revision" | cut -c11-) >> $log
  290.    if [ "$newsvn" == "$oldsvn" ] ; then  
  291.       echo "You are up to date already (SVN $newsvn)" >> $log
  292.    else
  293.       svn update
  294.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  295.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  296.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  297.    fi
  298. fi
  299.  
  300. #__ Exploitdb ______________________________________________________________
  301. if [ "$exploitdb" == "true" ] ; then
  302.    clear
  303.    echo " -- Exploitdb --------------------------------" >> $log
  304.    $border1
  305.    echo "[i] Updating Exploitdb..."
  306.    $border1
  307.    cd $exploitdb_path
  308.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  309.    newsvn=$(svn info $exploitdb_svn | grep "Revision" | cut -c11-)
  310.    if [ "$newsvn" == "$oldsvn" ] ; then  
  311.       echo "You are up to date already (SVN $newsvn)" >> $log
  312.    else
  313.       svn update
  314.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  315.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  316.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  317.    fi
  318. fi
  319.  
  320. #__ Social Engineering Toolkit _____________________________________________
  321. if [ "$SET" == "true" ] ; then
  322.    clear
  323.    echo " -- SET --------------------------------------" >> $log
  324.    $border1
  325.    echo "[i] Updating SET..."
  326.    $border1
  327.    cd $set_path
  328.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  329.    newsvn=$(svn info $set_svn | grep "Revision" | cut -c11-)
  330.    if [ "$newsvn" == "$oldsvn" ] ; then  
  331.       echo "You are up to date already (SVN $newsvn)" >> $log
  332.    else
  333.       svn update
  334.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  335.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  336.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  337.    fi
  338. fi
  339.  
  340. #__ Fast-track _____________________________________________________________
  341. if [ "$fasttrack" == "true" ] ; then
  342.    clear
  343.    echo " -- Fasttrack --------------------------------" >> $log
  344.    $border1
  345.    echo "[i] Updating Fasttrack...  "
  346.    $border1
  347.    cd $fasttrack_path
  348.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  349.    newsvn=$(svn info $fasttrack_svn | grep "Revision" | cut -c11-)
  350.    if [ "$newsvn" == "$oldsvn" ] ; then  
  351.       echo "You are up to date already (SVN $newsvn)" >> $log
  352.    else
  353.       svn update
  354.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  355.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  356.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  357.    fi
  358. fi
  359.  
  360. #__ SQLMap _________________________________________________________________
  361. if [ "$SQLMap" == "true" ] ; then
  362.    clear
  363.    echo " -- SQLMap -----------------------------------" >> $log
  364.    $border1
  365.    echo "[i] Updating SQLMap...      "
  366.    $border1
  367.    cd $sqlmap_path
  368.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  369.    newsvn=$(svn info $sqlmap_svn | grep "Revision" | cut -c11-)
  370.    if [ "$newsvn" == "$oldsvn" ] ; then  
  371.       echo "You are up to date already (SVN $newsvn)" >> $log
  372.    else
  373.       svn update
  374.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  375.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  376.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  377.    fi
  378. fi
  379.  
  380. #__ Nikto __________________________________________________________________
  381. if [ "$nikto" == "true" ] ; then
  382.    clear
  383.    echo " -- Nikto ------------------------------------" >> $log
  384.    $border1
  385.    echo "[i] Updating Nikto...  "
  386.    $border1
  387.    cd $nikto_path
  388.    $nikto_command | awk -v line=1 'NR == line { print $0 }'  >> $log
  389. fi
  390.  
  391. #__ Nessus _________________________________________________________________
  392. if [ "$nessus" == "true" ] ; then
  393.    clear
  394.    echo " -- Nessus -----------------------------------" >> $log
  395.    $border1
  396.    echo "[i] Updating Nessus...  "
  397.    $border1
  398.    cd $nessus_path
  399.    $nessus_command | awk -v line=2 'NR == line { print $0 }'  >> $log
  400. fi
  401.  
  402. #__ w3af ___________________________________________________________________
  403. if [ "$w3af" == "true" ] ; then
  404.    clear
  405.    echo " -- w3af -------------------------------------" >> $log
  406.    $border1
  407.    echo "[i] Updating w3af..."
  408.    $border1
  409.    cd $w3af_path
  410.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  411.    newsvn=$(svn info $w3af_svn | grep "Revision" | cut -c11-)
  412.    if [ "$newsvn" == "$oldsvn" ] ; then  
  413.       echo "You are up to date already (SVN $newsvn)" >> $log
  414.    else
  415.       svn update
  416.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  417.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  418.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  419.    fi
  420. fi
  421.  
  422. clear
  423. $border2
  424. echo " Update report for $(date)"
  425. $border2
  426. cat $log
  427. $border2
  428. sleep 1
  429. rm -f $log
  430. exit 1