Reply
php decode hacked my site
Old 10-20-2009, 03:50 AM php decode hacked my site
Experienced Talker

Posts: 44
Trades: 0
i found a problem on my site and when i compare the files on the server with my local files i found that every page (*.js or *.php) has this line on it
<?php /**/eval(base64_decode('aWYoZnVuY3Rpb25fZXhpc3RzKC
or a javascript line

so i knew that my site has been hacked..
so
1 - i want to know how to prevent anyone to hack my site?
i made on every textfield or textarea on posting or getting it the htmlspecialcharacter($_POST['name'])

is this true? and can it help me?
2- how did anyone hack my site??
3- how i can know what does this code mean???
thanks in advance and have a nice day
john_zakaria is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 10-20-2009, 04:27 AM Re: php decode hacked my site
Novice Talker

Posts: 13
Name: Georgi Kuzmanov
Trades: 0
php eval function is a big trouble
do not use it!
kuzmanin is offline
Reply With Quote
View Public Profile
 
Old 10-20-2009, 05:11 AM Re: php decode hacked my site
Skilled Talker

Posts: 65
Trades: 0
Same problem here please help any one,

I hope there are lots PHP Experts. Waiting for good reply.

Thanks
__________________
Find here New Forest, Brockenhurst Hotels, New Forest Cottages and New Forest Hotels from New-forest-bed-breakfast.co.uk
spidersense101 is offline
Reply With Quote
View Public Profile
 
Old 10-20-2009, 05:14 AM Re: php decode hacked my site
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
Change your FTP passwords.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 10-20-2009, 05:17 AM Re: php decode hacked my site
NullPointer's Avatar
Will Code for Food

Latest Blog Post:
Easy PHP Search with Opera
Posts: 1,068
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by kuzmanin View Post
php eval function is a big trouble
do not use it!
Not only does that not answer his question, but like every built in function, it has its uses. In this particular case, eval is being used to obscure malicious code, but obviously this isn't its sole purpose.

1. I doubt this particular incident has anything to do with with post data. More likely your ftp info has been compromised. You should change your password and contact your hosting provider about the incident. (Someone with more experience with this type of issue can probably give you a better answer).

2. See 1.

3.
PHP Code:
echo base64_decode(aWYoZnVuY3Rpb25fZXhpc3RzKC... 
That will output the code.
__________________
Tinsology | How to Post Code | EverythingDev

Last edited by NullPointer; 10-20-2009 at 05:19 AM..
NullPointer is offline
Reply With Quote
View Public Profile
 
Old 10-20-2009, 02:37 PM Re: php decode hacked my site
wayfarer07's Avatar
NYE-KEE

Posts: 3,155
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
This happened to me once when I had accidentally set my default file permissions to a bad level on a site that was on a shared server. The hacker is most likely using the file system of the shared computer to browse to your user directory. Your host may be able to help you discover why they are able to do this, and will likely be happy to help as it will get a malicious user off of one of their computers.
__________________
Wayfarer | jQuery Tooltip Plugin | Mapbox: the jQuery Map
Freelance Jobs Available
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 10-20-2009, 03:26 PM Re: php decode hacked my site
chrisrich's Avatar
Junior Talker

Posts: 3
Trades: 0
I've seen this kind of thing happen a number of times. Do you have register globals set to On or Off? (set it to OFF and if your programs break as a result, update the way you use the php global variables - you just have to refer to them more specifically then before syntax-wise - examples are all over the web..)

Next up if that's a no often they come through a vulnerable formmail or email script or any script that allows uploading of files. Make sure all scripts you've downloaded from free providers are up to date - if you have mail scripts replace them with tectite's formmail replacement. Fantastically secure and they update it constantly. (simple google search for tectite formmail should do)

The next most likely culprit is a blended (multiple phase) attack that started with mysql injection - if you are using a database. Two things need to be done at the minimum - audit all your code... and before any query is processed make sure the variable that is holding the query string is run through
PHP Code:
mysqli_real_escape_string($query_string); 
The next thing is to look at the fields in your database and use either regular expressions or php's substitute string handling functions to strip all unecessary characters from each piece of data. Obviously a name field isn't going to have brackets and symbols - but instead of individually specifying all the symbols to take out (don't bother because mysql takes multiple character sets into account, symbols are not represented by the same data from one character set to the other). Instead use functions/regex's that allow you to basically allow all alphanumeric characters and deny everything else. Regular expressions are more versatile but php's str_replace is simpler to learn and gets the job done.

That's a start. There are plenty more possibilities but those are the more common simpler attacks. You do need to have a good look through your code and database to see if there's more stuff in there you don't recognize since the attack... you might want to establish when the hacker first got in (could be weeks before he actually did anything) and restore a backup from before then - then update the code.

Good luck. A search for php security tutorial should give you ideas for more best practices and angles of attack.
__________________
I use these guys for all my... Los Angeles IT Consulting
- Networking, Managed Services, LAN/WAN Security, Programming & Web Design.
chrisrich is offline
Reply With Quote
View Public Profile
 
Old 10-21-2009, 12:32 PM Re: php decode hacked my site
mtishetsky's Avatar
King Spam Talker

Posts: 1,166
Name: Mike
Location: Mataro, Spain
Trades: 0
Quote:
Originally Posted by chrishirst View Post
Change your FTP passwords.
And don't use TotalCommander
__________________
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Reply     « Reply to php decode hacked my site
 

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.17785 seconds with 13 queries