Results 1 to 10 of 10
  1. #1
    Join Date
    May 2003
    Posts
    852

    Arrow 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

  2. #2
    Join Date
    Jun 2006
    Location
    Cluj Napoca
    Posts
    469
    1. find /home -perm 777
    2. find /home -type d -name support
    add a cron to run every 24 hours and will e-mail you
    IntoDNS - Check your DNS health and configuration
    FLEIO - OpenStack billing and control panel for service providers

  3. #3
    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

  4. #4
    Join Date
    May 2003
    Posts
    852
    Thanks guys

    david510
    Could you please explain each line

  5. #5
    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 it
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  6. #6
    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 ?

  7. #7
    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 ??

  8. #8
    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 tfolder
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  9. #9
    Join Date
    May 2003
    Posts
    852
    thank you foobic very much

  10. #10
    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 !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •