HTTP Only cookies without PHP 5.2
HTTP Only cookies without PHP 5.2
by Matt Mecham
on September 12, 2006
For a while, Microsoft have had a flag
for cookies called ‘httponly’. This doesn’t sound particularly
exciting, but it is a vital step forward for web application security.
This flag tells Internet Explorer to make this cookie ‘invisible’ to
javascript (and other scripting languages) which means that an XSS
attack will no longer be able to steal your sensitive cookies.
The problem is that ‘http only’ support has only just been added into PHP 5.2
. This makes this feature unavailable to most webservers.
However, there appears to be a way to force this flag to be written
regardless of your PHP version by simply adding “; HttpOnly” at the end
of the domain name when setting the cookie. PHP’s “setcookie” function
merely formats the data into a “set-cookie” header. Fortunately, PHP
doesn’t appear to filter out or escape the semi-colon so it’s added to
the end of the “set-cookie” request.
if ( PHP_VERSION < 5.2 )
{
@setcookie( $name, $value, $expires, $path, $domain. '; HttpOnly' );
}
else
{
@setcookie( $name, $value, $expires, $path, $domain, NULL, TRUE );
}
I've tested this out and it appears to work fine. IE7 shows the
"sensitive" cookie data in the document.cookie string without adding
the flag. Adding the flag onto the domain string causes the sensitive
cookies to disappear from the document.cookie string.
Firefox ignores it and sets cookies as does Safari and Opera. I'll
do some more testing and report in on my findings. I also have a
Firefox friendly version to stop access to the document.cookie which
I'll post up tomorrow.
UPDATE 14th September
I've downloaded the source to PHP 5 to make confirm that this 'hack'
will work across different platforms. The source code confirms that no
cleaning takes place on
相关文档:
function poster()
{
$URL = 'http://www.yw56.com.cn/DIY.asp'; //需要提交到的页面
//下面这段是要提交的数据
$post_data['orderid'] = "YW861736303CN";
$post_data['button'] = "提交";
$referrer="http://www.yw56.com.cn/DIY.asp";
$Cookie=&qu ......
前提: Apache 和 Mysql已经安装完毕。
php 版本:php-5.2.6.tar.gz
下载地址:
ZendOptimiter-3.3.3-linux-glibc23-i386.tar.gz
下载地址:
1. 首先安装 GD库软件
libxml2-2.7.2.tar.gz
下载地址:
#tar -zxvf libxml2-2.7.2.tar.gz
#cd libxml2-2.7.2
#mkdir /usr/local/modules
#mkdir /usr/loc ......
php中如何关闭notice级的错误提示
2008-09-04 15:39
1.在php.ini文件中改动error_reporting
改为:
error_reporting = E_ALL & ~E_NOTICE
如果你不能操作php.ini文件,你可以用下面的方法 ......
基础题:
1.表单中 get与post提交方法的区别?
答:get是发送请求HTTP协议通过url参数传递进行接收,而post是实体数据,可以通过表单提交大量信息.
2.session与cookie的区别?
答:session:储存用户访问的全局唯一变量,存储在服务器上的php指定的目录中的(session_dir)的位置进行的存放
cookie:用来存储连续 ......
<?php
//新建目录
mkdir("/path/to/my/dir", 0700); //0700表示权限最大
//删除目录
rmdir("/path/to/my/dir");
//遍历目录
$p =dir(/etc/php5);
echo "handler:".$p->handler;
while(false!=$entry=$p->read()){
echo $entry."\n" ;
}
$p->close();
//输出文件内容
$handle=@ ......