Code Monkey home page Code Monkey logo

code-inspector's Introduction

code-inspector

注意:本项目是一个学习项目,可能不会长期维护,作者精力有限,欢迎大佬们二次开发

一个Java自动代码审计工具,尤其针对SpringBoot框架,也可自行改造以适配其他情况

提供一个SpringBoot的Jar包即可进行自动代码审计并生成报告,底层技术基于字节码分析

由于没有真正的执行,例如无法识别过滤等操作,所以会存在误报false positive

注意:漏洞检测并不是简单地检测某个方法内是否包含敏感方法,而是从每个Controller的每个Mapping的每一个用户可控参数开始分析与追踪,构建出方法调用链,分析这个参数在整个链路的过程

成果

漏洞扫描成果

使用GUI启动器

选择好你的Jar包后点击Start即可,默认开启所有配置

注意:目标JarJava 8编译的情况下兼容性最佳,高版本Java可能优化指令导致与原规则不匹配产生漏报

选项:

  • import rt.jar 绝大多数情况请勿勾选
  • analyze all libs 绝大多数情况请勿勾选
  • debug mode 保存一些临时的分析结果到当前目录中

DoS

配置DoS模块:

  • for循环停止条件可控
  • 正则规则和输入同时可控
  • 数组初始化大小可控
  • ArrayList初始化大小可控

RCE

配置RCE模块:

  • Runtime.exec直接/拼接执行命令
  • ProcessBuilder直接/拼接执行命令
  • JNDI注入导致RCE(lookup内容可控)
  • GroovyShell.evaluate直接/拼接执行命令
  • Spring EL直接/拼接执行命令

SSRF

配置SSRF模块:

  • HttpUrlConnection请求
  • Apache HttpClient请求
  • Socket建立新连接
  • OKHttp请求

SQL Injection

配置SQL Injection模块:

  • JdbcTemplate.update存在字符串拼接
  • JdbcTemplate.execute存在字符串拼接
  • JdbcTemplate.queryAny存在字符串拼接
  • Statement.executeQuery存在字符串拼接
  • Statement.executeUpdate存在字符串拼接
  • Statement.execute存在字符串拼接

Open Redirect

配置Redirect模块:

  • 使用HttpServletResponse.sendRedirect重定向
  • 使用SpringMVC直接返回String可控
  • 使用SpringMVC返回ModelAndView可控

Deserialization

配置Deserialization模块:

  • Java原生反序列化
  • Fastjson反序列化
  • SnakeYAML反序列化
  • Jackson反序列化
  • Hessian2反序列化
  • XMLDecoder反序列化

使用API

可以使用以下的方式方便地进行扫描,注意三个boolean参数绝大多数情况应该设置为false

public static void testRCE() {
    CodeInspector inspector = new CodeInspectorImpl();
    List<ResultInfo> results = inspector.analyzeRCE(
            "your/path/to/jar/file",
            false, false, false);
    System.out.println(results.size());
}

Graphviz

指定Controller类名和Mapping的方法名,以及分析的参数索引,即可画图

常见问题

常见问题

如何构建方法调用链

如何构建方法调用链

如何处理分支

如何处理分支

通用污点传递规则

通用污点传递规则

如何编写新规则

如何编写新规则

code-inspector's People

Contributors

4ra1n avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.