最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何使用 Axios 对使用 csrf 令牌的网站进行身份验证

网站源码admin36浏览0评论

如何使用 Axios 对使用 csrf 令牌的网站进行身份验证

如何使用 Axios 对使用 csrf 令牌的网站进行身份验证

我要验证到该网站的网站 =%2fHomeAccess 并且它使用“__RequestVerificationToken”,当您进入该网站和令牌隐藏在html中。我登录时检查了有效负载并发送了:

const axios = require('axios');
const cheerio = require('cheerio');

axios.get('')
  .then((response) => {
    const $ = cheerio.load(response.data);
    const token = $('input[name="__RequestVerificationToken"]').val();

    const payload = {
      __RequestVerificationToken: token,
      SCKTY00328510CustomEnabled: 'True',
      SCKTY00436568CustomEnabled: 'True',
      Database: '10',
      VerificationOption: 'UsernamePassword',
      'LogOnDetails.UserName': 'TestName',
      tempUN: '',
      tempPW: '',
      'LogOnDetails.Password': 'TestPass'
    };

    return axios.post('', payload);
  })
  .then((response) => {
    console.log(response.data);
  })
  .catch((error) => {
    console.error(error);
  });

当我尝试这个时,我得到的只是错误,我不确定为什么。

回答如下:
发布评论

评论列表(0)

  1. 暂无评论