Webmasterpals  

Go Back   Webmasterpals > Site Management > Website Programming

Reply
 
Thread Tools Display Modes
  #1  
Old 01-29-2010, 03:43 PM
DAVID87 DAVID87 is offline
Junior Member
 
Join Date: Jun 2009
Posts: 21
DAVID87 is on a distinguished road
Default Code Injection

Hi All,

I am having a bit of trouble at the moment with some code injection. I had some trouble before with a code that was being injected into my pages on my website and it was adding a line to the bottom of any page with name of index or home.

I cured this by adding "mysql_real_escape_string" on all of my input fields and also as a precaution changed my homepage from the default name to something else so I am not using index or home.

Now I am getting someone, somehow modifying all of my ".js" files in different directories and adding a lie of code at the end of them which redirects my site else where.

can anyone give me any pointers on how I can stop this and cure it??

Thanks in advance

David
Reply With Quote
  #2  
Old 01-29-2010, 06:27 PM
pbu's Avatar
pbu pbu is offline
Administrator
 
Join Date: Feb 2008
Location: hrwebdir.org
Posts: 1,081
pbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond repute
Default Re: Code Injection

it could be xss injection. make sure you filter all GET and POST variables using filter() function.
PHP Code:
function filter($data) {
    
$data trim(htmlentities(strip_tags($data)));
    
    if (
get_magic_quotes_gpc())
        
$data stripslashes($data);
    
    
$data mysql_real_escape_string($data);
    
    return 
$data;

Reply With Quote
  #3  
Old 01-29-2010, 08:00 PM
DAVID87 DAVID87 is offline
Junior Member
 
Join Date: Jun 2009
Posts: 21
DAVID87 is on a distinguished road
Default Re: Code Injection

Thanks pbu.

I have just tested on one page of my site and I can get this working. I will work on getting it on all my script pages now. Hopefully if I monitor this over the next few days it should be the fix I am looking for.

Thanks again.
Reply With Quote
  #4  
Old 01-29-2010, 09:49 PM
pbu's Avatar
pbu pbu is offline
Administrator
 
Join Date: Feb 2008
Location: hrwebdir.org
Posts: 1,081
pbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond reputepbu has a reputation beyond repute
Default Re: Code Injection

dont forget - to filter all GET/POST at once, use this loop

PHP Code:

foreach($_POST as $key => $value) {
    
$data[$key] = filter($value);

Reply With Quote
  #5  
Old 01-29-2010, 10:57 PM
DAVID87 DAVID87 is offline
Junior Member
 
Join Date: Jun 2009
Posts: 21
DAVID87 is on a distinguished road
Default Re: Code Injection

Im guessing that the below id just for the post values.

PHP Code:
foreach($_POST as $key => $value) {
    
$data[$key] = filter($value);

is it just a case of changeing POST for GET for the get values?
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 06:30 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Webmasterpals.com (c) 2008 - All Rights Reserved