1002/ 0040755 0001750 0001750 00000000000 07226710053 011324 5 ustar rreames rreames 1002/ogormanl1.txt 0100744 0001750 0001750 00000002061 07167445110 013764 0 ustar rreames rreames Listing 1 #!/bin/csh # # Viagra for BSD # # A simple little csh script for keeping services up and # at the ready on a BSD system. Taken from Unix Guru # Universe (http://www.ugu.com), then hacked together # to run on BSD and given a little bit more versatility by # James O'Gorman (jameso@elwood.net). # # Define the process to look for foreach DAEMON ( inetd apache ) # Look for the process and send any output to /dev/null ps -cax | fgrep "$DAEMON:t" | cut -c27-80 > /dev/null # If the process is not running, start it and give me # the date and time that it happened if ( $status > 0) then echo "Restarting $DAEMON" date # Have a dir with scripts named the process name that # you are watching for, the scripts in there will # restart the process. It is up to you to write the # scripts and make them start the app correctly. But, # that is not so hard now is it? We do this so that # we have a bit more control over how the process starts. /root/scripts/start/$DAEMON & # And end the script endif end 1002/petersenl1.txt 0100744 0001750 0001750 00000001424 07173615776 014167 0 ustar rreames rreames Listing 1: listmaker.pl #!/usr/bin/perl ## This script takes an outlook mail list and saves it ## as a mail list for sendmail. Actually, this will work ## for any list that has the email at the end of each ## line. ## Make sure the alias is in the ## /etc/aliases file and you ran 'newaliases'! ## The input is stdin, the output is stdout use strict; while (<>) { # read each line from STDIN to $_ chop; # take EOL off if ($_ eq "") { next; } # no blanks if ($_ !~ /\@/) { next; } # don't count stuff without an email address if ($_ =~ ":") { next; } # don't parse header information /.+\W(.+\@.+)/; # get the email address print "$1\n"; # print the email address #print "$_\n"; # debugging - print the whole line } 1002/hol1.txt 0100744 0001750 0001750 00000002422 07201611576 012731 0 ustar rreames rreames Listing 1 chk-sshd.pl - Perl script that starts sshd if it's not currently running 01: #!/usr/bin/perl -w 02: 03: ########################################### 04: ## this is the process we are looking for 05: ## (your server may be different) 06: ########################################### 07: $ps_entry = "/usr/local/sbin/sshd"; 08: 09: ########################################### 10: ## this is the path to sshd, depends on 11: ## your setup, it might be different. 12: ########################################### 13: $sshd_path = "/usr/local/sbin/sshd"; 14: 15: ########################################### 16: ## use the ps command to get a list of 17: ## the processes currently running 18: ########################################### 19: @processes = `ps ax`; 20: 21: $n = @processes; 22: $is_running = 0; 23: 24: for ($i=0; $i<$n; $i++) { 25: if ($processes[$i] =~ /$ps_entry/) { 26: $is_running = 1; 27: } 28: } 29: 30: ########################################### 31: ## if sshd is not currently running, then 32: ## start it now. 33: ########################################### 34: if (not $is_running) { 35: `$sshd_path &`; 36: } 1002/pardol1.txt 0100744 0001750 0001750 00000007057 07205007652 013437 0 ustar rreames rreames Listing 1: antivirus.pl #!/usr/bin/perl use CGI; use Mail::Sendmail; use Socket; use Sys::Hostname; $query=new CGI; print $query->header(); print $query->start_html("Antivirus service"); print ''; print '
'; my $hostname = gethostbyaddr(inet_aton($query->remote_host()),AF_INET); $hostname=~s/.enpl.es//; $hostname=uc($hostname); print $query->h1(""; } close FILE; print $query->hr; print $query->start_form; if($query->param()) # We come from the submit button, we start the whole process { # We've got $hostname, and $query->param('Shares'), $query->param('email') # We don't need anything more to start the job # We have to use smbmount to mount /mnt/smb/$hostname/$share my $share; my $email; my $time; $share=$query->param('Shares'); $share=~s/^( |\t)+//g; chop($share); $share=~s/ //g; $email=$query->param('email'); if (!($email=~/[a-z-A-Z-0-1]+\@enpl.es/)) { print "Error: Invalid e-mail address: $email"; exit(-1); } # We create the dir. where we'll mount the client share mkdir "/mnt/smb/$hostname",500; mkdir "/mnt/smb/$hostname/$share",500; open FD, ">/tmp/atjob.$hostname.$share" || die "Can't create temp file"; print FD "/usr/bin/smbmount //$hostname/$share /mnt/smb/$hostname/$share -N > /dev/null \n"; print FD "/usr/local/bin/uvscan -c -r /mnt/smb/$hostname/$share |mail -s \"Antivirus Report\" $email \n"; print FD "/usr/bin/smbumount /mnt/smb/$hostname/$share\n"; # We remove the directory in two steps, just in case print FD "rmdir /mnt/smb/$hostname/$share\n"; print FD "rmdir /mnt/smb/$hostname\n"; close FD; chmod 500,"/tmp/atjob.$hostname.$share"; if ($query->param('ScanNow') eq 'on') { $time='now'; print "You'll receive an e-mail report in a while."; } else { $time='23:00'; print "Ready
Remember to leave the computer on tonight...";
}
system ("at $time -f /tmp/atjob.$hostname.$share");
# sleep(5);
print $query->end_form;
print $query->end_html;
}
else
{
# No parameters
my @shares;
open (FILE,"/usr/local/samba/bin/smbclient -L $hostname -U nobody%nopass |grep Disk| cut -f 1 -d \" \" |");
while ( ";
print '';
}
else
{
print "Select the resource: " . $query->popup_menu('Shares',\@shares) . "
" . $query->submit(-name=>'Start');
}
print $query->end_form;
print $query->end_html;
}
1002/bennl1.txt 0100744 0001750 0001750 00000001767 07205012442 013247 0 ustar rreames rreames Listing 1: Example CGI Script that runs a whois query
#!/usr/bin/perl
# Get the value of the QUERY_STRING environment variable, which is set by the
# web server to the value of the query string portion of the URI.
$querystring = $ENV{'QUERY_STRING'};
# Separate the key=val pairs into tokens. They are delimited by &.
@qs = split (/&/, $querystring);
# Split each of the key=val pairs and save in a hash, keyed by key.
foreach $i (0 .. $#qs)
{
# Convert plus to space, and convert %hh to the real value.
$qs[$i] =~ s/\+/ /g;
$qs[$i] =~ s/%(..)/pack("c",hex($1))/ge;
# Now, split along the =.
($key, $val) = split (/=/, $qs[$i], 2);
# Save in hash.
$param{$key} = $val;
}
# Get the value of the 'parm' key.
$parm = $param{'parm'};
# Since this CGI script is outputting plain text tell the browser
# to expect plain text.
print "Content-type: text/plain\n\n";
# Run a whois query.
print `/bin/whois $parm`;
# Done!
exit;
# Untaint $val since it's going to be passed to the shell. The regular
# expression match being performed here returns TRUE only if $val
# consists entirely of these characters: A-Z, a-z, # -, @, and '.'.
# If $val consists entirely of these characters, then $1 is set by the
# regular expression match to the value that matched. Since $1 is the
# result of a regular expression match, it is considered "laundered".
# Set $val to $1, and now $val is laundered.
#
if ($val =~ /^([\w+\-@\.]*)$/)
{
$val = $1;
}
else
{
die "Bad value for parm = $val";
}