7, October 2008

php, CMS security - 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: php, CMS security
« previous next »
Pages: [1] Print

Author Topic: php, CMS security  (Read 2943 times)
Credit Thief
.com pimp
*****
Posts: 1118
0 credits
Members referred : 0



« on: Aug 31, 2005, 04:19:13 PM »

I was going to start making a Content Managment System website with php and was wondering if anyone knew of some good tuorials or something.

Also I'm just guessing this is how you do it:

-Build the shell of your website which is your index
-Then write something like:

PHP Code:
<? php

$pageid = $_GET['pageid'];
$page = $pageid . "php";

include("$page.php");

?> 


But he said it would leave it vulnerable to php injection.. Just wondering what you all think
« Last Edit: Sep 12, 2005, 06:06:43 AM by Bobster »

Proffesional nerd
War Hero
****
Posts: 283
556 credits
Members referred : 0



« Reply #1 on: Aug 31, 2005, 04:27:42 PM »

Yes it is not secure at all.

You should use something like :

Code:
<?php 

$pageid 
$_GET['pageid']; 
$page $pageid "php"

include(
"content/" $page ".php"); 

?>
 

because including the $page var could be used like this :

http://yoursite.com/index.php?pageid=http://uri_to_a_remote_server_manager Visit through proxy

so the problem would be that the 'hacker' could include to your page an external php program and that's too bad....
« Last Edit: Aug 31, 2005, 04:30:28 PM by yohan »

Novice Spammer
***
Gender: Female
Posts: 101
0 credits
Members referred : 0



« Reply #2 on: Sep 07, 2005, 11:16:21 AM »

is there a better way to check for security faults in a PHP program?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8102
41569 credits
Members referred : 3



« Reply #3 on: Sep 07, 2005, 01:00:01 PM »

is there a better way to check for security faults in a PHP program?

I am not sure if there is a way to do this, except than taking a look in your site, and make sure it is not defaced Smiley

I am kiddin. But anyway it is too hard to tell that there is a way to check the security faults of a site.

You must be allways reading articles and news regarding to the languages you use, make small or no use at all of common vurnerabal functions such as eval and exec, and check your log files on a regular base.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Current Events + Big Sites = Easy Money
Novice Spammer
***
Gender: Female
Posts: 101
0 credits
Members referred : 0



« Reply #4 on: Sep 07, 2005, 01:38:34 PM »

I am not sure if there is a way to do this, except than taking a look in your site, and make sure it is not defaced Smiley

I am kiddin. But anyway it is too hard to tell that there is a way to check the security faults of a site.

You must be allways reading articles and news regarding to the languages you use, make small or no use at all of common vurnerabal functions such as eval and exec, and check your log files on a regular base.

Thanks, Nikolas! I actually don't check my log files, except when I'm testing my scripts. But I will start doing so.

Also, since this is about CMS security, what do you think is the best way to prevent spam in comments/guestbook systems within a CMS?
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8102
41569 credits
Members referred : 3



« Reply #5 on: Sep 07, 2005, 02:02:36 PM »

The first thing you have to do is puting the code rel=nofollow to the links that created from your guestbook or comment script. Then you should put a security image to your submit page, as the comment spammers are programs ( I mean that comment spamming is not generated by humans that browse your site)

An example is in the topsites directory Visit through proxy. Browse the directory and try to submit a review for a site.

After all of these things you can also use a script to stop the referer spam like aStatSpam Visit through proxy

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Current Events + Big Sites = Easy Money
Credit Thief
.com pimp
*****
Posts: 1118
0 credits
Members referred : 0



« Reply #6 on: Sep 12, 2005, 06:07:44 AM »

Yes it is not secure at all.

You should use something like :

Code:
<?php 

$pageid 
$_GET['pageid']; 
$page $pageid "php"

include(
"content/" $page ".php"); 

?>
 

So this will work good then?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8102
41569 credits
Members referred : 3



« Reply #7 on: Sep 12, 2005, 06:21:57 AM »


So this will work good then?

Yes because even if there is a url in the $page variable, the script will stop because it wont find the file /content/whatever else.....

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Current Events + Big Sites = Easy Money
I love Pokemon
*
Gender: Male
Posts: 14
84 credits
Members referred : 0



« Reply #8 on: Sep 12, 2005, 06:25:45 PM »

Hmm. Interesting thoughts.

I didn't knew about this vunerability
Novice Spammer
***
Posts: 100
103 credits
Members referred : 0



« Reply #9 on: Sep 12, 2005, 09:45:39 PM »

That is the method I used to code one of my websites. Very basic and easy.
Cyberpunk Wannabe
*
Gender: Male
Posts: 39
172 credits
Members referred : 0



« Reply #10 on: Sep 13, 2005, 06:17:02 PM »

That is the method I used to code one of my websites. Very basic and easy.

It is very basic and easy, but it is also the number one 'weapon' for deface hacking attacks!
Sandwich Artist
*
Posts: 25
48 credits
Members referred : 0


« Reply #11 on: Jan 16, 2006, 11:54:31 AM »

You may also want to make sure the file exists before including it.
Then redirect anyone to the main page if the file is invalid.
Raped By Google
*
Gender: Male
Posts: 27
12 credits
Members referred : 0



« Reply #12 on: Jan 24, 2006, 10:15:48 PM »

Thing is , if you do an echo on errors  like ,
"Couldnt find $page";
Its still suscpetible to XSS , you can use HTML to include frames and things , PHP to echo config files and the like or SQL to  delete user tables or get them etc.
Its very confusing but just use stripslashes and htmlspecialchars on your echo and you should be fine.
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #13 on: Feb 05, 2006, 09:49:32 PM »

storing pages in a mysql or postgre db is much more secure then storing file on your webserver directory alone... then echoing these values with something like this:

Code:
<?php
$homepage 
mysql_query("SELECT * FROM pages WHERE id=1");
$homepage mysql_fetch_array($homepage);
echo 
"<table width=\"100%\" height=\"100%\"><tr><td>";
echo 
stripslashes($homepage['content']);
echo 
"</td></tr></table>";
?>

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8102
41569 credits
Members referred : 3



« Reply #14 on: Feb 05, 2006, 10:14:54 PM »

Meth0d I will not agree with you.

Database is not used because it is safer, but because it gives you the abillity to make more things like content managment, CMS upgrades, layout upgrades.

Files are much faster, but are usefull only for small static sites.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : Current Events + Big Sites = Easy Money
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #15 on: Feb 06, 2006, 12:03:17 AM »

yeah that is more the point i was going with that anyway, my sites always change so i dont use static pages as much anymore

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #16 on: Mar 09, 2006, 05:06:38 AM »

You may also want to make sure the file exists before including it.
Then redirect anyone to the main page if the file is invalid.

I agree!

Another thought... wouldn't a mod rewrite be easier and safer still?! At the same time, your site (in the public areas) will become more SE friendly and get you higher rankings.


Last blog : Site of the Month - August 2007
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=69
Tags : php html mysql spam 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: php, CMS security
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Oct 07, 2008, 03:04:19 PM





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!





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.