|
| 1 | +# 【BytecodeScreen】 |
| 2 | +本工具设计初衷是由前阵子的beichen师傅挖掘的CS的RCE漏洞,因为刚毕业还在适应新的工作,上个月就一直工作很忙,产品果然没我想的这么好做。终于在国庆假期,可以好好的学习一下主管的这篇文章[https://mp.weixin.qq.com/s/l5e2p_WtYSCYYhYE0lzRdQ](https://mp.weixin.qq.com/s/l5e2p_WtYSCYYhYE0lzRdQ),看到这个部分的时候有了一些思考 |
| 3 | +这里是主管总结的符合此情况的类的要求。找了一遍网上的工具(可能是我找的不够仔细并且IDEA用的不够熟练),我第一时间没有找到可以帮我快速筛选的工具,昨天看了pang0lin师傅的文章,发现好像是存在这样的情况。 |
| 4 | +之前跟着threedr3am,Longgofo,4ra1n,su18等很多师傅的文章学习了GadgetInspector代码和原理相关的知识,由此借鉴了很多的代码从而完成了一款基于ASM来获取字节码信息筛选的工具来应对此等情况。 |
| 5 | +项目使用展示: |
| 6 | +```python |
| 7 | +D:\Desktop\BytecodeScreen_jar>java -jar BytecodeScreen.jar -h |
| 8 | + ____ _ _ _____ |
| 9 | + | _ \ | | | | / ____| |
| 10 | + | |_) |_ _| |_ ___ ___ ___ __| | ___| (___ ___ _ __ ___ ___ _ __ |
| 11 | + | _ <| | | | __/ _ \/ __/ _ \ / _` |/ _ \\___ \ / __| '__/ _ \/ _ \ '_ \ |
| 12 | + | |_) | |_| | || __/ (_| (_) | (_| | __/____) | (__| | | __/ __/ | | | |
| 13 | + |____/ \__, |\__\___|\___\___/ \__,_|\___|_____/ \___|_| \___|\___|_| |_| |
| 14 | + __/ | |
| 15 | + |___/ |
| 16 | + ---Author 0xrumble |
| 17 | + |
| 18 | +======================================================================================================================= |
| 19 | +Usage: <main class> [options] |
| 20 | + Options: |
| 21 | + --debug |
| 22 | + make debug |
| 23 | + Default: false |
| 24 | + -h, --help |
| 25 | + Help Info |
| 26 | + -i, --interface |
| 27 | + JAVA InterFace Name |
| 28 | + --jar |
| 29 | + use base rt.jar |
| 30 | + Default: false |
| 31 | + -m, --method |
| 32 | + JAVA Method Name |
| 33 | + -p, --paramter |
| 34 | + JAVA Method Paramter Type |
| 35 | + -r, --return |
| 36 | + JAVA Method Return Paramter Type |
| 37 | + --static |
| 38 | + try do static |
| 39 | + Default: false |
| 40 | + -s, --superclass |
| 41 | + JAVA SuperClass |
| 42 | + -j, --targetpath |
| 43 | + JAVA Target PATH |
| 44 | +``` |
| 45 | +# 参数介绍 |
| 46 | +## 基础参数 |
| 47 | +### 参数使用 |
| 48 | +```python |
| 49 | +-h --help: 输出help页面属性。 |
| 50 | +--debug: 开启debug属性。 |
| 51 | +-j --targetpath : |
| 52 | + 1.后面跟一个文件夹路径,会读取这个文件夹及子文件夹。例如: |
| 53 | + -j D:\Desktop\testts\target\classes |
| 54 | + 2.后面跟一个jar文件路径,会读取这个文件夹及子文件夹。例如: |
| 55 | + -j D:\Desktop\testts\out\artifacts\testts_jar\testts.jar |
| 56 | + 3.后面跟一个txt文件路径,会读取这个txt文件内的内容。例如: |
| 57 | + -j D:\Desktop\123.txt |
| 58 | + 内容为(每行一个上面的路径形式): |
| 59 | + D:\Desktop\testts\out\artifacts\testts_jar\testts.jar |
| 60 | + D:\Desktop\testts\target\classes |
| 61 | +``` |
| 62 | +## 方法参数 |
| 63 | +### 参数分类: |
| 64 | +#### 1.基本类型 |
| 65 | +int,byte,char,double,float,long,short,boolean 例如:{(int)} {(byte)} |
| 66 | + |
| 67 | +#### 2.特殊类型 |
| 68 | +void 例如:{(void)} |
| 69 | + |
| 70 | +#### 3.对象类型 |
| 71 | +普通对象:全限定类名。例如:{(java.lang.String)} , {( java.lang.Boolean)} |
| 72 | +数组对象:全限定类名+[] 例如:一维数组:{(java.lang.String[])},二维数组:{{java.lang.String[][]}} |
| 73 | + |
| 74 | +#### 4.内部类 |
| 75 | +普通内部对象变量:全限定类名+$+内部类名。例如:{(infra.config.Configuration$Module)} |
| 76 | +数组内部对象变量:全限定类名+$+内部类名+[] 例如:{(infra.config.Configuration$Module[])} |
| 77 | + |
| 78 | +### 参数使用 |
| 79 | +```python |
| 80 | +-i, --interface 指定实现的全路径接口名称(多个用,分割) 例如: |
| 81 | + -i org.example.Interface3,org.example.Interface2 |
| 82 | +-s, --superclass 指定继承的全路径父类名称,例如: |
| 83 | + -s org.example.class1 |
| 84 | + |
| 85 | +-m, --method 指定方法名称,例如: |
| 86 | + (确定的传入参数) -m {(setpar1)} |
| 87 | + (不确定的传入参数) -m {(set*)} |
| 88 | + |
| 89 | +-p, --paramter 指定全路径的传入参数名称,例如: |
| 90 | + (确定的传入参数,多个用,分割) -p {(java.lang.String)} |
| 91 | + (不确定的传入参数) -p {(*)} |
| 92 | + (没有传入参数) -p {(void)} |
| 93 | +-r, --return 指定全路径的返回值名称,例如: |
| 94 | + (确定的返回值) -r {(java.lang.String)} |
| 95 | + (不确定的返回值) -r {(*)} |
| 96 | + (没有传入参数) -r {(void)} |
| 97 | + |
| 98 | +--static 扫描static方法,默认不查找static方法 |
| 99 | +--jar 扫描默认jre路径下的rt.jar包 |
| 100 | +``` |
| 101 | +# 工具使用 |
| 102 | +## 例子1:无参构造函数 |
| 103 | +1.规定方法名称(构造方法用<init>) |
| 104 | +2.参数确定(为空) |
| 105 | +3.返回值确定(为空) |
| 106 | +```python |
| 107 | +java -jar BytecodeScreen.jar -j D:\Desktop\123.txt -m "{(<init>)}" -p {(void)} -r {(void)} |
| 108 | +``` |
| 109 | + |
| 110 | +## 例子2:查找特定方法 |
| 111 | +1.查找set方法 |
| 112 | +2.传入参数不限 |
| 113 | +3.返回值为空 |
| 114 | +```python |
| 115 | +java -jar BytecodeScreen.jar -j D:\Desktop\hcc\123.txt -m {(set*)} -p {(*)} -r {(void)} |
| 116 | +``` |
| 117 | + |
| 118 | +## 例子3:查找特定类方法 |
| 119 | +1.继承xxxxx |
| 120 | +2.实现xxxxx的接口 |
| 121 | +3.方法名包含xxxx |
| 122 | +4.参数包含xxxx |
| 123 | +5.返回值是xxxx |
| 124 | +```python |
| 125 | +-j D:\Desktop\123.txt -m "{(class*)}{(<init>)}" -p {(java.util.List,java.lang.String)}{(void)} -r {(java.lang.String)}{(void)} -s org.example.class8 -i org.example.interfaces1,org.example.Interface2 |
| 126 | +``` |
| 127 | + |
| 128 | +## 例子4(这里就只扫描rt.jar): |
| 129 | + |
| 130 | +```python |
| 131 | +java -jar BytecodeScreen.jar -j D:\Desktop\123.txt -m "{(<init>)}{(set*)}" -p {(void)}{(java.lang.String)} -r {(void)}{(void)} -s java.awt.Component |
| 132 | +``` |
| 133 | + |
| 134 | +具体使用一共18种情况: |
| 135 | + |
0 commit comments