使用ColdFusion将凭据发布到cfhttp正文

问题描述 投票:0回答:2

我正在传递几个凭据以及__EVENTARGUMENT,__ CHSTSTATE。但我无法在控制台或小提琴手中看到变量和数据,我错过了什么。我尝试了url,formfield和body但没有成功。顺便说一下,我正在使用ColdFusion 9。

<cfset authenticationRequestBody = "__LASTFOCUS=#LASTFOCUS#&__EVENTTARGET=#EVENTTARGET#&__EVENTARGUMENT=#EVENTARGUMENT#&__VIEWSTATE=#EncodeViewState#&__VIEWSTATEGENERATOR=#EncodeViewGenerator#&__EVENTVALIDATION=#EncodeEventValidation#&#encodeForURL(UNameString)#=#UserName#&#encodeForURL(PwdString)#=#encodeForURL(Password)#&#encodeForURL(ButtonString)#=Submit">


<cfset stsUrl = "https://somesite.com/yyy/login.aspx" >
<cfhttp url="#stsUrl#" method="post"  resolveurl="no"  >
    <cfhttpparam type="header" name="Accept" value="application/xhtml+xml,text/html">
    <cfhttpparam type="header" name="REFERER" value="#BaseUrl#" >
    <cfhttpparam type="header" name="Accept-Language" value="en-US">
    <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
    <cfhttpparam type="header" name="Connection" value="keep-alive" >
    <cfhttpparam type="header" name="User-Agent" value="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36" >
    <cfloop collection="#cookies#" item="i">
        <cfhttpparam type = "cookie" name="#i#" value="#cookies[i]#">
    </cfloop>
    <cfhttpparam type="body" name="PostData" value="#authenticationRequestBody#">


<cfoutput>
    <cfdump var="#GetHTTPRequestData()#">
</cfoutput>

这不是与配置相关的问题因为我使用SSL测试服务器检查了站点上的JVM版本和TLS版本。我在代码中遗漏了一些东西。

Coldfusion 11(更新12)JVM:1.8 TLS:1.2

我可以直到登录屏幕。即使在正文中传递用户名和密码后,它也不会验证。当我使用相同的凭据直接访问URL时,它会成功登录。

coldfusion coldfusion-9 cfhttp
2个回答
0
投票

尝试做一个

<cfdump var="#cfhttp#">

要么

<cfhttp url="#stsUrl#" method="post"  resolveurl="no" result="result" >  
   ...
</cfhttp>

<cfdump var="#result#">

0
投票

问题不在于配置或兼容版本..问题在于我们从一开始就传递的cookie。当我们使用cfhttp浏览其他页面时,我们需要携带我们从过去的cfhttp调用中获得的旧cookie。 。在我的情况下,我需要在第一次调用中初始化cookie。下面是两个调用的示例..

<cfhttp url='#BaseUrl#' method="get" redirect="no">
        <cfhttpparam type="header" name="Connection" value="keep-alive" >
        <cfhttpparam type="header" name="Cache-Control" value="no-cache">
        <cfhttpparam type="header" name="User-Agent" value="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko">
        <cfhttpparam type="header" name="cookie" value="TestCookie=;" >
</cfhttp>

<cfhttp url="#stsUrl#" method="post"  redirect="no" resolveurl="yes" result="postResult" >
    <cfhttpparam type="header" name="REFERER" value="#BaseUrl#" >
    <cfhttpparam type="header" name="Cache-Control" value="no-cache">
    <cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
    <cfhttpparam type="header" name="Connection" value="keep-alive" >
    <cfhttpparam type="header" name="User-Agent" value="Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36" >

    <cfhttpparam type="header" name="cookie" value="TestCookie=;" encoded="yes">

    <cfloop collection="#CookieList#" item="i">
        <cfhttpparam type="header" name="cookie" value="#CookieList[i]#" encoded="yes">
    </cfloop>

    <cfhttpparam name="__LASTFOCUS"  value="" type="formfield">
    <cfhttpparam name="__EVENTTARGET"  value="" type="formfield">
    <cfhttpparam name="__EVENTARGUMENT"  value="" type="formfield">
    <cfhttpparam name="__VIEWSTATE"  value="#VIEWSTATE#" type="formfield">
    <cfhttpparam name="__VIEWSTATEGENERATOR"  value="#VIEWSTATEGENERATOR#" type="formfield">
    <cfhttpparam name="__EVENTVALIDATION"  value="#EVENTVALIDATION#" type="formfield">
    <cfhttpparam name="ctl00$MainContent$LoginCtrl$UserName"  value="#UserName#" type="formfield">
    <cfhttpparam name="ctl00$MainContent$LoginCtrl$Password"  value="#Password#" type="formfield">
    <cfhttpparam name="ctl00$MainContent$LoginCtrl$LoginButton"  value="Submit" type="formfield">
</cfhttp>
© www.soinside.com 2019 - 2024. All rights reserved.