Results 1 to 10 of 10
Thread: How to (small security script)
-
08-31-2007, 02:27 PM #1Web Hosting Master
- Join Date
- May 2003
- Posts
- 852
How to (small security script)
hello
How to do this
The server scan the /home directory
1) List all folders/files with permission 777
2) List all folders with name of upload
and send the result as a notification email
lets say every 24 hours
server CPANEL/WHM
-
08-31-2007, 02:58 PM #2Web Hosting Evangelist
- Join Date
- Jun 2006
- Location
- Cluj Napoca
- Posts
- 469
-
08-31-2007, 02:58 PM #3Web Hosting Master
- Join Date
- Oct 2004
- Location
- Kerala, India
- Posts
- 4,771
Make a file named /root/check.sh, chmod it to 755. Enter the following code into it. Set a cron to run this file every 24 hours.
* 2 * * * sh /root/check.sh
Code:#!/bin/sh cd /home/ find . -type d -perm 777 > /root/files_dirs find . -type f -perm 777 >> /root/files_dirs find . -name upload > /root/upload1 cat /root/files_dirs | mail -s "Permissions 777" mail -s user@domain.com cat /root/upload1 | mail -s "Folders named Upload" mail -s user@domain.com
David | www.cliffsupport.com
Affordable Server Management Solutions sales AT cliffsupport DOT com
CliffWebManager | Access WHM from iPhone and Android
-
08-31-2007, 03:15 PM #4Web Hosting Master
- Join Date
- May 2003
- Posts
- 852
Thanks guys
david510
Could you please explain each line
-
08-31-2007, 03:20 PM #5Web Hosting Master
- Join Date
- Oct 2004
- Location
- Kerala, India
- Posts
- 4,771
enter into /home
find directories with permission 777
append to a file
find files with permission 777
append to same file
find files with name upload
append to another file
show the first file contents and mail those contents to user@domain.com
show the second file contents and mail to user@domain.com
Thats itDavid | www.cliffsupport.com
Affordable Server Management Solutions sales AT cliffsupport DOT com
CliffWebManager | Access WHM from iPhone and Android
-
08-31-2007, 03:30 PM #6Web Hosting Master
- Join Date
- May 2003
- Posts
- 852
Great
what if I want to search for more then one folder
like upload , hacker , ssh
and all will be appended in /root/upload1 ????
and how to ignore some files and folder off 777 under some directories like
.cpan
cpapachebuild
src
??
one more question
the created files will it be overwritting after 24 hours ?
or should I add rm -rf XXXXX at the end of the script ?
-
08-31-2007, 06:34 PM #7Web Hosting Master
- Join Date
- May 2003
- Posts
- 852
all questons above has been answered
but one more to go
cd /home
find . -type d -perm 777 > /root/xfile
it will find all folders with 777 permission and list it in xfile
ok how can I ignore some folders from getting scand and typed in xfile
for example
I trust folder (tfolder) and it has 777 permission
how can I make it ignored from appearing in xfile ??
-
08-31-2007, 09:54 PM #8Retired Moderator
- Join Date
- Feb 2005
- Location
- Australia
- Posts
- 5,849
find . -type d -perm 777 |egrep -v "/tfolder|/othertfolder" > /root/xfile
Edit: this would be safer:
find . -type d -perm 777 |egrep -v "/path/to/tfolder|/path/to/othertfolder" > /root/xfile
since the first would hide all folders called tfolderChris
"Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter
-
09-01-2007, 12:17 AM #9Web Hosting Master
- Join Date
- May 2003
- Posts
- 852
thank you foobic very much
-
09-01-2007, 05:18 PM #10Newbie
- Join Date
- Sep 2005
- Posts
- 18
Canibal
check this, all what you've been asking for
http://www.webhostingtalk.com/showthread.php?t=632387█ www.alrutani.com
█ Alrutani Web Hosting
Find your self in alrutani web hosting
It's more then a host, it's a network of minds !!