I'm Brady Redfearn, IT Guru, proper petrol head, and family man. I'm not a regular blogger, but I do post things online occasionally.
Wednesday, March 24, 2010
Monday, March 22, 2010
Saturday, March 20, 2010
Friday, March 19, 2010
Thursday, March 18, 2010
Wednesday, March 17, 2010
Tuesday, March 09, 2010
Monday, March 08, 2010
Saturday, March 06, 2010
Wednesday, March 03, 2010
Monday, March 01, 2010
Perl Administration
I'm not sure if this works, so let me know:
#!/usr/bin/perl -w
# Brady Redfearn, IT-344, Security Scan
# Code courtesy of Googling the Internet
# include mailer program
use Mail::Mailer;
# Variables
@array = (`ls -l`);
# email default string:
sub sendEmail{
# email fields
($to, $from, $subject, $body) = @_;$mailer = new Mail::Mailer->new();$mailer -> open({From => $from,To => $to,Subject => $subject,});print $mailer $body;$mailer -> close() or die "Couldn't send the message $!\n";}
# loop
foreach(@array){
$file = $_;
# Parses through the string and the portions within the parameters are saved
if($file =~ /(.)(...)(...)(...)\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+\S+\s+\S+\s+(\S+)/){
$group = $3;
$anyone = $4;
$group_per = $5;
$owner_name = $6;
$file = $7;
$user = $ENV{"USER"};
# File has been found
if(($group =~ m/(x|r|w)/)&&$anyone =~ m/(x|r|w)/){
$output = "A security issue has been detected:
File $file owned by $owner_name has $group permissions available to the group $group_per and has $anyone world permissions\n";
sendEmail("$user\@localhost","security\@localhost","Security problems detected",$output);
} # if ends
# another file
elsif($group =~ m/(x|r|w)/){
$output = "A security issue has been detected:
File $file owned by $owner_name has $group permissions available to the group $group_per and has $anyone world permissions\n";
sendEmail("$user\@localhost","security\@localhost","Security problems detected",$output);
} # else-if ends
# another file
elsif($anyone =~ m/(x|r|w)/){
$output = "A security issue has been detected:
File $file owned by $owner_name has $group permissions available to the group $group_per and has $anyone world permissions\n";
sendEmail("$user\@localhost","security\@localhost","Security problems detected",$output);
} # else-if ends
} # if statement
} # foreach loop