hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : grep and hacked files
Reply

Hosting Security and Technology Configuring and optimizing web hosting servers and operating systems, developing administration scripts, building servers, protecting against hackers, and general security (SSL certificates, etc.)
Forum Jump

grep and hacked files

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 01-07-2005, 12:18 AM
Linda_MBS Linda_MBS is offline
Junior Guru Wannabe
 
Join Date: Jun 2004
Posts: 33

grep and hacked files


With the recent PHPbb troubles,some of the nice folks on one of our servers got hit with a nice index replacement page by a hacker. I could go thru all the accounts manually and delete this file, but that would take hours.

I recall seeing something somewhere that I could grep for something specific in the file and then mass delete the returned files, but I cant recall exactly what it was I needed to do.

Any help?

Reply With Quote


Sponsored Links
  #2  
Old 01-07-2005, 02:42 AM
Techark Techark is offline
Web Hosting Master
 
Join Date: Apr 2002
Location: Australia or US depends
Posts: 5,723
for i in `locate nameoffile.html`; do if grep "whatever you need to grep for" $i > /dev/null; then rm -f /home/nameoffiletodlete $i; echo hacked: $i; fi; done


This should do it just replace the correct grep text and name of file to delete and serach for.

Might want to run updatedb before so the locate database is up to date.

__________________
Techark Web Hosting
Cloud Servers and Managed Dedicated Servers with Live Proactive Monitoring
My Blog of Random Thoughts

Reply With Quote
  #3  
Old 01-07-2005, 02:53 AM
error404 error404 is offline
Web Hosting Master
 
Join Date: Dec 2004
Location: Canada
Posts: 1,076
Use find instead of locate in that script. locate will never be totally up to date, and missing a file could be painful in this case.

Something like 'find / -iname nameoffile.html' instead of the locate command.

__________________
>> Keenan Tims
█▓▒░ I am currently looking for full-time work in the Vancouver area. Resume ░▒▓█
http://www.gotroot.ca/ | ktims@gotroot.ca | skype: keenan.tims

Reply With Quote
Sponsored Links
  #4  
Old 01-07-2005, 05:05 AM
Cirrostratus Cirrostratus is offline
Web Hosting Master
 
Join Date: Jul 2003
Location: Texas
Posts: 785
grep -R 'IamWormKeyword' /path/to/vhosts/ >> /tmp/infected.txt

Then view /tmp/infected.txt for all the hits.

That will grep ALL contents of ALL the files recursively under /path/to/vhosts and look for the keyword you specify and then dump the results in the text file.

From there you can open the files manually and fix them.

Thanks

Jeremy

Reply With Quote
  #5  
Old 01-07-2005, 12:06 PM
bitserve bitserve is offline
Web Hosting Master
 
Join Date: Nov 2001
Location: Ann Arbor, MI
Posts: 2,978
find / -type f -exec grep -l foo {} \; | xargs rm

Although you'd probably want to do this to be more careful:

cd /home (or dir where web docs are stored under)
find . -type f -exec grep -l foo {} \; | xargs -l -p rm

__________________
-Mark Adams
www.bitserve.com - Secure Michigan web hosting for your business.
Only host still offering a full money back uptime guarantee and prorated refunds.
Offering advanced server management and security incident response!

Reply With Quote
  #6  
Old 01-07-2005, 02:20 PM
Linda_MBS Linda_MBS is offline
Junior Guru Wannabe
 
Join Date: Jun 2004
Posts: 33
Will any of these work server wide?

Reply With Quote
  #7  
Old 01-07-2005, 06:16 PM
bitserve bitserve is offline
Web Hosting Master
 
Join Date: Nov 2001
Location: Ann Arbor, MI
Posts: 2,978
Techark's and my first example both work "server wide". While my second example and jeremy's example both use the more practical approach of only running it in the directory likely to contain index files. Based on your question, I'd recommend jeremy's approach, as it won't actually be harmful if you make a mistake.

__________________
-Mark Adams
www.bitserve.com - Secure Michigan web hosting for your business.
Only host still offering a full money back uptime guarantee and prorated refunds.
Offering advanced server management and security incident response!

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
cPacket Launches SPIFEE for Service Providers to Detect Network Performance Issues Web Hosting News 2013-01-28 16:21:35
Parallels Plesk Panel Vulnerability Revealed by Hacker Selling Exploit Web Hosting News 2012-07-11 10:34:13
Whistleblower Site Cryptome Hacked, Infects PCs with Drive-By Exploits Web Hosting News 2012-02-14 14:48:24
Bangladeshi Hacker TiGER-M@TE Targets InMotion Hosting Web Hosting News 2011-09-26 15:24:05
South Korean Domain Registrar Gabia, Epson Korea Websites Hacked Web Hosting News 2011-08-24 14:04:01


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?