Setting the secure flag in the cookie is easy

news/2024/5/18 11:49:13 标签: cookie, setting, flag

引自这里
TechRepublic had an interesting article about the Surf Jack attack. Many people commented, some giving their own solution to the problem. However many of these solutions do not prevent the attack because they do not really address it. Of course, who ever missed the details should check out the paper.

The attack has been addressed quite a while ago, and the solution is easy to implement in many occasions. So no need to reinvent the wheel or create a new solution which has not been peer reviewed yet. Here I’ll indicate how to set the secure flag in various languages / web application technologies. The idea is that besides making use of HTTPS instead of HTTP, one needs to set a flag in the cookie so that it cannot be leaked out in clear text.

PHP

bool setcookie ( string $name [, string $value [, int $expire [,string $path [, string $domain [, bool $secure [, bool $httponly ]]]]]] )

Note that the $secure boolean should be set to true.

JSP / Java Server Pages

Cookie helloCookie = new Cookie("name",text);
helloCookie.setSecure(true);

ASP.NET

HttpCookie cookie = new HttpCookie('name');
cookie.Secure = True;
cookie.Value = 'Joe';

Perl with CGI.pm

(added by Noam)
$cookie = cookie(-name=>’sessionID’,
-value=>’xyzzy’,
-expires=>’+1h’,
-path=>’/cgi-bin/database’,
-domain=>’.capricorn.org’,
-secure=>1);

http://www.niftyadmin.cn/n/1053879.html

相关文章

ALC笔记

ACL ----访问控制列表 ACL的作用: 1,访问控制:在路由器流量流入或流出的接口上,匹配流量,然后执行设定好的动作。----permit 允 许, deny 拒绝 2,抓取感兴趣流:ACL可以和其他服务结合使用。…

IIS开启https协议

1.打开IIS控制台 2.打开你需要启用SSL证书的网站,右键选择“编辑绑定‘设置网站主机头,如下图 3.在“网站绑定“中找到点击“”添加“,”如下图(选择https类型) 4.选择SSL证书,点击确定,完成 5.…

kvm虚拟化之virt-install

转自:http://www.361way.com/virt-install/2721.html virt-install是rpm包python-virtinst里的一个工具 -- 其实就是一个python写的脚本 。其是qemu-kvm工具的人性化实现。可以利用该工具在终端下创建KVM guest主机。 [rootkvmtest ~]# rp…

冒泡排序-python

题目: 如果一个list是一组打乱的数字 list1[3,2,1,9,10,78,6] 如何用python将这组打乱的数字进行冒泡排序? 题解: def sort(nums): for i in range(len(nums)-1): #这个循环负责设置冒泡排序进行的次数 for j in range(len(nums)-i-1): #j为列表下标 i…

pandas常用操作方法

指定列中进行字段替换df[tradeDate] df["tradeDate"].apply(lambda x: x.replace("-", "")) 获取df中ticker(不)在df_halt["ticker"]的数据.df df[~df["ticker"].isin(df_halt["ticker"].tolist())] 获取ticker…

笔记本电脑连wifi然后通过有线网口做桥接

让你的笔记本电脑作为主机,台式机通过通过一根网线连接到你的笔记本,共享无线网络上网,可以进行如下操作: 1,先找跟网线将两台电脑连接。 2,打开win7自带的windows防火墙,此步在控制面板里可以设…

Oz制作CentOS镜像

转自:http://www.chenshake.com/oz-making-centos-mirror/ 一直以来,我都是使用Ubuntu的镜像,自己没动手做过镜像。对于Openstack的镜像来说,需要在image里安装cloud init,这样才能注入密钥,网络的设置,也是需要cloud init。 做镜…

VLAN笔记

VLAN V ---虚拟的 LAN ---局域网---地理覆盖范围较小的网络 MAN ---城域网 WAN ---广域网 LAN ---广播域 VLAN ---虚拟局域网---交换机和路由器协同工作后,将原来的一个广播域逻辑上切分为多个 第一步:创建VLAN[Huawei]display vlan ---查看交换机上…