File: nessus-update-plugins-gpl

package info (click to toggle)
nessus-plugins 2.2.8-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 15,508 kB
  • ctags: 251
  • sloc: sh: 8,346; ansic: 4,452; pascal: 3,089; perl: 704; makefile: 172; php: 1
file content (336 lines) | stat: -rw-r--r-- 6,883 bytes parent folder | download | duplicates (2)
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/bin/sh -e
#
# nessus-update-plugins-gpl
#
# This script will retrieve all the newest GPL 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-gpl [-v] [-r name] [-d dir]
# 
#
# -d <dir>  : use <dir> as the plugin dir
# -r <name> : read a plugin name
# -v        : be verbose
# -vv       : be more verbose (debug)
#



# Proxy users
#
# If you are behind a proxy, you can set this options here
# or in ~/.nessus-update-pluginsrc
#
# If you edit THIS file, then the proxy (and proxy username/password)
# will be system-wide. 

proxy_user=
proxy_passwd=
proxy=
location="http://www.nessus.org/nasl/all-2.0.tar.gz"
location_md5="http://www.nessus.org/nasl/all-2.0.tar.gz.md5"
location_sig="http://www.nessus.org/nasl/all-2.0.sig"

# Examples :
# proxy_user="renaud"
# proxy_passwd="topsecr3t"
# proxy="proxy.fr.nessus.org:8080"
#
# You can copy the lines above and put them
# in your ~/.nessus-update-pluginsrc



#
# The command we use to retrieve the plugins
#
fetch_cmd="@FETCHCMD@"

#
# The arguments of this command :
#    -source for lynx/links
#    -q -O -  for wget
#    -s -o - for curl
# 
fetch_args="@FETCHARGS@"




#-------------- DO NOT EDIT THIS FILE BEYOND THAT POINT ---------------------#



gzip=/bin/gzip
prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
libexecdir=${exec_prefix}/libexec
datadir=${prefix}/share
sysconfdir=/etc
sharedstatedir=${prefix}/com
localstatedir=/var/run
libdir=/var/lib
includedir=${prefix}/include
oldincludedir=/usr/include
infodir=${prefix}/info
mandir=${prefix}/share/man

pluginsdir="$libdir/nessus/plugins"

case `id` in uid=0*) ;; *)
    echo "only root should use nessus-update-plugins-gpl"
        exit 1
	esac
	


if [ ! -r "$sysconfdir/nessus/nessusd.conf" ]; then
	if [ ! -e "$sysconfdir/nessus/nessusd.conf" ]; then
	echo "$sysconfdir/nessus/nessusd.conf does not exist!"
	echo "Do you have the nessus daemon installed?"
	else
	echo "I cannot read $sysconfdir/nessus/nessusd.conf."
	echo "Are you root?"
	fi
	exit 1
fi
newdir=`awk '/plugins_folder/ {print $3}' $sysconfdir/nessus/nessusd.conf`
test -n "$newdir" && pluginsdir="$newdir"



test -z "$fetch_cmd" && {
	echo "\$fetch_cmd not set in $0 - aborting"
	exit 1
	}


fetchprogram=`echo $fetch_cmd | cut -d " " -f 1`
if [ -n "$fetchprogram" -a ! -x "$fetchprogram" ]
then
  echo "The program '$fetchprogram' can not be found or executed"
  echo "Please configure this script by changing the option"
  echo "\$fetch_cmd or by installing $fetchprogram"
  exit 1
fi

#
# Read the configuration file, if any
#
test -f ~/.nessus-update-pluginsrc && . ~/.nessus-update-pluginsrc

help_screen()
{
 echo "nessus-update-plugins-gpl 1.0.6, by Renaud Deraison <deraison@cvs.nessus.org>"
 echo
 echo
 echo "Usage : nessus-update-plugins-gpl [-v[v][-h] [-r name] [-d dir]"
 echo
 echo "-v              : be verbose"
 echo "-vv             : be more verbose (debug)"
 echo "-h              : this help screen"
 echo "-d DIR          : install plugins in DIR"
 echo "-r NAME         : read plugin named NAME"
 echo
 echo "Default action  : update the nessusd plugins"
 exit 0
}



proxyopts=""

echo "$fetch_cmd" | grep "lynx" 2>&1 > /dev/null &&
{
 test -n "$proxy" && http_proxy="http://$proxy/"
 test -n "$proxy_user" && proxyopts="-pauth=\"$proxy_user:$proxy_passwd\""
} 

echo "$fetch_cmd" | grep "wget" 2>&1 > /dev/null &&
{
 test -n "$proxy" && http_proxy="http://$proxy/"
 test -n "$proxy_user" && proxyopts="--proxy=on --proxy-user=$proxy_user --proxy-passwd=$proxy_passwd"
}


export http_proxy

opts=`getopt "vld:r:hi:" $*`

for i in $opts
do
 case $i in
 -h)
   help_screen
   ;;
   
  -v)
   if [ -z "$verbose" ];
    then
      verbose="y"
     else
       set -x
   fi
   ;;
 
 -r)
   expect_r="y"
   ;;

 -d)
   expect_d="y"
   ;;
   
  -i)
   expect_i="y"
   ;;
    
  *)
   test -n "$expect_d" &&
     {
      pluginsdir="$i"
      unset expect_d
     }

   test -n "$expect_r" &&
     {
      plug_name="$i"
      unset expect_r
     }
     
   test -n "$expect_i" &&
     {
      install_plug="$i"
      unset expect_i
     }  
   ;;
 esac
done   



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

tar="-xf"	
test -z "$verbose" || tar="-xvf"



if [ ! -d $pluginsdir ] ; then
	echo "Plugindir $pluginsdir is not a directory!"
	exit 1
fi


	
if [ -n "$fetch_cmd" -a -n "$gzip" ] ;
then
cwd=`pwd`
tmpdir=$TEMPDIR
test -z "$tmpdir" &&
{
 tmpdir=$TMPDIR
 test -z "$tmpdir" && tmpdir=/tmp
}
mkdir "$tmpdir/nessus-update-plugins-$$" || {
	echo "Could not create temporary directory ($tmpdir/nessus-update-plugins-$$)"
	exit 1
}
cd "$tmpdir/nessus-update-plugins-$$"
$fetch_cmd $fetch_args $proxyopts "$location_md5" > all-2.0.tar.gz.md5
test -s "$pluginsdir/MD5" && {
	if [ -x /usr/bin/diff ];
	then 
	 diff "$pluginsdir/MD5"  all-2.0.tar.gz.md5 > /dev/null && {
	 cd "$cwd"
	 rm -rf "$tmpdir/nessus-update-plugins-$$"
	 exit 0
	}
	fi
}
	
$fetch_cmd $fetch_args $proxyopts "$location_sig" > all-2.0.sig
$fetch_cmd $fetch_args $proxyopts "$location" > all-2.0.tar.gz
test -s all-2.0.tar.gz || {
	echo "Downloading http://www.nessus.org/nasl/all-2.0.tar.gz failed"
	cd "$cwd"
	rm -rf "$tmpdir/nessus-update-plugins-$$"
	exit 1
	}

# Check the archive signature
test -x $sbindir/nessus-check-signature && {
	$sbindir/nessus-check-signature all-2.0.tar.gz all-2.0.sig || {
		echo "Aborting"
		exit 1
		}
	}

rm -f all-2.0.sig
	
cat all-2.0.tar.gz | $gzip -cd 2>/dev/null > all-2.0.tar
test $? = 0 || {
 mv all-2.0.tar.gz all-2.0.tar	# Some version of lynx gunzip data on the fly
}
cat all-2.0.tar | tar $tar - 
rm all-2.0.tar
test -s nessus_detect.nasl || {
	echo "Something went wrong when installing the plugins - uncompressing the plugins archive failed"
	cd "$cwd"
	rm -rf "$tmpdir/nessus-update-plugins-$$"
	exit 1
	}
	
find . -name "*.nasl" -exec cp {} "$pluginsdir/" \;
find . -name "*.inc" -exec cp {} "$pluginsdir/" \;


test -d "$pluginsdir/.bin" &&
{ 
 precomp_support=y
 rm -rf "$pluginsdir/.bin"
 mkdir "$pluginsdir/.bin"
}

cp -p all-2.0.tar.gz.md5 "$pluginsdir/MD5"

cd "$cwd"
rm -rf "$tmpdir/nessus-update-plugins-$$"

if [ -x /usr/bin/xargs ];
then
 cd $pluginsdir
 ls | xargs -n 200 chown 0:0 
else
 chown 0:0 $pluginsdir/*.nasl
 chown 0:0 $pluginsdir/*.inc
fi

# Recompile the plugins - Nessus 2.1.x and newer...
test -n "$precomp_support" &&
{
 $sbindir/nessusd -R
}


# HUP nessusd
test -f /var/run/nessus/nessusd.pid && {
    pid=`cat /var/run/nessus/nessusd.pid`
    kill -1 $pid 2>/dev/null
}
 exit 0
else
 echo "Error \$fetch_cmd or \$gzip are not set - abort"
exit 1
fi