()
| 100 | } |
| 101 | |
| 102 | public Object isGadgetChain() { |
| 103 | ObjectMapper mapper = new ObjectMapper(); |
| 104 | JsonNode node = null; |
| 105 | try { |
| 106 | node = mapper.readTree(getData("NewChains(1)")); |
| 107 | } catch (IOException e) { |
| 108 | e.printStackTrace(); |
| 109 | } |
| 110 | |
| 111 | //将Json串以树状结构读入内存 |
| 112 | assert node != null; |
| 113 | JsonNode results = node.get("results");//得到results这个节点下的信息 |
| 114 | |
| 115 | Object object_input = null; |
| 116 | System.out.println("-----------------正在载入数据,当前数据集中包含" + results.size() + "条调用链-----------------"); |
| 117 | for (int i=0;i<results.size();i++) { |
| 118 | System.out.println("------------------------当前验证第" + (i+1) + "条潜在调用链-----------------------"); |
| 119 | int SourceID = results.get(i).get("sourceID").intValue(); |
| 120 | int SinkID = results.get(i).get("sinkID").intValue(); |
| 121 | System.out.println( "Source:" + get_ClassName(results, i, SourceID) + "." + get_MethodName(results, i, SourceID)); |
| 122 | System.out.println( "Sink:" + get_ClassName(results, i, SinkID) + "." + get_MethodName(results, i, SinkID)); |
| 123 | |
| 124 | try { |
| 125 | object_input = object_init(get_ClassName(results, i, SourceID)); |
| 126 | } catch (Exception e) { |
| 127 | e.printStackTrace(); |
| 128 | } |
| 129 | ArrayList<Object> object_list = new ArrayList<>(); |
| 130 | object_list.add(object_input); |
| 131 | |
| 132 | JsonNode Edges = results.get(i).get("Edges"); |
| 133 | a:for (int j = 0; j < Edges.size(); j++ ) { |
| 134 | String relation = Edges.get(j).get("edge").textValue(); |
| 135 | try { |
| 136 | if (relation.equals("ALIAS") && |
| 137 | !(Modifier.isAbstract(Class.forName(get_ClassName(results, i, get_ReflectClassId(Edges, j)[1])).getModifiers()))) { |
| 138 | String ReflectClass = get_ClassName(results, i, get_ReflectClassId(Edges, j)[1]); |
| 139 | j = get_ReflectClassId(Edges, j)[0]; |
| 140 | System.out.println("待实例化的类为:" + ReflectClass); |
| 141 | Class<?> clazz = null; |
| 142 | try { |
| 143 | clazz = Class.forName(ReflectClass); |
| 144 | } catch (ClassNotFoundException e) { |
| 145 | e.printStackTrace(); |
| 146 | } |
| 147 | assert clazz != null; |
| 148 | Class<?>[] interfaces = clazz.getInterfaces(); |
| 149 | String Polluted_Class = null; |
| 150 | int flag = 0; |
| 151 | int number_of_interfaces = 1; |
| 152 | b:for (Class<?> inter : interfaces) { |
| 153 | if (inter.getName().equals("java.io.Serializable")) { |
| 154 | flag = 1; |
| 155 | number_of_interfaces++; |
| 156 | continue; |
| 157 | } |
| 158 | Polluted_Class = inter.getName(); |
| 159 | System.out.println("待赋值的属性类型为:" + Polluted_Class); |
nothing calls this directly
no test coverage detected