-
Notifications
You must be signed in to change notification settings - Fork 180
Expand file tree
/
Copy pathApiScanner.java
More file actions
39 lines (34 loc) · 1.53 KB
/
ApiScanner.java
File metadata and controls
39 lines (34 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package burp.application;
import burp.BurpExtender;
import burp.IHttpRequestResponse;
import burp.application.apitypes.ApiType;
import burp.application.apitypes.actuator.ApiTypeActuator;
import burp.application.apitypes.graphql.ApiTypeGraphQL;
import burp.application.apitypes.soap.ApiTypeSoap;
import burp.application.apitypes.swagger.ApiTypeSwagger;
import burp.utils.CommonUtils;
import java.util.ArrayList;
import java.util.function.BiFunction;
public class ApiScanner {
private final ArrayList<BiFunction<IHttpRequestResponse, Boolean, ApiType>> apiTypeConstructors = new ArrayList<>();
public ApiScanner() {
this.apiTypeConstructors.add(ApiTypeActuator::newInstance);
this.apiTypeConstructors.add(ApiTypeSwagger::newInstance);
this.apiTypeConstructors.add(ApiTypeGraphQL::newInstance);
this.apiTypeConstructors.add(ApiTypeSoap::newInstance);
}
public ArrayList<ApiType> detect(IHttpRequestResponse baseRequestResponse, boolean isPassive) {
ArrayList<ApiType> apiTypes = new ArrayList<>();
for (BiFunction<IHttpRequestResponse, Boolean, ApiType> apiTypeConstructor : apiTypeConstructors) {
try {
ApiType apiType = apiTypeConstructor.apply(baseRequestResponse, isPassive);
if (apiType.isFingerprintMatch()) {
apiTypes.add(apiType);
}
} catch (Exception e) {
BurpExtender.getStderr().println(CommonUtils.exceptionToString(e));
}
}
return apiTypes;
}
}