使用Java使用__RequestVerificationToken填充HTML表单

时间:2017-07-02 08:28:04

标签: java html angular csrf-protection

我正在构建一个应用程序,它使用存储的登录/传递信息登录网站并抓取其内容。但是,相关网站的前端已经改变,现在我的脚本不再起作用了。

我发现该网站现在采用了一种更复杂的登录程序,使用某种CSRF保护。我已经从网站上提取了相关的__RequestVerificationToken,但无法提交表单。这是我尝试使用JAVA工具填写的表单的HTML代码:

protected $appends = ['is_admin'];

public function getIsAdminAttribute()
{
    return $this->attributes['admin'] == 'yes';
}

这是当前的JAVA代码:         HtmlPage landing_page = null;

<form name="userInfoForm" ng-submit="$ctrl.signIn(userInfoForm)" novalidate="" class="ng-pristine ng-invalid ng-invalid-required">
  <div class="form-group">
    <div class="form-group">
      <!-- ngIf: $ctrl.responseModel.errorMessage -->    </div>
    <div class="form-group">
      <label class="sr-only">
        Username
      </label>
      <input id="kitnum-input" tabindex="1" type="text" class="form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" placeholder="Username" ng-model="$ctrl.kitNum" ng-change="$ctrl.onType(userInfoForm)" autofocus="" required=""/>
    </div>
    <div class="form-group">
      <label class="sr-only">
        Password
      </label>
      <input id="password-input" tabindex="2" type="password" class="form-control ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required" placeholder="Password" ng-model="$ctrl.password" ng-change="$ctrl.onType(userInfoForm)" required=""/>
    </div>
  </div>
  <div class="form-group text-center cta-space cta">
    <button id="sign-in-btn" type="submit" value="Sign in" data-style="zoom-in" class="btn btn-main btn-uppercase ladda-button" loading-data-button="" loading="false" ng-disabled="$ctrl.submitDisabled" disabled="disabled">
      <span class="ladda-label">
        Sign In
      </span>
      <span class="ladda-spinner">
      </span>
    </button>
  </div>
</form>

任何想法如何解决这个问题?

0 个答案:

没有答案