目录

Session操控漏洞

示例:


Session操控漏洞

在Apache tomcat中,有一个默认的example示例目录,该example目录中存着众多的样例,其中/examples/servlets/servlet/SessionExample 允许用户对Session进行操作。由于Session是存储在服务器端的用于验证用户身份的东西。所以,理论上,只要我们可以操控Session,就可以伪造任意用户身份信息!

如图,是Apache tomcat 网站根目录下的文件夹,默认是有一个examples目录的

这是examples目录下的文件

我们访问该SessionExample页面,该页面可以对Session进行操控,本来该页面是Apache tomcat用来给开发者操纵Session示例的页面。但是,如果实际生产环境中不删除该页面的话,可能存在伪造任意用户身份的漏洞。

http://127.0.0.1:8080/examples/servlets/servlet/SessionExample

那么我们来看看SessionExample页面是如何通过接收用户输入的值,来对Session进行控制的。

表单部分代码,接收用户输入的Name和Value值。

out.println("<P>");
out.print("<form action=\"");
out.print(response.encodeURL("SessionExample"));
out.print("\" ");
out.println("method=POST>");
out.println(rb.getString("sessions.dataname"));
out.println("<input type=text size=20 name=dataname>");
out.println("<br>");
out.println(rb.getString("sessions.datavalue"));
out.println("<input type=text size=20 name=datavalue>");
out.println("<br>");
out.println("<input type=submit>");
out.println("</form>");

核心代码,将接收的用户输入的Name和Value值写入到Session中

HttpSession session = request.getSession(true);
out.println(rb.getString("sessions.id") + " " +session.getId());
out.println("<br>");
out.println(rb.getString("sessions.created") + " ");
out.println(new Date(session.getCreationTime()) +"<br>");
out.println(rb.getString("sessions.lastaccessed") + "");
out.println(new Date(session.getLastAccessedTime()));
String dataName = request.getParameter("dataname");//获取dataname参数的值
String dataValue = request.getParameter("datavalue");//获取datavalue参数的值
if (dataName != null && dataValue != null) {
session.setAttribute(dataName, dataValue);//将dataname和datavalue写入session
}

也就是说,用户通过表单提交Name和Value参数,然后通过request.getParameter()函数获取这两个参数的值,再通过session.setAttribute() 函数将Name和Value的值写入Session中。

漏洞利用示例:

我们先来编写 login.jsp 、login_check.jsp 、 index.jsp 这三个页面,通过这三个页面来模拟一般网站身份验证的过程。

login.jsp

<form action=login_check.jsp method="POST" >  
用户名: <input type="text"name="username"><br> 
密码: <input type="text" name="password"><br> 
<inputtype="submit" value="登录"><br> 
<form>

login_check.jsp

<% 
      if(request.getParameter("username") != null && 
      request.getParameter("password")!= null) {  
      String username =request.getParameter("username"); 
      String password =request.getParameter("password"); 
      //验证身份 
      if (username.equals("admin")&& password.equals("admin")) {  
        session.setAttribute("login","admin"); 
        response.sendRedirect("index.jsp"); 
        }else { 
           response.sendRedirect("login.jsp"); 
        }  
      } 
%>

index.jsp

 <% 
     if(session.getAttribute("login")!= null &&
     ((String)session.getAttribute("login")).equals("admin")){ 
        out.println("Login"); 
      } else{
       response.sendRedirect("login.jsp");
       }
%>

我们直接打开网站后台,即 index.jsp

http://127.0.0.1:8080/examples/index.jsp

发现被重定向到login.jsp了。因为我们没有登录,所以被重定向到了登录页面

打开SessionExample

http://127.0.0.1:8080/examples/servlets/servlet/SessionExample

在Name of Session Attribute: 里输入 login

在Value of Session Attribute:里输入 admin

提交后显示login=admin已经写入session

再次打开index.jsp,显示成功登录

注:但是在现实生产环境中,我们很难知道服务器后端的Session中是通过什么参数(Name)和值(Value)来判断用户登录状态的。所以就是我们根本很难利用该页面来进行任意用户伪造,只是说理论上是可行的。

相关文章:Session认证

参考文章:Apache Tomcat样例目录session操纵漏洞

Apache Tomcat examples directory vulnerabilities(Apache Tomcat样例目录session操纵漏洞)复现的更多相关文章

  1. tomcat web漏洞整改--Apache Tomcat examples directory vulnerabilities

    在利用AWVS等弱扫工具对网站进行漏洞扫描时,经常会出现一些Tomcat漏洞问题,一般在弱扫报告中,都会给出简单的处理办法,但有时这些办法可能不太适合我们,或者在一些正式使用的环境中,不好操作,那么我 ...

  2. apache tomcat 目录session应用信息漏洞

    Tomcat 是一款开源的 Web 应用服务器软件.Tomcat 属于轻量级应用服务器,在中小型系统和并发访问用户不多的场合下被普遍使用,是开发和调试 JSP 程序的首选. 漏洞描述 apache T ...

  3. MyEclipse配置tomcat报错 - java.lang.UnsupportedClassVersionError: org/apache/lucene/store/Directory : Unsupported major.minor version 51.0

    1 开发Servlet程序时,MyEclipse配置好tomcat与JDK之后,启动时控制台报下列错误: 1 java.lang.UnsupportedClassVersionError: org/a ...

  4. Apache 实现ProxyPass转发URL到Tomcat并实现http自动转https【转载】

    转自 Apache 实现ProxyPass转发URL到Tomcat并实现http自动转https - OPEN 开发经验库http://www.open-open.com/lib/view/open1 ...

  5. apache、mod_jk负载均衡与tomcat集群

    最近需要搭建apache和tomcat的集群,实现静态网站直接通过apache访问,动态网站转交给tomcat处理,实现负载均衡和tomcat集群配置. apache安装 wget http://ap ...

  6. 整合apache+tomcat+keepalived实现高可用tomcat集群

    Apache是一个强大的Web服务器在处理静态页面.处理大量网络客户请求.支持服务的种类以及可配置方面都有优势,高速并且强壮.但是没有JSP/Servlet的解析能力.整合Apache和Tomcat可 ...

  7. tomcat启动 报org.apache.catalina.LifecycleException异常

    java 服务器 tomcat启动 报org.apache.catalina.LifecycleException异常 异常代码如下: [2018-05-10 04:45:08,856] Artifa ...

  8. 【原创】Apache和基于虚拟主机的Tomcat集群方案

    最近建设了北京某政府机构的网站,网站前段使用Apache做负载均衡,后端使用Tomcat做的集群,基于虚拟主机的方式访问,并且实现了静态资源和动态资源的分离. 开始的建设方案有两种,一种是使用apac ...

  9. Tomcat 搭配 Nginx 还是 Apache 呢?

    Apache .Tomcat.Nginx的区别, 哪个与Tomcat搭配效率高? 一. 定义: 1. Apache Apache HTTP服务器是一个模块化的服务器,可以运行在几乎所有广泛使用的计算机 ...

随机推荐

  1. calcite 概念和架构

    1. 前言 Flink使用Calcite构造SQL引擎,那么他们 是怎么合作的? drill, hive,storm 和其他的一干apache 大数据引擎也用calcite , 那么对于同一个sql  ...

  2. Elasticsearch 为了搜索

    前言 Elasticsearch 是一个开源的搜索引擎,建立在一个全文搜索引擎库 Apache Lucene 基础之上. Lucene 可以说是当下最先进.高性能.全功能的搜索引擎库--无论是开源还是 ...

  3. Java 查找算法

    1 查找算法介绍 在 java 中,我们常用的查找有四种: 1) 顺序(线性)查找 2) 二分查找/折半查找 3) 插值查找 4) 斐波那契查找   2 线性查找算法 有一个数列: {1,8, 10, ...

  4. MySQL 40题练习题和答案

    2.查询"生物"课程比"物理"课程成绩高的所有学生的学号: 思路:    获取所有有生物课程的人(学号,成绩) - 临时表    获取所有有物理课程的人(学号, ...

  5. 漏洞复现-CVE-2018-15473-ssh用户枚举漏洞

          0x00 实验环境 攻击机:Win 10 0x01 影响版本 OpenSSH 7.7前存在一个用户名枚举漏洞,通过该漏洞,攻击者可以判断某个用户名是否存在于目标主机 0x02 漏洞复现 针 ...

  6. 分布式基础理论之CAP 和BASE

    前言 本文聊聊 CAP 定理和 BASE 理论. CAP 定理 C:一致性(Consistency) 数据的强一致性.希望分布式系统只读到最新写入的数据 A:可用性(Availability) 分布式 ...

  7. ijkplayer接入使用

    1.ijkplayer简介 ijkplayer是一个基于FFmpeg的轻量级Android/iOS视频播放器.FFmpeg的是全球领先的多媒体框架,能够解码,编码, 转码,复用,解复用,流,过滤器和播 ...

  8. [LeetCode 279.] Perfect Squres

    LeetCode 279. Perfect Squres DP 是笨办法中的高效办法,又是一道可以被好办法打败的 DP 题. 题目描述 Given a positive integer n, find ...

  9. 实验: survivor放不下的对象进入老年代

    实验一: 存活对象包含 小于survivor大小的对象 + 大于survivor的对象 private static final Integer _1MB = 1024 * 1024; /** * - ...

  10. 【wp】2021V&NCTF

    前几天打完的V&NCTF公开赛,做题的时候没记过程,这是复现wp. 最后排名Top 18,三道RE+两道杂项(wp没啥可放的hhh)+一道web,感觉re题目还是挺好的,难度适中点赞,尤其pc ...