<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ## CSRF的原理 一個典型的CSRF攻擊有著如下的流程: * 受害者登錄a.com,并保留了登錄憑證(Cookie)。 * 攻擊者引誘受害者訪問了b.com。 * b.com 向 a.com 發送了一個請求:a.com/act=xx。瀏覽器會默認攜帶a.com的Cookie。 * a.com接收到請求后,對請求進行驗證,并確認是受害者的憑證,誤以為是受害者自己發送的請求。 * a.com以受害者的名義執行了act=xx。 * 攻擊完成,攻擊者在受害者不知情的情況下,冒充受害者,讓a.com執行了自己定義的操作。 ## 如何預防CSRF 服務端的預防CSRF攻擊的方式方法有多種,但思想上都是差不多的,主要從以下2個方面入手: 1. 正確使用GET,POST和Cookie; ``` mux.Get("/user/:uid", getuser) mux.Post("/user/:uid", modifyuser) ``` 2. 在非GET請求中增加偽隨機數; 1. 生成隨機數token ``` h := md5.New() io.WriteString(h, strconv.FormatInt(crutime, 10)) io.WriteString(h, "ganraomaxxxxxxxxx") token := fmt.Sprintf("%x", h.Sum(nil)) t, _ := template.ParseFiles("login.gtpl") t.Execute(w, token) ``` 輸出token ``` <input type="hidden" name="token" value="{{.}}"> ``` 驗證token ``` r.ParseForm() token := r.Form.Get("token") if token != "" { //驗證token的合法性 } else { //不存在token報錯 } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看