Version: 3.3 Update

This commit is contained in:
gh0stkey
2024-07-23 09:21:30 +08:00
parent e4b7f86a0c
commit 5f54d1f461
19 changed files with 1166 additions and 644 deletions

View File

@@ -0,0 +1,42 @@
package hae.utils.http;
import burp.api.montoya.MontoyaApi;
import burp.api.montoya.http.HttpService;
import burp.api.montoya.http.message.requests.HttpRequest;
import burp.api.montoya.http.message.requests.HttpTransformation;
import burp.api.montoya.utilities.RandomUtils;
public class HttpUtils {
private final MontoyaApi api;
public HttpUtils(MontoyaApi api) {
this.api = api;
}
public HttpRequest generateRequestByMultipartUploadMethod(String url, String name, String filename, String content) {
HttpRequest baseRequest = HttpRequest.httpRequestFromUrl(url).withTransformationApplied(HttpTransformation.TOGGLE_METHOD);
String boundary = api.utilities().randomUtils().randomString(32, RandomUtils.CharacterSet.ASCII_LETTERS);
StringBuilder newBody = new StringBuilder();
newBody.append(String.format("--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n\r\n%s\r\n", boundary, name, filename, content));
newBody.append(String.format("--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n%s\r\n", boundary, "purpose", "file-extract"));
newBody.append("--").append(boundary).append("--\r\n");
baseRequest = baseRequest.withUpdatedHeader("Content-Type", "multipart/form-data; boundary=" + boundary).withBody(newBody.toString());
return baseRequest;
}
public HttpRequest generateRequestByJsonMethod(String url, String data) {
HttpRequest baseRequest = HttpRequest.httpRequestFromUrl(url).withTransformationApplied(HttpTransformation.TOGGLE_METHOD);
HttpService baseService = baseRequest.httpService();
String requestString = baseRequest.toString().replace("application/x-www-form-urlencoded", "application/json");
baseRequest = HttpRequest.httpRequest(baseService, requestString).withBody(data);
return baseRequest;
}
public HttpRequest generateRequestByDeleteMethod(String url) {
return HttpRequest.httpRequestFromUrl(url).withMethod("DELETE");
}
}