Current location: Hot Scripts Forums » Advertising Forums » Job Offers & Assistance » Looking for a bash script that can scan for specific words in specific files/directories.


Looking for a bash script that can scan for specific words in specific files/directories.

Reply
  #1 (permalink)  
Old 05-17-09, 10:23 AM
KuJoe KuJoe is offline
Newbie Coder
 
Join Date: Apr 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Arrow Looking for a bash script that can scan for specific words in specific files/directories.

I currently own and manage a free web hosting site and we take a proactive approach to dealing with illegal content. We are looking for a less intrusive and less time consuming method to do this and so far our best option is to have a shell script to scan our servers /home/ directory looking in only the user's public_html directory within .php and .htm* files. Here is the current code that was provided from a user at Web Hosting Talk - The largest, most influential web hosting community on the Internet

Code:
#!/bin/bash
FINDBIN=/usr/bin/find
EGREPBIN=/bin/egrep
BADWORDS="shell_exec|nulled|ddos|phish|warez|divx"
$FINDBIN /home/ -iname \*.php -o -iname \*.htm -o -iname \*.htm* -type f -exec $EGREPBIN -i -H $BADWORDS {} \;
This script works great, except that certain keywords are returning a lot of results from user's /tmp/ directories and such. It would be an added bonus if the results could be somewhat formatted and sent via e-mail so that we could run this as a daily cron, but that is not required.

Payment for your help is possible based on the code and timeframe. Future projects my also be available.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-17-09, 11:26 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You could pipe the $FINDBIN through mail, like so:

set $FINDPARMS to the parameters you want to send to find

$FINDBIN $FINDPARMS | mail -s "FINDBIN OUTPUT" email@domain.com

To exclude some directories, you may be able to use -regex. I haven't worked with this, but it looks promising.

-regex pattern
File name matches regular expression pattern. This is a match on the whole path, not a search. For example, to match a file named './fubar3', you can use the regular expression '.*bar.' or '.*b.*3', but not 'f.*r3'. The regular expressions understood by find are by default Emacs Regular Expressions, but this can be changed with the -regextype option.

-regex "^/tmp"

Formatting opportunities could be achieved with the following commands:

sort, cut, awk and sed

Great resource bash commands - Linux MAN Pages

This the line I use to see what files have been created or modified on my server in the past 24 hours. Maybe it can help you as well.

find $HOME/public_html -mtime 0

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks

Tags
bash, request, shell


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
Need Help Finding a Specific Script Blackadder Script Requests 5 04-06-05 04:42 PM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 01:12 AM
Simple but specific forum script wanted cat Script Requests 9 06-01-04 03:54 AM
Looking for a specific script or clone development css Script Requests 2 12-09-03 05:56 AM


All times are GMT -5. The time now is 02:08 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.