0

我们有基于 SharePoint 表单的身份验证。我想使用 Curl 并使用此身份验证获取站点内容。使用 FireFox Tamper Data 我得到了这个 POSTDATA 信息:

POSTDATA=__VIEWSTATE=%dlkgKDFLFKF54FFEF564FEVv5ve56rv4e6rv546E5vre%4F
&
__EVENTVALIDATION=%fwf5we4fEEFefe544654fe54F5eF
&
Login_UserInput=username
&
Login_PasswordInput=passw
&
LoginButton=Login

登录页面网址:https://subdomain.domain.local/_layouts/Company/Login/FormsLogin.aspx?ReturnUrl=%2f_layouts%2fAuthenticate.aspx%3fSource%3d%252F&Source=%2F

登录后的网址:https://subdomain.domain.local/companysites/siteCollection/subsite/Pages/LandingPage.aspx

我用来通过 curl 获取网页内容的命令:

curl.exe -F "POSTDATA=__VIEWSTATE=%dlkgKDFLFKF54FFEF564FEVv5ve56rv4e6rv546E5vre%4F&__EVENTVALIDATION=%fwf5we4fEEFefe544654fe54F5eF&Login_UserInput=username&Login_PasswordInput=passw&ButtonLogin=Login" https://subdomain.domain.local/sites/siteCollection/subsite/Pages/LandingPage.aspx -k

但总是得到:403 FORBIDDEN

有什么问题?

4

1 回答 1

0

-F选项会产生一个 multipart/form-data 请求,但您的网站可能只需要一个常规的 POST 并Content-Type设置为application/x-www-form-urlencoded. 所以尝试:

curl.exe -k -d "POSTDATA=__VIEWSTATE=%dlkgKDFLFKF54FFEF564FEVv5ve56rv4e6rv546E5vre%4F&__EVENTVALIDATION=%fwf5we4fEEFefe544654fe54F5eF&Login_UserInput=username&Login_PasswordInput=passw&ButtonLogin=Login" https://subdomain.domain.local/sites/siteCollection/subsite/Pages/LandingPage.aspx
于 2014-12-28T18:56:18.557 回答