fix bug
This commit is contained in:
@@ -37,7 +37,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//更新header
|
//更新header
|
||||||
byte[] newMessage = BurpExtender.helpers.buildHttpMessage(headers, getHttpRequestBody(currentRequest).getBytes());
|
byte[] newMessage = BurpExtender.helpers.buildHttpMessage(headers, getHttpRequestBody(currentRequest));
|
||||||
currentRequest.setRequest(newMessage);
|
currentRequest.setRequest(newMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,38 +45,29 @@ public class Utils {
|
|||||||
|
|
||||||
public static void addfakeip(IHttpRequestResponse iHttpRequestResponse, String ip) {
|
public static void addfakeip(IHttpRequestResponse iHttpRequestResponse, String ip) {
|
||||||
|
|
||||||
|
//获取原请求信息
|
||||||
|
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(iHttpRequestResponse);
|
||||||
|
List<String> headers = requestInfo.getHeaders();
|
||||||
|
|
||||||
byte contentType = BurpExtender.helpers.analyzeRequest(iHttpRequestResponse).getContentType();
|
//为每个请求添加一个Header
|
||||||
|
headers = headers.stream().filter(key -> !key.equals(Config.AUTOXFF_KEY)).collect(Collectors.toList());
|
||||||
|
headers.add(String.format("%s: %s", Config.AUTOXFF_KEY, ip));
|
||||||
|
|
||||||
if (contentType != CONTENT_TYPE_MULTIPART) {
|
//更新header
|
||||||
//获取原请求信息
|
byte[] newMessage = BurpExtender.helpers.buildHttpMessage(headers, getHttpRequestBody(iHttpRequestResponse));
|
||||||
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(iHttpRequestResponse);
|
iHttpRequestResponse.setRequest(newMessage);
|
||||||
List<String> headers = requestInfo.getHeaders();
|
|
||||||
|
|
||||||
//为每个请求添加一个Header
|
|
||||||
headers = headers.stream().filter(key -> !key.equals(Config.AUTOXFF_KEY)).collect(Collectors.toList());
|
|
||||||
headers.add(String.format("%s: %s", Config.AUTOXFF_KEY, ip));
|
|
||||||
|
|
||||||
//更新header
|
|
||||||
byte[] newMessage = BurpExtender.helpers.buildHttpMessage(headers, getHttpRequestBody(iHttpRequestResponse).getBytes());
|
|
||||||
iHttpRequestResponse.setRequest(newMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getHttpRequestBody(IHttpRequestResponse httpRequestResponse) {
|
private static byte[] getHttpRequestBody(IHttpRequestResponse httpRequestResponse) {
|
||||||
byte[] request = httpRequestResponse.getRequest();
|
byte[] request = httpRequestResponse.getRequest();
|
||||||
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(request);
|
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(request);
|
||||||
|
|
||||||
int httpBodyOffset = requestInfo.getBodyOffset();
|
int httpBodyOffset = requestInfo.getBodyOffset();
|
||||||
int httpBodyLength = request.length - httpBodyOffset;
|
int httpBodyLength = request.length - httpBodyOffset;
|
||||||
String httpBody = null;
|
byte[] httpBody = new byte[httpBodyLength];
|
||||||
try {
|
System.arraycopy(request,httpBodyOffset,httpBody,0,httpBodyLength);
|
||||||
httpBody = new String(request, httpBodyOffset, httpBodyLength, "UTF-8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return httpBody;
|
return httpBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user