|
21 | 21 |
|
22 | 22 | import java.util.Iterator;
|
23 | 23 | import java.util.LinkedHashMap;
|
| 24 | +import java.util.List; |
24 | 25 | import java.util.Map;
|
25 | 26 | import java.util.regex.Matcher;
|
26 | 27 | import java.util.regex.Pattern;
|
@@ -105,21 +106,32 @@ public void scanHttpResponseReceive(HttpMessage msg, int id, Source source) {
|
105 | 106 | }
|
106 | 107 | if (evidence != null && evidence.length() > 0) {
|
107 | 108 | // we found something
|
108 |
| - newAlert() |
109 |
| - .setName(getName() + " - " + server) |
110 |
| - .setRisk(Alert.RISK_MEDIUM) |
111 |
| - .setConfidence(Alert.CONFIDENCE_MEDIUM) |
112 |
| - .setDescription(getDescription() + " - " + server) |
113 |
| - .setOtherInfo(getExtraInfo(msg, evidence)) |
114 |
| - .setSolution(getSolution()) |
115 |
| - .setReference(getReference()) |
116 |
| - .setEvidence(evidence) |
117 |
| - .setCweId(548) // Information Exposure Through Directory Listing |
118 |
| - .setWascId(16) // Directory Indexing |
119 |
| - .raise(); |
| 109 | + buildAlert(server, evidence).raise(); |
120 | 110 | }
|
121 | 111 | }
|
122 | 112 |
|
| 113 | + private AlertBuilder buildAlert(String server, String evidence) { |
| 114 | + return newAlert() |
| 115 | + .setName(getName() + " - " + server) |
| 116 | + .setRisk(Alert.RISK_MEDIUM) |
| 117 | + .setConfidence(Alert.CONFIDENCE_MEDIUM) |
| 118 | + .setDescription(getDescription() + " - " + server) |
| 119 | + .setOtherInfo(getExtraInfo(evidence)) |
| 120 | + .setSolution(getSolution()) |
| 121 | + .setReference(getReference()) |
| 122 | + .setEvidence(evidence) |
| 123 | + .setCweId(548) // Information Exposure Through Directory Listing |
| 124 | + .setWascId(16); // Directory Indexing |
| 125 | + } |
| 126 | + |
| 127 | + @Override |
| 128 | + public List<Alert> getExampleAlerts() { |
| 129 | + return List.of( |
| 130 | + buildAlert("Apache 2", "<html><title>Index of /htdocs</title></html>").build(), |
| 131 | + buildAlert("Microsoft IIS", "<pre><A HREF=\"/\">[To Parent Directory]</A><br><br>") |
| 132 | + .build()); |
| 133 | + } |
| 134 | + |
123 | 135 | /**
|
124 | 136 | * get the id of the scanner
|
125 | 137 | *
|
@@ -160,11 +172,10 @@ private String getReference() {
|
160 | 172 | /**
|
161 | 173 | * gets extra information associated with the alert
|
162 | 174 | *
|
163 |
| - * @param msg |
164 | 175 | * @param arg0
|
165 | 176 | * @return
|
166 | 177 | */
|
167 |
| - private String getExtraInfo(HttpMessage msg, String arg0) { |
| 178 | + private String getExtraInfo(String arg0) { |
168 | 179 | return Constant.messages.getString(MESSAGE_PREFIX + "extrainfo", arg0);
|
169 | 180 | }
|
170 | 181 |
|
|
0 commit comments