File: nessus-update-plugins.in

package info (click to toggle)
nessus-plugins 1.0.10-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,924 kB
  • ctags: 408
  • sloc: sh: 7,838; ansic: 3,415; makefile: 233
file content (195 lines) | stat: -rw-r--r-- 3,787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/sh
#
# nessus-update-plugins
#
# This script will retrieve all the newest plugins from 
# www.nessus.org.
#
# NOTE: the use of this script is dangerous as the authenticity of 
#       the scripts is not checked for. USE THIS SCRIPT WITH CAUTION
# 
# 
# Author  : Renaud Deraison <deraison@cvs.nessus.org>
# License : GPL (but for two lines of script, does it matter ?)
# 
#
# usage : nessus-update-plugins [-v]
# 
#
# -l        : list the plugins but do not install them
# -r <name> : read a plugin name
# -v        : be verbose
# -vv       : be more verbose (debug)
#

lynx=@LYNX@
gzip=@GZIP@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
sbindir=@sbindir@
libexecdir=@libexecdir@
datadir=@datadir@
sysconfdir=@sysconfdir@
sharedstatedir=@sharedstatedir@
localstatedir=@localstatedir@
libdir=@libdir@
includedir=@includedir@
oldincludedir=@oldincludedir@
infodir=@infodir@
mandir=@mandir@




help_screen()
{
 echo "nessus-update-plugins 1.0.1, by Renaud Deraison <deraison@cvs.nessus.org>"
 echo
 echo
 echo "Usage : nessus-update-plugins [-v[v]] [-l] [-r name] [-h]"
 echo
 echo "-v              : be verbose"
 echo "-l              : list the plugins available on the server"
 echo "-r <pluginname> : view the content of a plugin"
 echo "-i <pluginname> : only install <pluginname>"
 echo "-h              : this help screen"
 echo
 echo "Default action  : update the nessusd plugins"
 exit 0
}


list_plugins()
{
 if test -n "$lynx" ;
 then
  echo "List of plugins available on www.nessus.org : "
  echo
  $lynx -source http://www.nessus.org/nasl/index.txt
  echo
  echo
 fi
 exit 0
}


view_plugin()
{
 if test -n "$lynx" ;
 then
  $lynx -source "http://www.nessus.org/nasl/$1"
 fi
 exit 0
}

install_plugin()
{
if test -n "$lynx" ;
then
test -f "$libdir/nessus/plugins/$1" && mv "$libdir/nessus/plugins/$1" "$libdir/nessus/plugins/$1.bak"
$lynx -source "http://www.nessus.org/nasl/$1" > "$libdir/nessus/plugins/$1"
grep "404 Not Found" "$libdir/nessus/plugins/$1" 2>&1 > /dev/null && {
	echo "Error - file not found"
	rm -f "$libdir/nessus/plugins/$1"
	test -f "$libdir/nessus/plugins/$1.bak" && mv "$libdir/nessus/plugins/$1.bak" "$libdir/nessus/plugins/$1"
	}
	
# HUP nessusd
test -f @localstatedir@/lib/nessus/nessusd.pid && (
    pid=`cat @localstatedir@/lib/nessus/nessusd.pid`
    kill -1 $pid 2>/dev/null
)
 exit 0

else
echo "Error \$lynx or \$gzip are not set - abort"
exit 1
fi
}


opts=`getopt "vlr:hi:" $*`

for i in $opts
do
 case $i in
 -h )
   help_screen
   ;;
   
  -v)
   if [ -z "$verbose" ];
    then
      verbose="y"
     else
       set -x
   fi
   ;;
   
 -l)
   get_plugin_list="y"
   ;;
 
 -r)
   expect_r="y"
   ;;
   
  -i)
   expect_i="y"
   ;;
    
  *)
   test -n "$expect_r" &&
     {
      plug_name="$i"
      unset expect_r
     }
     
   test -n "$expect_i" &&
     {
      install_plug="$i"
      unset expect_i
     }  
   ;;
 esac
done   



test -n "$get_plugin_list" && list_plugins
test -n "$plug_name" && view_plugin "$plug_name"
test -n "$install_plug" && install_plugin "$install_plug"

tar="--no-same-owner -xf"
test -z "$verbose" || tar="--no-same-owner -xvf"





# make sure that we are root, if there is no id command,
# you loose, anyway
case `id` in uid=0*) ;; *)
    echo "only root should use nessus-update-plugins"
        exit 1
	esac
	
	
if test -n "$lynx" -a -n "$gzip" ;
then
cwd=`pwd`
cd $libdir/nessus/plugins/
$lynx -source http://www.nessus.org/nasl/all-1.0.x.tar.gz | $gzip -cdf | tar  $tar - 
cd "$cwd"
chown 0 $libdir/nessus/plugins/*.nasl
chgrp 0 $libdir/nessus/plugins/*.nasl
# HUP nessusd
test -f @localstatedir@/lib/nessus/nessusd.pid && (
    pid=`cat @localstatedir@/lib/nessus/nessusd.pid`
    kill -1 $pid 2>/dev/null
)
else
 echo "Error \$lynx or \$gzip are not set - abort"
exit 1
fi