r00t-3xp10it

[ netool toolkit ] import a nmap.XML to Msf db

Dec 15th, 2014
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.54 KB | None | 0 0
  1. #----------------------------------------------------------
  2. # RED TEAM OPERATIONS (netool t00lkit - msfdb.db)
  3. # use metasploit database to store scans made by nmap
  4. # to be used later in netool toolkit by red team members.
  5. # ---------------------------------------------------------
  6. # WARNING: THIS SCRIPT WILL NOT WORK OUTSIDE NETOOL T00LKIT
  7. # ---------------------------------------------------------
  8.  
  9.  
  10.  
  11. PLANNING:
  12. When you are working with other team members, with various individuals scanning at different times
  13. and from different locations, it helps to know how to import a basic nmap generated XML export file
  14. into the metasploit db Framework.
  15.  
  16. First, we scan the Windows machine using the -oX option to generate a Target.xml file.
  17. -------------------------------------------
  18. nmap -sS -Pn -oX $H0m3/opensource/logs/intrusive.log $target
  19. -------------------------------------------
  20. After generating the XML file, we use the db_import command to import it into our database.
  21. We can then verify that the import worked by using the “hosts” command, which lists the
  22. systems entries that have been created, as shown here:
  23. -------------------------------------------
  24. msf> db_status
  25. msf> db_import Subnet1.xml
  26. msf> hosts
  27. -------------------------------------------
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. # ---------------------------------
  36. # to be inserted into netool.sh
  37. # ---------------------------------
  38. #!/bin/sh
  39.  
  40.  
  41.  
  42.  
  43.  
  44. # -----------------------------------
  45. # search for specific port open in the external network
  46. # -----------------------------------
  47. sh_extlan () {
  48.  
  49.    Colors;
  50.    echo ${YellowF}'-|' This module searches For random targets with a ${Reset};
  51.    echo ${YellowF}'-|' Specified open port In external network '(WAN)' ${Reset};
  52.    echo ${YellowF}'-|' We can scan ports with this module In 2 ways ${Reset};
  53.    echo ${YellowF}'-|' [${GreenF} 80,135,445 ${YellowF}] OR [${GreenF} 1-1000 ${YellowF}] ${Reset};
  54.  
  55.       # chose to run  or to leave to main menu
  56.       read -p "[+]::{run|quit}(choise):" pass
  57.       if test "$pass" = "run"
  58.  
  59. then
  60.  
  61.    Colors;
  62.    NUM=$(zenity --scale --title "SCAN WAN NETWORK" --text "Nº LIMIT OF HOSTS TO FOUND" --min-value=1 --max-value=1027 --value=1 --step 1) > /dev/null 2>&1
  63.    PORT=$(zenity --title="PORTS TO SEARCH" --text " example: 21,139,445" --width 300 --entry) > /dev/null 2>&1
  64.    output=$(zenity --list --title "LOGFILE OUTPUT FORMAT" --text "log => port scan to toolkit database\nxml => port scan to msf database" --radiolist --column "Pick" --column "Option" TRUE "output in log (t00lkit db)" FALSE "Output in xml (msf db)" --width 330 --height 180) > /dev/null 2>&1
  65.    sh_cshh
  66.  
  67. else
  68.  
  69.    Colors;
  70.    echo ${RedF}[x]::[ QUITTING ] ${Reset};
  71.    sleep 2
  72.    clear
  73.    sh_2menu
  74. fi
  75. }
  76.  
  77.  
  78.  
  79. sh_cshh () {
  80. Colors;
  81.  
  82.  
  83.  if [ "$output" = "output in log (t00lkit db)" ]; then
  84.    echo ${BlueF}[*]${RedF}::${BlueF}[Please wait]${RedF}::${GreenF}[ RUNING SCANS ] ${Reset};
  85.    nmap -e $inter -iR $NUM -sS -Pn -p $PORT --open -oN ~/opensource/logs/Random-Hosts.log | zenity --progress --pulsate --title "SCANING WAN NETWORK" --text="LOGFILE: Random-Hosts.log\nHOSTS: $NUM ONLY: open PORTS: $PORT" --percentage=0 --auto-close > /dev/null 2>&1
  86.       cat ~/opensource/logs/Random-Hosts.log | zenity --title "SCAN WAN NETWORK REPORT" --text-info --width 730 --height 500 > /dev/null 2>&1
  87.       chown $usera ~/opensource/logs/Random-Hosts.log > /dev/null 2>&1
  88.       sleep 1
  89.       sh_hdtt3
  90.  
  91. else
  92.  
  93.    Colors;
  94.    echo ${BlueF}[*]${RedF}::${BlueF}[Please wait]${RedF}::${GreenF}[ RUNING SCANS ] ${Reset};
  95.    echo "" > ~/opensource/logs/Random-Hosts.xml
  96.    nmap -e $inter -iR $NUM -sS -Pn -p $PORT --open -oX ~/opensource/logs/Random-Hosts.xml $ipscan | zenity --progress --pulsate --title "SCANING WAN NETWORK" --text="LOGFILE: Random-Hosts.xml\nHOSTS: $NUM ONLY: open PORTS: $PORT" --percentage=0 --auto-close > /dev/null 2>&1
  97.    chown $usera ~/opensource/logs/Random-Hosts.xml > /dev/null 2>&1
  98.    sh_fff
  99. fi
  100. }
  101.  
  102.  
  103.  
  104.  
  105. sh_hdtt3 () {
  106. Colors;
  107.  
  108.    # store scans in database?
  109.    dbt=$(zenity --list --title "T00LKIT DATABASE" --text "Store scan on t00lkit database?" --radiolist --column "Pick" --column "Option" TRUE "Append scan to DataBase" FALSE "Clear Database and Append scan" FALSE "Clear Database and manually input" --width 330 --height 180) > /dev/null 2>&1
  110.  
  111.  
  112.      if [ "$dbt" = "Append scan to DataBase" ]; then
  113.        dtr=`date`
  114.        fill=`cat $H0m3/opensource/logs/Random-Hosts.log`
  115.        echo "" >> $H0m3/opensource/modules/database.db
  116.        echo "" >> $H0m3/opensource/modules/database.db
  117.        echo "|[ $dtr ]|" >> $H0m3/opensource/modules/database.db
  118.        echo "$fill" >> $H0m3/opensource/modules/database.db
  119.        zenity --info --title="T00LKIT DATABASE" --text "Scan Appended to DataBase" --width 300 > /dev/null 2>&1
  120.        chown $usera $H0m3/opensource/modules/database.db > /dev/null 2>&1
  121.        cd ~/opensource
  122.        sh_2menu
  123.  
  124.  
  125.      elif [ "$dbt" = "Clear Database and Append scan" ]; then
  126.        dtr=`date`
  127.        fill=`cat $H0m3/opensource/logs/Random-Hosts.log`
  128.        echo "" > $H0m3/opensource/modules/database.db
  129.        echo "|[ $dtr ]|" >> $H0m3/opensource/modules/database.db
  130.        echo "$fill" >> $H0m3/opensource/modules/database.db
  131.        zenity --info --title="T00LKIT DATABASE" --text "Database clean and\nnew scan Appended" --width 300 > /dev/null 2>&1
  132.        chown $usera $H0m3/opensource/modules/database.db > /dev/null 2>&1
  133.        cd ~/opensource
  134.        sh_2menu
  135.  
  136.  
  137.      elif [ "$dbt" = "Clear Database and manually input" ]; then
  138.        dtr=`date`
  139.        mad=$(zenity --title="INPUT TARGET TO DATABASE" --text "You can input TARGET-IP, NOTES , ETC..." --entry --width 300) > /dev/null 2>&1
  140.        echo "" > $H0m3/opensource/modules/database.db
  141.        echo "|[ $dtr ]|" >> $H0m3/opensource/modules/database.db
  142.        echo "$mad" >> $H0m3/opensource/modules/database.db
  143.        zenity --info --title="T00LKIT DATABASE" --text "Database clean with\nnew Append" --width 300 > /dev/null 2>&1
  144.        chown $usera $H0m3/opensource/modules/database.db > /dev/null 2>&1
  145.        cd ~/opensource
  146.        sh_2menu
  147.  
  148.  
  149. else
  150.  
  151.    Colors;
  152.    echo ${RedF}[x]::[ QUITTING ]${Reset};
  153.    sleep 2
  154.    cd ~/opensource
  155.    sh_2menu
  156. fi
  157. }
  158.  
  159.  
  160. sh_fff () {
  161. Colors;
  162.  
  163.  
  164.        echo ${BlueF}[*]${RedF}::${BlueF}[Please wait]${RedF}::${GreenF}[ BUILDING RC FILE ] ${Reset};
  165.        # generate resource file
  166.        echo "db_import $H0m3/opensource/logs/Random-Hosts.xml" > $H0m3/opensource/logs/msfdb.rc
  167.        echo "hosts" >> $H0m3/opensource/logs/msfdb.rc
  168.        chown $usera $H0m3/opensource/logs/msfdb.rc > /dev/null 2>&1
  169.        sleep 2
  170.  
  171.        echo ${BlueF}[*]${RedF}::${BlueF}[Please wait]${RedF}::${GreenF}[ START MSF SERVICES ] ${Reset};
  172.        # start postgresql+metasploit db
  173.        # /etc/init.d/postgresql start > /dev/null 2>&1
  174.        # /etc/init.d/metasploit start > /dev/null 2>&1
  175.        service metasploit start > /dev/null 2>&1
  176.  
  177.  
  178.        echo ${BlueF}[*]${RedF}::${BlueF}[Please wait]${RedF}::${GreenF}[ START METASPLOIT ] ${Reset};
  179.        # access msfdatabase
  180.        xterm -T "METASPLOIT" -geometry 110x23 -e "sudo msfconsole -r $H0m3/opensource/logs/msfdb.rc"
  181.        sleep 2
  182.  
  183.        clear
  184.        # clear recent files made
  185.        echo ${BlueF}[*]${RedF}::${BlueF}[Please wait]${RedF}::${GreenF}[ CLEANING FILES ] ${Reset};
  186.        rm $H0m3/opensource/logs/msfdb.rc > /dev/null 2>&1
  187.        rm $H0m3/opensource/logs/Random-Hosts.xml > /dev/null 2>&1
  188.        rm $H0m3/opensource/logs/report.log > /dev/null 2>&1
  189.        service metasploit stop > /dev/null 2>&1
  190.        cd ~/opensource
  191.        sh_2menu
  192. }
  193.  
  194.  
  195. #EOF
Advertisement
Add Comment
Please, Sign In to add comment