怎样撰写企业网站建设方案,黄村网站建设价格,网站集群怎么做,专业制作网站服务公司拿DVWA的CSRF为例子 接DVWA的分析#xff0c;发现其实Impossible的PHPSESSID是设置的samesite1. 参数的意思参考Set-Cookie
SameSite:控制 cookie 是否随跨站请求一起发送#xff0c;这样可以在一定程度上防范跨站请求伪造攻击#xff08;CSRF#xff09;。 下面用DVWA CS…拿DVWA的CSRF为例子 接DVWA的分析发现其实Impossible的PHPSESSID是设置的samesite1. 参数的意思参考Set-Cookie
SameSite:控制 cookie 是否随跨站请求一起发送这样可以在一定程度上防范跨站请求伪造攻击CSRF。 下面用DVWA CSRF Low Level来分析下samsite的设置。
DVWA CSRF
Cookie一共包含security和PHPSESSID这里讲下PHPSESSIDsession的cookie。 在dvwaPage.inc.php中dvwa_start_session()函数先通过dvwaSecurityLevelGet()函数获得security_level。 之后如果security_level为impossible则samesite设置为Strict。否则为None跨站携带cookie。不同设置的详细解释在Cookie 的 SameSite 属性 最后通过session_set_cookie_params设置session 的cookie。
function dvwa_start_session() {// This will setup the session cookie based on// the security level.$security_level dvwaSecurityLevelGet();if ($security_level impossible) {$httponly true;$samesite Strict;}else {$httponly false;$samesite ;}$maxlifetime 86400;$secure false;$domain parse_url($_SERVER[HTTP_HOST], PHP_URL_HOST);/** Need to do this as you cant update the settings of a session* while it is open. So check if one is open, close it if needed* then update the values and start it again.*/if (session_id()) {session_write_close();}session_set_cookie_params([lifetime $maxlifetime,path /,domain $domain,secure $secure,httponly $httponly,samesite $samesite]);session_start();// This is the call that will force a new Set-Cookie header with the right flagssession_regenerate_id();
}function dvwaSecurityLevelGet() {global $_DVWA;// If there is a security cookie, that takes priority.if (isset($_COOKIE[security])) {return $_COOKIE[ security ];}// If not, check to see if authentication is disabled, if it is, use// the default security level.if (in_array(disable_authentication, $_DVWA) $_DVWA[disable_authentication]) {return $_DVWA[ default_security_level ];}// Worse case, set the level to impossible.return impossible;
}与之前在DVWA SCRF的利用不同因为samesite是跨站设置。所以先用burp抓个包生成csrf的html放在kali中。 kali中用python开启简单http服务在用浏览器去请求kali网站的html模拟跨站攻击。
html!-- CSRF PoC - generated by Burp Suite Professional --bodyform actionhttp://192.168.20.156/DVWA/vulnerabilities/csrf/input typehidden namepassword#95;new value123 /input typehidden namepassword#95;conf value123 /input typehidden nameChange valueChange /input typesubmit valueSubmit request //formscripthistory.pushState(, , /);document.forms[0].submit();/script/body
/html
现在这个源码可以在CSRF Low Level界面产生漏洞修改密码。 此时浏览器Cookie中PHPSESSID的samestie为None。 之后将红框位置改为Lax 看下Lax的解释我们的表单是Get方式提交的所以设置了Lax应该还是可以实现CSRF攻击的 验证CSRF漏洞发现PHPSESSID的samesite为Lax并且漏洞还是存在的。 最后我们把samesite设置为Strict再次进行验证发现无法修改密码。 用burp抓包分析发现请求修改密码包Cookie中并没有PHPSESSID PHPSESSID中samesite设置为Strict。