PDA

View Full Version : listing files by date modified



pghcollectibles
05-23-2009, 12:06 AM
i would like to know how i can do that to see all my files. will that need to be done with ssh? is there a cli for listing any file modified after a certain date/time? my files may have been compromised and that would be the easiest way for me to determine which ones may have been tampered with

anonymous
05-23-2009, 09:10 AM
i would like to know how i can do that to see all my files. will that need to be done with ssh? is there a cli for listing any file modified after a certain date/time? my files may have been compromised and that would be the easiest way for me to determine which ones may have been tampered with

unix FIND command. use -mtime switch

stamat
05-23-2009, 10:42 AM
find folder -mtime -1

this command will find all files in given folder, which have been modified within 24 hours from now. (-2 for two days and so on). If you use -ctime (creation time) then it will find files created within given period. It will go to sub folders also.

I think that you must use ssh in order to execute find or other linux commands, or maybe create perl or php script to that for you (via exec(), system() or passtrough() functions - in php).

I could create PHP script, if you like, which will list all files modified within given period and output it in HTML, so you can place it somewhere on your website (in password protected folder) and view it from browser.

Regards

pghcollectibles
05-23-2009, 11:05 AM
if its something that wont take you too long, that would be cool. i started working on a file browsing script a while ago but it only involved listing files that existed.

stamat
05-23-2009, 02:45 PM
Here is PHP script for finding files modified within last few days.

Extract zip file in some folder on your account (accessible through one of your domains).
When you access that folder from browser, you will be able to chose from which folder to start the search, and within how many days they were modified.

I tested it on my domain and it seems to work fine, but I had no time for detailed tests.
You should know that this script will go through all sub folders in specified folder (including through links). If you have great number of files on your account this script should be modified.

I can additionally modify this script if you need it to provide more info.

In index.php (on top) you can find two variables:
$GLOBALS["start_folder"] = "./";
$Days = ($_POST["days"]) ? $_POST["days"]: "2";
first one is start folder. And number "2" at the end of second line is default number of days. You can modify these parameters to your needs.

This script will go trough ANY folder you specify on your account (if it exists). Even below public_html/, so you should not allow access to it to anyone but you (password protect its folder).

Regards.