Advertisement
Guest User

Untitled

a guest
Oct 26th, 2010
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 18.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #  Back|Track 4 Update Utility
  4.  
  5. #  (C)opyright 2010 Scamentology
  6. vs="1.81"
  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. #    ( -d ) apt-get everything (Change variable under OS update below to disable any features) #
  25. #    ( -m ) Metasploit                                                                         #
  26. #    ( -a ) aircrack-ng and airgraph-ng                                            #
  27. #    ( -e ) exploitdb                                                                          #
  28. #    ( -s ) Social Engineering Toolkit                                                         #
  29. #    ( -f ) Fasttrack                                                                          #
  30. #    ( -S ) SQLMap                                                                             #
  31. #    ( -n ) Nikto                                                                              #
  32. #    ( -N ) Nessus                                                                             #
  33. #    ( -w ) w3af                                                                               #
  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. #    change -clean="yes"- to -clean="no"-                                                      #
  41. #                                                                                              #
  42. ################################################################################################
  43.  
  44. #                 Variables
  45.  
  46. # Check for Internet Access
  47.             netcheck="yes"        # (yes/no) no = don't check for internet access
  48.  
  49. # OS Update and Upgrade Variables
  50.               update="yes"        # (yes/no) yes for Update
  51.              upgrade="yes"        # (yes/no) yes for Upgrade
  52.                  dup="yes"        # (yes/no) yes for Distribution Update
  53.                clean="yes"        # (yes/no) Cleanup Downloaded Packages
  54.  
  55. # Default Install Paths (Change these if your install path is different)
  56.      framework3_path="/pentest/exploits/framework3/"         # Metasploit framework 3
  57.      framework2_path="/pentest/exploits/framework2/"         # Metasploit framework 2
  58.        aircrack_path="/pentest/wireless/aircrack-ng/"        # Aircrack-ng
  59.        airgraph_path="/pentest/wireless/airgraph-ng"         # Airgraph-ng
  60.       exploitdb_path="/pentest/exploits/exploitdb"           # Exploitdb
  61.             set_path="/pentest/exploits/SET/"                # Social Engineering Toolkit
  62.       fasttrack_path="/pentest/exploits/fasttrack/"          # Fasttrack
  63.          sqlmap_path="/pentest/database/sqlmap/"             # SQLMap
  64.           nikto_path="/pentest/scanners/nikto/"              # Nikto
  65.          nessus_path="/opt/nessus/sbin"                      # Nessus
  66.            w3af_path="/pentest/web/w3af"                     # w3af
  67.  
  68. # Online SVN Checks (Change these if the SVN link changes)
  69.       framework3_svn="https://www.metasploit.com/svn/framework3/trunk"
  70.       framework2_svn="https://www.metasploit.com/svn/framework2/trunk"
  71.         aircrack_svn="http://trac.aircrack-ng.org/svn/trunk"
  72.         airgraph_svn="http://trac.aircrack-ng.org/svn/trunk/scripts/airgraph-ng"
  73.        exploitdb_svn="svn://devel.offensive-security.com/exploitdb"
  74.              set_svn="http://svn.thepentest.com/social_engineering_toolkit"
  75.        fasttrack_svn="http://svn.secmaniac.com/fasttrack"
  76.           sqlmap_svn="http://svn.sqlmap.org/sqlmap/trunk/sqlmap"
  77.             w3af_svn="https://w3af.svn.sourceforge.net/svnroot/w3af/trunk"
  78.  
  79. # Update Commands (Change these if the build design changes - or they are wrong)
  80.   framework3_command="svn update"
  81.   framework2_command="svn update"
  82.     aircrack_command="svn update"
  83.     airgraph_command="svn update"
  84.    exploitdb_command="svn co svn://devel.offensive-security.com/exploitdb"
  85.          set_command="./set-update"
  86.    fasttrack_command="svn update"
  87.       sqlmap_command="svn update"
  88.        nikto_command="perl nikto.pl -update"
  89.       nessus_command="./nessus-update-plugins"
  90.         w3af_command="svn update"
  91.  
  92. #-- Nothing to change below this line --------------------------------------------------
  93.  
  94. # Temporary log location
  95.                  log="/tmp/btupdate.log"
  96. # Borders
  97.              border1="echo "############################""
  98.              border2="echo "################################################################""
  99.  
  100. # Help Section
  101. function help() {
  102.    echo "(C)opyright 2010 Scamentology ~
  103. ######################################
  104. #           btupdate $vs             #
  105. # A script for updating Back|Track 4 #
  106. ######################################
  107.  
  108. Usage: update.sh [options]
  109.  
  110. Options:
  111.   -d [Dist-up]            ---  apt-get everything
  112.   -m [Metasploit]         ---  Update Metasploit 2 and 3 (svn update)
  113.   -a [aircrack-ng]        ---  Update aircrack-ng, airdrop-ng and airgraph-ng
  114.   -e [exploitdb]          ---  Update exploitdb
  115.   -s [SET]                ---  Update Social Engineering Toolkit
  116.   -S [SQLMap]             ---  Update SQLMap
  117.   -f [Fasttrack]          ---  Update Fasttrack
  118.   -n [Nikto]              ---  Update Nikto
  119.   -N [Nessus]             ---  Update Nessus Plugins
  120.   -w [w3af]               ---  Update w3af
  121.   -x [Everything]         ---  Do all actions in script
  122.   -h [Help]               ---  Help menu
  123.  
  124. Example:
  125.   ./btupdate.sh -x              (updates everything including apt-get
  126.   ./btupdate.sh -d              (apt-get update, upgrade and dist-upgrade)
  127.   ./btupdate.sh -m -a -s -f     (updates Metasploit Aircrack-ng SET and Fasttrack)
  128.  
  129. "
  130.    exit 1
  131. }
  132. while getopts "dmaesSfnNwxh" OPTIONS; do
  133.    case ${OPTIONS} in
  134.       d ) distup="true" ;;                      # apt-get everything
  135.       m ) metasploit="true" ;;                  # Update Metasploit 2 and 3 (svn co)
  136.       a ) aircrack="true" ;;                    # Update aircrack-ng and airgraph-ng
  137.       e ) exploitdb="true" ;;                   # Update exploitdb
  138.       s ) SET="true" ;;                         # Update Social Engineering Toolkit
  139.       S ) SQLMap="true" ;;                      # Update SQLMap
  140.       n ) nikto="true" ;;                       # Update Nikto plugins
  141.       N ) nessus="true" ;;                      # Update Nessus plugins
  142.       f ) fasttrack="true" ;;                   # Update Fasttrack
  143.       w ) w3af="true" ;;                        # Update w3af
  144.       x ) all="true" ;;                         # Do all actions in script
  145.       h ) help ;;                               # Help menu
  146.       * ) help ;;                               # Default
  147.    esac
  148. done
  149.  
  150. #__ If the -x switch is chosen______________________________________________
  151. if [ "$all" == "true" ] ; then
  152.    metasploit="true"
  153.      aircrack="true"
  154.        distup="true"
  155.           SET="true"
  156.     exploitdb="true"
  157.     fasttrack="true"
  158.        SQLMap="true"
  159.         nikto="true"
  160.        nessus="true"
  161.          w3af="true"
  162. fi
  163.  
  164. echo "   (C)opyright 2010 Scamentology ~"
  165. echo "######################################"
  166. echo "#           btupdate $vs             #"
  167. echo "# A script for updating Back|Track 4 #"
  168. echo "######################################"
  169.  
  170. #__ Check if Root __________________________________________________________
  171. if [ "$(id -u)" != "0" ] ; then echo "Run as root" ; exit 1 ; fi
  172.  
  173. #__ If no choices are made _________________________________________________
  174. if [ "$all" == "" ] && [ "$metasploit" == "" ] && [ "$aircrack" == "" ] && [ "$distup" == "" ] && [ "$SET" == "" ] && [ "$SQLMap" == "" ] && [ "$exploitdb" == "" ] && [ "$fasttrack" == "" ] && [ "$nikto" == "" ] && [ "$nessus" == "" ] && [ "$w3af" == "" ] ; then echo "Please choose an option" ; exit 1 ; fi
  175.  
  176. #__ Distribution Upgrade Variables _________________________________________
  177. if [ "$update" == "yes" ] ; then updatea="apt-get -y update" ; fi
  178. if [ "$upgrade" == "yes" ] ; then upgradea="apt-get -y upgrade" ; fi
  179. if [ "$dup" == "yes" ] ; then distupa="apt-get -y dist-upgrade" ; fi
  180. if [ "$clean" == "yes" ] ; then cleana="apt-get -y dist-upgrade" ; fi
  181.  
  182. #__  _________________________
  183. if [ "$cleanup" == "true" ] ; then clean="apt-get clean" ; fi
  184.  
  185. #__ Checking for Internet___________________________________________________
  186. if [ "$netcheck" == "yes" ] ; then
  187.    clear
  188.    $border1
  189.    echo "#[i] Checking for internet"
  190.    $border1
  191.    for (( ; ; ))
  192.    do
  193.       ping -c 1 www.google.com >/dev/null
  194.       return_val=$?
  195.       if [ $return_val != "0" ] ; then
  196.          clear
  197.          $border2
  198.          echo "[!] Internet access: Failed..."
  199.          $border2
  200.          echo "[i] Click yes to start networking then close wicd to continue"
  201.          $border2
  202.          read -p "[?] Would you like to open WICD now? [Y/n]: "
  203.             if [[ "$REPLY" =~ ^[Yy]$ ]] ; then
  204.             wicd-gtk --no-tray
  205.          else
  206.             clear
  207.             $border1
  208.             echo "[!] No internet access available"
  209.             $border1
  210.             exit 1
  211.             fi
  212.       else
  213.          clear
  214.          $border1
  215.          echo "[i] Internet access: Success" ;
  216.          $border1
  217.          break;
  218.       fi
  219. done
  220. fi
  221. #__ Distribution and apt-get _______________________________________________
  222. if [ "$distup" == "true" ] ; then
  223.    clear
  224.    echo " -- Updating Distribution --------------------" >> $log
  225.    $border1
  226.    echo "[i] Updating Distribution..."
  227.    $border1
  228.    $updatea && $upgradea && $distupa | grep "newly installed" >> $log
  229.    $cleana
  230. fi
  231.  
  232. #__ MSF Framework 3 ________________________________________________________
  233. if [ "$metasploit" == "true" ] ; then
  234.    clear
  235.    echo " -- Framework 3 ------------------------------" >> $log
  236.    $border1
  237.    echo "[i] Updating Framework 3..."
  238.    $border1
  239.    cd $framework3_path
  240.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  241.    newsvn=$(svn info $framework3_svn | grep "Revision" | cut -c11-)
  242.    if [ "$newsvn" == "$oldsvn" ] ; then  
  243.       echo "You are up to date already (SVN $newsvn)" >> $log
  244.    else
  245.       $framework3_command
  246.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  247.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  248.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  249.    fi
  250. fi
  251.  
  252. #__ MSF Framework 2 ________________________________________________________
  253. if [ "$metasploit" == "true" ] ; then
  254.    clear
  255.    echo " -- Framework 2 ------------------------------" >> $log
  256.    $border1
  257.    echo "[i] Updating Framework 2..."
  258.    $border1
  259.    cd $framework2_path
  260.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  261.    newsvn=$(svn info $framework2_svn | grep "Revision" | cut -c11-)
  262.    if [ "$newsvn" == "$oldsvn" ] ; then  
  263.       echo "You are up to date already (SVN $newsvn)" >> $log
  264.    else
  265.       $framework2_command
  266.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  267.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  268.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  269.    fi
  270. fi
  271.  
  272. #__ Aircrack-ng ____________________________________________________________
  273. if [ "$aircrack" == "true" ] ; then
  274.    clear
  275.    echo " -- Aircrack-ng ------------------------------" >> $log
  276.    $border1
  277.    echo "[i] Updating aircrack-ng..."
  278.    $border1
  279.    cd $aircrack_path
  280.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  281.    newsvn=$(svn info $aircrack_svn | grep "Revision" | cut -c11-) >> $log
  282.    if [ "$newsvn" == "$oldsvn" ] ; then  
  283.       echo "You are up to date already (SVN $newsvn)" >> $log
  284.    else
  285.       $aircrack_command
  286.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  287.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  288.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  289.    fi
  290. fi
  291.  
  292. #__ Airgraph-ng _____________________________________________________________
  293. if [ "$aircrack" == "true" ] ; then
  294.    clear
  295.    echo " -- Airgraph-ng ----------------------------------" >> $log
  296.    $border1
  297.    echo "[i] Updating Airgraph-ng..."
  298.    $border1
  299.    cd $airgraph_path
  300.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  301.    newsvn=$(svn info $airgraph_svn | grep "Revision" | cut -c11-)
  302.    if [ "$newsvn" == "$oldsvn" ] ; then  
  303.       echo "You are up to date already (SVN $newsvn)" >> $log
  304.    else
  305.       $airgraph_command
  306.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  307.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  308.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  309.    fi
  310. fi
  311.  
  312. #__ Exploitdb ______________________________________________________________
  313. if [ "$exploitdb" == "true" ] ; then
  314.    clear
  315.    echo " -- Exploitdb --------------------------------" >> $log
  316.    $border1
  317.    echo "[i] Updating Exploitdb..."
  318.    $border1
  319.    cd $exploitdb_path
  320.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  321.    newsvn=$(svn info $exploitdb_svn | grep "Revision" | cut -c11-)
  322.    if [ "$newsvn" == "$oldsvn" ] ; then  
  323.       echo "You are up to date already (SVN $newsvn)" >> $log
  324.    else
  325.       rm -rf exploitdb/
  326.       $exploitdb_command
  327.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  328.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  329.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  330.    fi
  331. fi
  332.  
  333. #__ Social Engineering Toolkit _____________________________________________
  334. if [ "$SET" == "true" ] ; then
  335.    clear
  336.    echo " -- SET --------------------------------------" >> $log
  337.    $border1
  338.    echo "[i] Updating SET..."
  339.    $border1
  340.    cd $set_path
  341.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  342.    newsvn=$(svn info $set_svn | grep "Revision" | cut -c11-)
  343.    if [ "$newsvn" == "$oldsvn" ] ; then  
  344.       echo "You are up to date already (SVN $newsvn)" >> $log
  345.    else
  346.       $set_command
  347.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  348.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  349.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  350.    fi
  351. fi
  352.  
  353. #__ Fast-track _____________________________________________________________
  354. if [ "$fasttrack" == "true" ] ; then
  355.    clear
  356.    echo " -- Fasttrack --------------------------------" >> $log
  357.    $border1
  358.    echo "[i] Updating Fasttrack...  "
  359.    $border1
  360.    cd $fasttrack_path
  361.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  362.    newsvn=$(svn info $fasttrack_svn | grep "Revision" | cut -c11-)
  363.    if [ "$newsvn" == "$oldsvn" ] ; then  
  364.       echo "You are up to date already (SVN $newsvn)" >> $log
  365.    else
  366.       $fasttrack_command
  367.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  368.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  369.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  370.    fi
  371. fi
  372. #__ SQLMap _________________________________________________________________
  373. if [ "$SQLMap" == "true" ] ; then
  374.    clear
  375.    echo " -- SQLMap -----------------------------------" >> $log
  376.    $border1
  377.    echo "[i] Updating SQLMap...      "
  378.    $border1
  379.    cd $sqlmap_path
  380.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  381.    newsvn=$(svn info $sqlmap_svn | grep "Revision" | cut -c11-)
  382.    if [ "$newsvn" == "$oldsvn" ] ; then  
  383.       echo "You are up to date already (SVN $newsvn)" >> $log
  384.    else
  385.       svn update
  386.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  387.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  388.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  389.    fi
  390. fi
  391.  
  392. #__ Nikto __________________________________________________________________
  393. if [ "$nikto" == "true" ] ; then
  394.    clear
  395.    echo " -- Nikto ------------------------------------" >> $log
  396.    $border1
  397.    echo "[i] Updating Nikto...  "
  398.    $border1
  399.    cd $nikto_path
  400.    $nikto_command | awk -v line=1 'NR == line { print $0 }'  >> $log
  401. fi
  402.  
  403. #__ Nessus _________________________________________________________________
  404. if [ "$nessus" == "true" ] ; then
  405.    clear
  406.    echo " -- Nessus -----------------------------------" >> $log
  407.    $border1
  408.    echo "[i] Updating Nessus...  "
  409.    $border1
  410.    cd $nessus_path
  411.    $nessus_command | awk -v line=2 'NR == line { print $0 }'  >> $log
  412. fi
  413.  
  414. #__ w3af ___________________________________________________________________
  415. if [ "$w3af" == "true" ] ; then
  416.    clear
  417.    echo " -- w3af -------------------------------------" >> $log
  418.    $border1
  419.    echo "[i] Updating w3af..."
  420.    $border1
  421.    cd $w3af_path
  422.    oldsvn=$(svn info | grep "Revision" | cut -c11-)
  423.    newsvn=$(svn info $w3af_svn | grep "Revision" | cut -c11-)
  424.    if [ "$newsvn" == "$oldsvn" ] ; then  
  425.       echo "You are up to date already (SVN $newsvn)" >> $log
  426.    else
  427.       $w3af_command
  428.       upsvn=$(svn info | grep "Revision" | cut -c11-)
  429.       if [ "$newsvn" == "$upsvn" ] ; then echo "Updated Successfully to    (SVN $upsvn)" >> $log ; fi
  430.       if [ "$newsvn" != "$upsvn" ] ; then echo "Server might be down or slow - Try again" >> $log ; fi
  431.    fi
  432. fi
  433.  
  434. clear
  435. $border2
  436. echo " Update report for $(date)"
  437. $border2
  438. cat $log
  439. $border2
  440. sleep 1
  441. rm -f $log
  442. exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement