6, July 2008

Got Hacked, advise needed - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Security
Topic: Got Hacked, advise needed
« previous next »
Pages: [1] Print

Author Topic: Got Hacked, advise needed  (Read 401 times)
So if I press Alt F4... What?
****
Gender: Male
Posts: 389
2352 credits
Members referred : 2



« on: Apr 09, 2008, 03:04:58 PM »

One of my sites was found with spam links included in the index.php

the site has no database
just a simple contact form (that uses mail())

I found "prefer.php" file in my public_html/lib/
that was actually doing the insertion/injection in index.php
but how did it get there (I can send it if anyone wants to see it)

I am sanitizing/filtering all the inputs for email headers injection
but maybe not correctly for XSS attacks or PHP remote inclusion

are there some patterns I should be scanning for ??

should I include any directives in .htaccess ??

How can someone write a file on my server with
just exploiting a contact form ??

any pointers/advice would be greatly appreciated



Last blog : Pagerank 0, the new Leprosy ?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #1 on: Apr 09, 2008, 03:53:50 PM »

So the prefer.php wrote  to the index.php?

In any case if something wrote to any page of your site, you should check the scripts that use the fopen() and fwrite() functions.

An other thing you should check is other directory index files (index.php on www root folders) that have the same problem. If this is the case then someone hacked the server and you should contact your hosting company (or let me know if it is your own server)

Good luck Smiley

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
So if I press Alt F4... What?
****
Gender: Male
Posts: 389
2352 credits
Members referred : 2



« Reply #2 on: Apr 09, 2008, 04:47:06 PM »

thanks for the reply Nikola,

the server is not mine so I also asked the admin
they told me that I should alwasy have my .php files as CHMOD 644
apparently I did not have them

Would that be enough for them to get access ??

I will check all my fopen, fwrite functions but I am pretty sure
the filenames for them are hardcoded
that does not cause a problem right ??

I did not understand this part though
----------
An other thing you should check is other directory index files (index.php on www root folders) that have the same problem.
---------


Last blog : Pagerank 0, the new Leprosy ?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Apr 09, 2008, 05:42:08 PM »

sounds to me that the provider is hiding some problem, I had the same problem before with a shared hosting account.

look the hacker is not some stranger, I think it's another customer Wink


Last blog : 4th of July Lottery from TemplateMonster.com
So if I press Alt F4... What?
****
Gender: Male
Posts: 389
2352 credits
Members referred : 2



« Reply #4 on: Apr 09, 2008, 06:17:23 PM »

Olaf thanks for you input,
It is indeed hosted on a shared host.

2 support guys concluded that keeping the .php files as 644
will prevent other attacks

They were both definite about that !!!
But never offered to explain how such a think could have happened !


Last blog : Pagerank 0, the new Leprosy ?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Apr 09, 2008, 08:00:58 PM »

what permissions do you have for these files? a normal server will use 644 as default


Last blog : 4th of July Lottery from TemplateMonster.com
So if I press Alt F4... What?
****
Gender: Male
Posts: 389
2352 credits
Members referred : 2



« Reply #6 on: Apr 09, 2008, 08:11:46 PM »

I never knew that I should be worried about this
but now I will, everything is turned to 644


Last blog : Pagerank 0, the new Leprosy ?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Apr 09, 2008, 08:50:05 PM »

I never knew that I should be worried about this
but now I will, everything is turned to 644

if you upload a file this should be 644 automatically or the server is wrong configured


Last blog : 4th of July Lottery from TemplateMonster.com
I am a fanatic. So?
*****
Gender: Female
Posts: 594
3697 credits
Members referred : 2



« Reply #8 on: Apr 10, 2008, 08:24:38 AM »

I feel for you Giorgios. One of my database driven sites apparently become a target on a Vietnamese hacker forum. It seemed that they figured out I was using a vulnerable script and encouraged their members to post that forum's banners and links on my site. Don't some folks have anything better to do with their time?

Hopefully, your problem is much easier to fix and you will get your site fully secure quickly.

www.yourmessageconsultant.com Visit through proxy, providing online content and printed marketing materials.
www.helpforwebbeginners.com Visit through proxy, Tutorials and how to's for new  webmasters.
www.CraftyTips.com Visit through proxy, a unique Arts & Crafts Directory
www.nocans.com Visit through proxy - Pet Food Recipe Site
www.petsiteguides.com Visit through proxy - A New Pet Directory

Last blog : Free Artist Profiles
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Apr 10, 2008, 09:24:16 AM »

This 3rd party script are big problems, even Wordpress is a risk since there are problems in the past. These days I bought a website with some custom script, it is so bad scripted that I think about to move the whole thing into the RB.


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #10 on: Apr 11, 2008, 03:31:31 PM »

These guys usually use an XSS vulnerability to include a remote script to your code. Then they use the /tmp folder to install an application that checks all the www directory index files (index.php on every site) and deface it.

In addition there is another vulnerability which may gives them the right to run their app as root, which means that your files will be defaced anyway (this is a problem with crontab)

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
So if I press Alt F4... What?
****
Gender: Male
Posts: 389
2352 credits
Members referred : 2



« Reply #11 on: Apr 12, 2008, 02:08:55 AM »

I never knew that I should be worried about this
but now I will, everything is turned to 644

if you upload a file this should be 644 automatically or the server is wrong configured
I have probably changed the file permissions after uploading them.
The hosting company has been great so far, everything works as advertised and the support questions are usually answered within the hour.

These guys usually use an XSS vulnerability to include a remote script to your code. Then they use the /tmp folder to install an application that checks all the www directory index files (index.php on every site) and deface it.

In addition there is another vulnerability which may gives them the right to run their app as root, which means that your files will be defaced anyway (this is a problem with crontab)


Olaf and Nick
Its my own script, simple of course but does don't allow input with

content-type:
bcc:
cc:
document.cookie
onclick
onload
;
~
|

Anything else I should be checking at ??


Last blog : Pagerank 0, the new Leprosy ?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #12 on: Apr 12, 2008, 12:35:35 PM »

You should check if you are including files from $_GET or $_POST. For example :

 include $_GET['action'] . '.php';

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
So if I press Alt F4... What?
****
Gender: Male
Posts: 389
2352 credits
Members referred : 2



« Reply #13 on: Apr 12, 2008, 09:28:16 PM »

You should check if you are including files from $_GET or $_POST. For example :

 include $_GET['action'] . '.php';

Thanks Nikolas but I was not doing anything that dangerous !!


Last blog : Pagerank 0, the new Leprosy ?
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7687
Tags : attack html inclusion Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Security
Topic: Got Hacked, advise needed
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 06, 2008, 07:52:52 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.548
Total Topics: 7.348
Total Members: 3.648
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: mybaseballcards

18 Guests, 4 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.