實測 ASP.NET Forms Authentication 產生的 Cookie 是否綁定電腦特徵、能否跨電腦偽造、單一用戶是否對應固定 Cookie 值。
Web.config 設定 Forms 驗證,憑證儲存在設定檔:
<authentication mode="forms">
<forms name="mylab" loginUrl="/login.aspx">
<credentials passwordFormat="Clear">
<user name="fancyray" password="fancyray" />
</credentials>
</forms>
</authentication>
<authorization> <deny users="?" /> </authorization>
登入頁面驗證碼:
if (FormsAuthentication.Authenticate(txtUser.Text, txtPass.Text)) {
FormsAuthentication.RedirectFromLoginPage(txtUser.Text, true);
}
使用 IEHttpHeaders 觀察驗證後 Cookie:
mylab=3ff83247c29eb5d14d61f389d453eee0586b94e27609c321b017be7b88d1a94d249996428a7a18f5c2d69f3c4dd2b88c00172cafb0b4b4ed8784db62d1d61bcc0c786b4ea7868fc6
在另一台電腦 login.aspx 注入此 Cookie:
<script> document.cookie = "mylab=3ff83247c29eb5d14d61f389d453eee0586b94e27609c321b017be7b88d1a94d249996428a7a18f5c2d69f3c4dd2b88c00172cafb0b4b4ed8784db62d1d61bcc0c786b4ea7868fc6"; </script>
來源討論:CSDN 社群