HELP!! My website is getting redirected to porn!!

Discussion in 'Programming' started by gerryt, May 8, 2009.

  1. #1
    I just got notified by google that they would stop serving ads to my webpage appyshackdotcom/all-searches.php
    I went there and the page automaticly gets redirected to a sex cam website.
    I've gone in and looked at the code and could'nt find anything.
    Can anyone give me a clue where to find the code and how they got in?
    Thanks
     
    gerryt, May 8, 2009 IP
  2. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #2
    I just came across this code in a "function.php" file
    I think this may be the problem?
    If so, what part of it can I delete without messing up my site?
    Thanks
    <?php
    //rewrite link
    function changeURL($var_link) {
    	$var_link = str_replace("-","_-_",$var_link);
    	$var_link = str_replace(" ","-",$var_link);
    	$var_link = str_replace("'","",$var_link);
        $var_link = str_replace("?","_qq_",$var_link);
        return $var_link;
    }
    
    function reverseURL($var_link) {
    	
    	$var_link = str_replace("_qq_","?", $var_link);
        $var_link = str_replace("_-_","&ddaasshh;", $var_link);
    	$var_link = str_replace("-"," ",$var_link);
    	$var_link = str_replace("&ddaasshh;","-",$var_link);
    	return $var_link;
    }
    
    //CHECK HOTORNOT ADMINISTRATOR LOGIN
    
    function chk_admin_login()
    
    {
    
            global $admin_user,$admin_pass;
    
            if($_SESSION['ADMINUID']!=$admin_user || $_SESSION['ADMINPASSWORD']!=$admin_pass)
    
            {
    
                    header("Location:login.php");
    
                    exit;
    
            }
    
    }
    
    function find_cat_name($id)
    
    {
    
            $sql="select catname from category where cat_id=$id";
    
            $rs=mysql_query($sql);
    
            $row=mysql_fetch_array($rs);
    
            return $row[catname];
    
    }
    
    function find_item_name($id)
    
    {
    
            $sql="select cat_id,title from recipes where id=$id";
    
            $rs=mysql_query($sql);
    
            $row=mysql_fetch_array($rs);
    
            $list[0]=$row[title];
    
            $list[1]=$row[cat_id];
    
            return $list;
    
    }
    
    ?>
    
    Code (markup):
     
    gerryt, May 8, 2009 IP
  3. webdesigners

    webdesigners Banned

    Messages:
    534
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #3
    You should check you .htaccess first there you might get the link of the site where your site is getting redirected. Just remove that bad link from .htaccess. If you need more help than contact me.
     
    webdesigners, May 8, 2009 IP
  4. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Here is the code from my htaccess
    Nothing really looks malicious in there...
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    
    RewriteRule ^([^\/]*)-c([^\/]*)/$ items.php?catid=$2&catname=$1 [L]
    
    RewriteRule ^([^\/]*)-r([^\/]*).html$ item_detail.php?itemid=$2 [L]
    
    RewriteRule ^([^\/]*)-search.html$ search-results.php?keyword=$1 [L]
    
    
    
    
    <Files 403.shtml>
    order allow,deny
    allow from all
    </Files>
    
    deny from 24.108.11.226
    deny from 70.64.128.254
    deny from 208.98.216.12
    deny from 75.101.143.129
    
    Code (markup):
     
    gerryt, May 8, 2009 IP
  5. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #5
    SOLVED!!
    The offending website had typed some code into my search box and it had caused my "all searches" page to refresh and redirect to the webcam site.
    I simply deleted the posts from my database.
    Thanks to all that had a look for me :)
     
    gerryt, May 8, 2009 IP
  6. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sounds like you need to sanitize your database inputs.
     
    kblessinggr, May 8, 2009 IP
  7. Sadi

    Sadi Greenhorn

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #7
    Filter the user input. Do not trust the input without proper filter. I think it was a sort of XSS attack.
     
    Sadi, May 9, 2009 IP
  8. monster64

    monster64 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    It sounds like they just injected via your search bar. You should make sure they didn't get a shell installed.
     
    monster64, May 11, 2009 IP
  9. gerryt

    gerryt Active Member

    Messages:
    374
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #9
    Is there some sort of code (filter) I can include on my "all searches" page that would prevent this from happening again?

    How can I tell if a "shell" got installed?
    I'm not even sure what a shell is ...:eek:
     
    gerryt, May 12, 2009 IP
  10. .htaccess

    .htaccess Peon

    Messages:
    277
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Check your site for some codes like javascripts, few Ad companies do such stupid stuff.
    Try removing all advertisments and scripts from your site coding.
     
    .htaccess, May 12, 2009 IP
  11. monster64

    monster64 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    A shell gives the hacker remote access to your server and files. They are usually uploaded and installed when a security flaw is discovered in a web server. You should find an anti-virus program with real time file system monitoring. It will pick up any shells they try to install and instantly delete them. If you don't have root access to the server, talk to your host to see what they can do.
     
    monster64, May 12, 2009 IP
  12. mstisay

    mstisay Peon

    Messages:
    59
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I had something like that happened to me before, No one would help me so i wiped out my entire site. Good thing you found yours :)
     
    mstisay, May 13, 2009 IP
  13. rakesh_kpn

    rakesh_kpn Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Check your PC for viruses. Normally it will write a script to your local html pages and webfiles. once you upload this files to your hosting server it will start redirecting. I have experienced this. please check the files you recently uploaded also check your PC for viruses.
     
    rakesh_kpn, May 15, 2009 IP
  14. crane

    crane Peon

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    your site security is very poor it seems, upgrade it first, use good filters to scan user requests...
     
    crane, May 17, 2009 IP
  15. lifesgood

    lifesgood Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    If you want to learn more about what they did..learnphponline.com/security/sql-injection-prevention-mysql-php
     
    lifesgood, May 17, 2009 IP
  16. boxieblue

    boxieblue Peon

    Messages:
    486
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    0
    #16
    wow i never knew they could inject code thru search bars :eek: i will look out for such things.
     
    boxieblue, May 17, 2009 IP
  17. Arionix

    Arionix Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Little bobby tables can make such a mess.
     
    Arionix, May 19, 2009 IP