Code Monkey home page Code Monkey logo

codeinspector's Introduction

CodeInspector

简介

简化并重写GadgetInspector尝试实现一个自动Java代码审计工具

目前是半成品,基本架构已经搭起来了,必要的类和方法已经实现

基本原理是从Java的字节码角度入手,使用ASM技术解析,模拟JVM的Operand StackLocal Variables Array实现数据流分析

最终目标:通过输入一个SpringBootJar,直接生成漏洞报告

参考先知社区文章:

https://xz.aliyun.com/t/10433

https://xz.aliyun.com/t/10363

原理

JVM在每次方法调用均会创建一个对应的Frame,方法执行完毕或者异常终止,Frame被销毁

而每个Frame的结构如下,主要由本地变量数组(local variables)和操作栈(operand stack)组成

局部变量表所需的容量大小是在编译期确定下来的,表中的变量只在当前方法调用中有效

JVM把操作数栈作为它的工作区——大多数指令都要从这里弹出数据,执行运算,然后把结果压回操作数栈

比如,IADD指令就要从操作数栈中弹出两个整数,执行加法运算,其结果又压回到操作数栈中

之所以介绍JVM Frame,是因为代码模拟了比较完善的Operand Stack和Local Variables交互

例如方法调用会从Stack中弹出参数,方法返回值会压入栈中

根据这样的规则,进而执行数据流的分析

参考代码中的core/CoreMethodAdapter,该类构造了Operand StackLocal Variables Array并结合ASM技术实现数据流分析

进度

目前仅尝试实现了一种简单的SSRF,但可以做到参数可控性判断和数据流追踪分析,参考已有代码可以实现其他的漏洞检测

使用

目前仅测试

打包:mvn clean package

执行:java -jar CodeInspector.jar --boot jar/springboot.jar --pack com.inspector.sbdemo

  • boot:指定SpringBoot的Jar包路径
  • pack:指定项目的包名,将会分析启动的SpringMVC路径映射,生成自动审计的入口

codeinspector'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.