#!/usr/bin/perl
# needs root of coiurse

$who =`whoami`;

if ($who !~ /root/){
	print "sorry, need rOOt !\n";
	exit;
}

# vars first
$initd_dir = "/etc/init.d";

# exact names here please

$to_stop0 	= 	"vsftp";		# port 20 / ftp services
$to_stop1	=	 "atd";		# linux socket / sheduled programm execution
$to_stop2 	=	 "apache";	# port 80 / httpd server 
$to_stop3 	=	 "squid";		# port 3128 / squid proxy server
$to_stop4 	=	 "smail";		# port 25 / sendmail
$to_stop5 	=	 "portmap";	# for normal use unessessary rpc services
$to_stop6 	=	 "samba";		# port 445 / samba fileserver 
$to_stop7 	=	 "rsync";		# remote syncronization, very vulnarable
$to_stop8 	=	 "ssh";		# port 22 / openssh server

#$to_stop9 	=	 "";
#$to_stop10 	= 	"";

 if ($to_stop0) {
  	$status = &stop_services_now($to_stop0);
	print "STATUS: $status\n";
  };

 if ($to_stop1) {
  	$status = &stop_services_now($to_stop1);
	print "STATUS: $status\n";
  };  
  
 if ($to_stop2) {
  	$status = &stop_services_now($to_stop2);
	print "STATUS: $status\n";
  };  
  
 if ($to_stop3) {
  	$status = &stop_services_now($to_stop3);
	print "STATUS: $status\n";
  };  
  
 if ($to_stop4) {
  	$status = &stop_services_now($to_stop4);
	print "STATUS: $status\n";
  };
	 
 if ($to_stop5) {
  	$status = &stop_services_now($to_stop5);
	print "STATUS: $status\n";
  };

 if ($to_stop6) {
  	$status = &stop_services_now($to_stop6);
	print "STATUS: $status\n";
  };

 if ($to_stop7) {
  	$status = &stop_services_now($to_stop7);
	print "STATUS: $status\n";
  };

 if ($to_stop8) {
  	$status = &stop_services_now($to_stop8);
	print "STATUS: $status\n";
  };
 
    
sub stop_services_now {

	my $service_to_stop = @_[0];

	print "STOPPING: $service_to_stop\n";
	system("$initd_dir/$service_to_stop stop");
	return "DONE STOPPING: $service_to_stop";
	
}

print "\n\n##########################################\n";
print "### STOPPING PREDEFINDED SERVICES DONE! ###\n";
print "#############################################\n";

return 1;
