Web Hosting Forum | Lunarpages
News:
+ JULY 4th SPECIAL! Get $50 off your new Basic hosting plan purchase!
+ Vote for the  June 2009 Site of the Month!
+ The June 2009 - Issue 21 Edition of the LP Newsletter has been Published!
+ Read the 10 Things Every Lunarpages Customer Should Know!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 04, 2009, 12:14:59 PM


Login with username, password and session length


Pages: 1 [2]   Go Down
  Print  
Author Topic: Files & Folders Monitoring Tool  (Read 1454 times)
SteveW
Master Jedi
*****
Offline Offline

Posts: 1394


WWW
« Reply #15 on: February 07, 2007, 06:02:27 AM »

Thanks for posting that link. It looks interesting. I probably won't follow up much on this until/unless the need arises, which of course I hope and expect it won't.

There's another post-hack solution that might be considerably more time efficient than file comparison: just erase the entire site and republish it. File comparison still might be necessary in that case, though, to look at directories above public_html, which shouldn't be erased because most of their data cannot be restored.

But hey I'm not complaining about the time spent. I got my first intro to Linux shell and learned how to create a cron job.  Applause
Logged





Mt. Shasta
photo gallery.


Don't forget Lunarpages 24/7/365 support documentation:
Flash Tutorials, Knowledge Base FAQ Articles, cPanel Manual, Glossary/Dictionary, Support Tickets,
and
Forum Search.

MrPhil
Professor in Nanotechnology
*****
Offline Offline

Posts: 4020



« Reply #16 on: February 07, 2007, 08:46:13 AM »

To get a complete listing of all the files in your site, you can use this command line with exactly this capitalization:
Code:
ls -1aFlqR

1 = one entry per line
a = all files (including hidden)
F = show file type
l = long form -- the whole kit and caboodle
q = show filenames with nonprintable characters
R = recursively list all directories below this one

Quote from: SteveW
I opted to use the default sort order for the ls command, and NOT sort by last-modified timestamp, because if you're going to compare TWO of these listings, you want the files listed in the exact same order.

Agreed. Don't sort the listing by time -- let it come out in alphabetical order.

ls -t = sort by timestamp
ls -r = reverse order (descending instead of ascending order)

Quote from: SteveW
Now that I have the file listing I need, I don't plan to run this cron job at any specified interval such as to discover a hack. I figure the fact that a hack has taken place will be obvious enough that one doesn't need to hunt for it. This listing is only for identifying suspicious files to examine after you know a hack has occurred.

I disagree. There have been many reports of hacked pages and scripts which don't reveal themselves in obvious manners. Someone may be using your site and account to spam, or put in lots of invisible links to porn sites to boost their Google rankings. Even if nothing odd seems to be happening, it's best to review your site on a regular basis.

Quote from: SteveW
Here are some sample output lines:

Code:
drwx--x--x  497 root     root        12288 Feb  5 00:06 ../
drwxrwx---    3 UserID   mail         4096 Feb  3 11:20 mail/
drwxr-x---    3 UserID   UserID       4096 Jan  6  2006 public_ftp/
drwxr-x---   33 UserID   nobody       4096 Feb  5 20:51 public_html/

The first character is the file type, "-" for file, "d" for directory, "l" for link. The remaining 9 characters are the permissions levels.

rwx are read, write, and execute permission. - means this group does not have this particular permission.
The three groups are owner (your) permissions, your group's permissions, and world (everyone else's) permissions. Sometimes referred to as user, group, and other.

Quote from: SteveW
I don't know what the 2nd column is.

The number of internal hard links to this file or directory. This listing appears to be at the level /home/<account name>/, so .. is /home and that's going to have links to it from every account on this system (several hundred) plus any other stuff under /home. A directory will have a hard link from every file and directory directly under it.

Quote from: SteveW
The 3rd and 4th columns must have to do with who created the file or who owns it or who last modified it?

The owner ID and the group ID of the directory or file.

Quote from: SteveW
The next column is the file size, then the month and day. The next column will be a misery for a database import: it's the last-modified timestamp unless it's old, in which case it's the year!

Good point. At some point (6 months?) the date/time stamp format changes over to lose the time and gain the year. Incidentally, this timestamp is by default the time the directory or file was last modified.

ls -u = display last access timestamp.

Quote from: SteveW
The last column is the file name, followed by a "/" if it's a directory rather than a file.

The -F flag tells ls to add / for directories, * for executables, and maybe other stuff (@ for soft links?). Omit the -F flag to get just the name.
Logged

Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC

2009 © Lunarpages.com
Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM