gpt4 book ai didi

java - 如何欺骗 session cookie 来测试 session 复制

转载 作者:太空宇宙 更新时间:2023-11-04 07:50:21 25 4
gpt4 key购买 nike

如何欺骗 session cookie 来测试 session 复制?

我在两个节点上使用 Jboss,我想确认如果一个节点出现故障,我的 session 数据是否位于另一个节点中。

我可以看到我的节点 1 正在设置此 cookie。我怎样才能在节点 2 上欺骗它?

JSESSIONID=3rsZ87MxC7EeukilWW8za7T-.node1; path=/hsr-test; domain=xxxx.xxxx.dev

最佳答案

这是一个迟到的回复,但由于我正在搜索此内容而添加。

这是一个简单的 session get/put jsp 脚本

    <html>
<body>

<a href="testsession.jsp?action=put">put</a>
<a href="testsession.jsp?action=get">get</a>
<%
String action = request.getParameter("action");
if ( null != action && "put".equals(action) ) {
%>
<h2>Set Current Time</h2>
<%
System.out.println( "Putting date now" );
session.setAttribute("current.time", new java.util.Date());
%>
The time is set to <%= session.getAttribute("current.time") %>
<% } else { %>
<h2>Get Time</h2>
<%
System.out.println( "Getting date now" );
%>
The time is <%= session.getAttribute("current.time") %>
<% } %>

<br>
<br>
server: <%=request.getServerName() %>

<br>
<br>
session: <%= session.getId() %>

</body>
</html>

如果您在命令行上,则可以在两个节点上使用它:

curl --cookie "JSESSIONID=ZWarGbkuDUoUuT-iOjYIATN+.2e84d3e9-3497-3e74-9604-a45f36cad465;"  http://node1/your_test_page

curl --cookie "JSESSIONID=ZWarGbkuDUoUuT-iOjYIATN+.2e84d3e9-3497-3e74-9604-a45f36cad465;" http://node2/your_test_page

您将看到浏览器和命令行测试中返回的时间。

关于java - 如何欺骗 session cookie 来测试 session 复制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14584419/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com