如何捕获存在隐藏 SAML POST 的请求的 SAML 响应?

How to capture the SAML response of a request in which hidden SAML POST is present?

我想从使用隐藏 SAML 身份验证的 URL 请求中捕获 SAML 响应。我能够在 Fiddler 中看到响应,但如何保存它以供进一步分析。 Post URL 的重定向请求,带有“200 OK”的 SAML 响应到达 fiddler,我想捕获它。是否有任何 Powershell 实用程序可用于执行相同的操作,或者我是否必须使用某些模块自动执行 Fiddler 本身。请建议是否还有其他选择。

我在 Powershell 中使用 "Invoke-WebRequest" 尝试了一些片段,但无法重现很多关于 SAML 响应的内容。

我自己吹喇叭,但我的 chrome plugin 会帮助您解决这个问题。它将 ta 添加到开发工具控制台。然后选项卡显示所有流量并突出显示带有 saml 消息的流量。当您单击其中一个时,它会以格式良好的明文形式向您显示 saml xml。

我尝试了很多东西,最后在 phantomjs 的帮助下几乎完成了。

var page = require('webpage').create();
page.customHeaders={'Authorization': 'Basic '+btoa('USER:PASSWORD')};

// hook into initial request
page.onResourceRequested = function(request) {
    //console.log("Request: "+ JSON.stringify(request, undefined, 4));
    var req_json = JSON.stringify(request, undefined, 4);
    if (request.method == "POST" && request.postData != null){
            //console.log("Request: "+ JSON.stringify(request, undefined, 4));
            console.log("SAML Req/Resp: \n" + request.postData);
    }
};

// hook to response
page.onResourceReceived = function(response) {
 //console.log("Response: "+ JSON.stringify(response, undefined, 4));
 var resp_json = JSON.stringify(response, undefined, 4);
};

page.open("https://yourURLwithhiddenSAML");

现在我能够使用 SAMLRequest 和 SAMLResponse 获取 postdata 并将输出重定向到某个文件。但是,我还注意到一件事。如果我添加

phantom.exit();

在函数内部,我无法获得包含 SAML 的完整 request/response 生命周期。