Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.44 KB | None | 0 0
  1. # Nessus Automation Wrapper Script v0.1 (c) 2010 Adam Obringer, Robert Morris University
  2. #
  3. # Requirements:
  4. # - Perl
  5. # - update-nessusrc (George A Theall)
  6. # - cron (of course) if you want this to do anything on it's own
  7. # - Linuxy paths for common binaries
  8. # - Tenable Nessus
  9. # - Flat files created for network zones / custom scantypes, etc.
  10. #
  11. # * This is meant to be wrapped around cron to automate Nessus scans via commandline.
  12. # * Updates nessusrc files according to scantype specified and passed to update-nessusrc
  13. # * Calls flat files from input variables, as well as the Nessus binary and update-nessusrc script (George A Theall)
  14. # * Timestamps each completion line for reference via log output to /opt/autoscan/log/ per run
  15. # * Emails results to selected addresses once completed.
  16. # * Create NBE file for Nitro ESM import
  17. # * Create Apache-viewable HTML report
  18. #
  19. # TODO:
  20. #
  21. # - FIX full logging output to file!
  22. # - Add capability for custom network zone
  23. # - Add capability for 'all' zones
  24. # - Add capability for custom scan type
  25. # - Remove HTML reporting/add MySQL archiving and static code to call data
  26. #
  27. #!/bin/sh
  28. DATE=`/bin/date +%Y%m%d`
  29. TIME=$(date +%k%M%S)
  30. NOW=$(date +"%Y-%m-%d_%k.%M")
  31. NCMD=/opt/nessus/bin/nessus
  32. NHOST=localhost
  33. NPORT=1241
  34. NUSER=nessus
  35. NPASS=xxxxxxxxxxx
  36. NCONFIG1=/opt/autoscan/configs/admin_vlans.cfg
  37. NCONFIG2=/opt/autoscan/configs/other_vlans.cfg
  38. NCONFIG3=/opt/autoscan/configs/resnet_vlans.cfg
  39. NCONFIG4=/opt/autoscan/configs/student_vlans.cfg
  40. NCONFIG5=/opt/autoscan/configs/test_vlans.cfg
  41. NTARGET1=/opt/autoscan/targets/targets_admin.txt
  42. NTARGET2=/opt/autoscan/targets/targets_other.txt
  43. NTARGET3=/opt/autoscan/targets/targets_resnet.txt
  44. NTARGET4=/opt/autoscan/targets/targets_student.txt
  45. NTARGET5=/opt/autoscan/targets/targets_test.txt
  46. NRESULT1=/opt/autoscan/results/admin_vlans-$DATE.nbe
  47. NRESULT2=/opt/autoscan/results/other_vlans-$DATE.nbe
  48. NRESULT3=/opt/autoscan/results/resnet_vlans-$DATE.nbe
  49. NRESULT4=/opt/autoscan/results/student_vlans-$DATE.nbe
  50. NRESULT5=/opt/autoscan/results/test_vlans-$DATE.nbe
  51. NREPORT1=/opt/autoscan/reports/admin_vlans-$DATE.html
  52. NREPORT2=/opt/autoscan/reports/other_vlans-$DATE.html
  53. NREPORT3=/opt/autoscan/reports/resnet_vlans-$DATE.html
  54. NREPORT4=/opt/autoscan/reports/-student_vlans-$DATE.html
  55. NREPORT5=/opt/autoscan/reports/test_vlans-$DATE.html
  56. VLANINPUT=$1
  57. RCTOOL=/opt/autoscan/scripts/update-nessusrc
  58. RCINPUT=$2
  59. HTMLOUT=/opt/autoscan/results/
  60. LOGDIR=/opt/autoscan/log
  61. LOGFILE=nessusauto_$VLANINPUT-$NOW.log
  62.  
  63.  
  64. echo ""
  65. echo ""
  66. echo "Nessus AutoScan script v0.1 - (c) Adam Obringer, Robert Morris University"
  67. echo ""
  68. echo "Syntax: $0 <area> <scantype>"
  69. echo ""
  70. echo "Available areas: admin|other|resnet|student|test"
  71. echo "Available scantypes: default|debug|top20|crithigh"
  72.  
  73. if [ $VLANINPUT = admin ] ; then
  74.   echo ""
  75.   echo ""
  76.   echo "$DATE.$TIME x Configuring for admin VLAN scan."
  77.   NCONFIG=$NCONFIG1
  78.   NTARGET=$NTARGET1
  79.   NRESULT=$NRESULT1
  80.   NREPORT=$NREPORT1
  81. elif [ $VLANINPUT = other ] ; then
  82.   echo ""
  83.   echo "$DATE.$TIME x Configuring for other VLAN scan."
  84.   NCONFIG=$NCONFIG2
  85.   NTARGET=$NTARGET2
  86.   NRESULT=$NRESULT2
  87.   NREPORT=$NREPORT2
  88. elif [ $VLANINPUT = resnet ] ; then
  89.   echo ""
  90.   echo "$DATE.$TIME x Configuring for resnet VLAN scan."
  91.   NCONFIG=$NCONFIG3
  92.   NTARGET=$NTARGET3
  93.   NRESULT=$NRESULT3
  94.   NREPORT=$NREPORT3
  95. elif [ $VLANINPUT = student ] ; then
  96.   echo ""
  97.   echo "$DATE.$TIME x Configuring for student VLAN scan."
  98.   NCONFIG=$NCONFIG4
  99.   NTARGET=$NTARGET4
  100.   NRESULT=$NRESULT4
  101.   NREPORT=$NREPORT4
  102. elif [ $VLANINPUT = test ] ; then
  103.   echo ""
  104.   echo "$DATE.$TIME x Configuring for test VLAN scan."
  105.   NCONFIG=$NCONFIG5
  106.   NTARGET=$NTARGET5
  107.   NRESULT=$NRESULT5
  108.   NREPORT=$NREPORT5
  109. else
  110.  echo ""
  111.  echo "*** Syntax error: Please properly specify zone to scan!"
  112.  echo "$0 admin|other|student|test"
  113.  exit 1
  114. fi
  115.  
  116. if [ $RCINPUT = default ] ; then
  117.   echo ""
  118.   echo "$DATE.$TIME x Configuring for default (non-dangerous/icmp/tcp_conn) Nessus plugins (with summary) via nessusrc."
  119.   $RCTOOL -s $NCONFIG
  120. elif [ $RCINPUT = debug ] ; then
  121.   echo ""
  122.   echo "$DATE.$TIME x Configuring for default Nessus plugins with debugging via nessusrc."
  123.   echo "* Warning * Does NOT replace RC file while debugging is enabled!"
  124.   $RCTOOL -s -d $NCONFIG
  125. elif [ $RCINPUT = top20 ] ; then
  126.   echo ""
  127.   echo "$DATE.$TIME x Configuring for SANS Top20 plugins (with summary) via nessusrc."
  128.   $RCTOOL -t -s $NCONFIG
  129. elif [ $RCINPUT = crithigh ] ; then
  130.   echo ""
  131.   echo "$DATE.$TIME x Configuring for Critical/High-risk vulnerabilities ONLY (with summary) via nessusrc."
  132.   $RCTOOL -r "(Critical|High)" -s $NCONFIG
  133. else
  134.   echo ""
  135.   echo "*** Syntax error: Please specify plugin type(s)."
  136.   echo "$0 default|debug|top20|crithigh"
  137.   exit 1
  138. fi
  139.  
  140. echo ""
  141. echo "$DATE.$TIME x Scanning hosts within $VLANINPUT zones via Nessus commandline..."
  142. $NCMD -c $NCONFIG -T nbe -xq $NHOST $NPORT $NUSER $NPASS $NTARGET $NRESULT > $LOGDIR/$LOGFILE
  143. #2>&1
  144. echo ""
  145. echo "$DATE.$TIME x Scan completed."
  146.  
  147. echo ""
  148. echo "$DATE.$TIME x Generating reporting html..."
  149. $NCMD -i $NRESULT -o $NREPORT > $LOGDIR/$LOGFILE
  150. #2>&1
  151. echo ""
  152. echo "$DATE.$TIME x HTML report generation completed. File(s) output to $HTMLOUT for Apache."
  153.  
  154. echo ""
  155. echo "$DATE.$TIME x Emailing results to recipient(s). TEMP DISABLED!"
  156. #cat - $LOGDIR/$LOGFILE << EOF | /usr/sbin/sendmail -t
  157. #to:obringer@rmu.edu,stewartm@rmu.edu
  158. #from:nessus-internal@security.rmu.edu
  159. #subject:Nessus Internal AutoScan Log Output - $VLANINPUT targets
  160. #
  161. #EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement