(int toolFlag, boolean messageIsRequest, IHttpRequestResponse iHttpRequestResponse)
| 171 | } |
| 172 | |
| 173 | @Override |
| 174 | public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse iHttpRequestResponse) { //处理请求包 |
| 175 | usehttps = iHttpRequestResponse.getHttpService().getProtocol().contains("https"); |
| 176 | |
| 177 | // 启用替换 |
| 178 | if ( getRadioButtonUseReqpState() && ( ( toolFlag == IBurpExtenderCallbacks.TOOL_PROXY && getRadioButtonReqp111State() ) || ( toolFlag == IBurpExtenderCallbacks.TOOL_REPEATER && getRadioButtonReqp222State() ) || |
| 179 | ( toolFlag == IBurpExtenderCallbacks.TOOL_INTRUDER && getRadioButtonReqp333State() )|| (toolFlag == IBurpExtenderCallbacks.TOOL_EXTENDER && getRadioButtonReqp444State() ) )){ |
| 180 | List<String> row_use = new ArrayList<>(); |
| 181 | // 处理request header头 |
| 182 | for ( int row = 0 ;row <= table.getRowCount()-1; row ++) { |
| 183 | if ( (Boolean)table.getValueAt(row, 0) ) // 获取enable参数 |
| 184 | row_use.add(String.valueOf(row));// 将enable参数为true的写入list里 |
| 185 | } |
| 186 | |
| 187 | // 请求有关的参数 |
| 188 | byte[] request = iHttpRequestResponse.getRequest(); |
| 189 | IRequestInfo iRequestInfo = helpers.analyzeRequest(iHttpRequestResponse); |
| 190 | // 获取请求中的所有参数 |
| 191 | |
| 192 | |
| 193 | if(messageIsRequest && row_use.size() > 0) { |
| 194 | |
| 195 | |
| 196 | List<String> headersList = iRequestInfo.getHeaders(); |
| 197 | |
| 198 | String headers_total = ""; |
| 199 | String host_value = ""; |
| 200 | for (String header : headersList) { |
| 201 | headers_total = headers_total + header + ("\r\n"); |
| 202 | String[] host_lists = header.split(":"); |
| 203 | if (host_lists[0].toLowerCase().equals("host")) { |
| 204 | host_value = host_lists[1]; |
| 205 | } |
| 206 | } |
| 207 | int bodyOffset = iRequestInfo.getBodyOffset(); |
| 208 | |
| 209 | byte[] body = Arrays.copyOfRange(request, bodyOffset, request.length); |
| 210 | String code_body = new String(body); |
| 211 | |
| 212 | for (String row : row_use){ //对启用的规则进行替换 |
| 213 | ishostReqp = false; |
| 214 | if ( table.getValueAt(Integer.parseInt(row), 1).toString().equals("*") ){ // Host |
| 215 | ishostReqp = true; |
| 216 | }else if(host_value.equals(table.getValueAt(Integer.parseInt(row), 1).toString())) ishostReqp = true; |
| 217 | else if (host_value.endsWith(table.getValueAt(Integer.parseInt(row), 1).toString().replace("*",""))) ishostReqp = true; |
| 218 | if (ishostReqp) { |
| 219 | String Item = table.getValueAt(Integer.parseInt(row), 2).toString(); //Item |
| 220 | String Match = table.getValueAt(Integer.parseInt(row), 3).toString(); //Match |
| 221 | String Replace = table.getValueAt(Integer.parseInt(row), 4).toString(); //Replace |
| 222 | String Type = table.getValueAt(Integer.parseInt(row), 5).toString(); //Type |
| 223 | String[] total = MatchandReplace(headers_total, code_body, Type, Item, Match, Replace, REQUEST); |
| 224 | headers_total = total[0]; |
| 225 | code_body = total[1]; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | List<String> end_headerstotallist = Arrays.asList(headers_total.split("\r\n")); |
| 230 |
nothing calls this directly
no test coverage detected