(IHttpRequestResponse basePair, IScannerInsertionPoint insertionPoint)
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public List<IScanIssue> doActiveScan(IHttpRequestResponse basePair, IScannerInsertionPoint insertionPoint) { |
| 60 | String base = insertionPoint.getBaseValue(); |
| 61 | String initialResponse = safeBytesToString(basePair.getResponse()); |
| 62 | List<IScanIssue> issues = new ArrayList<>(); |
| 63 | Map<String, Check> checksCopy = new HashMap<>(this.checks); |
| 64 | |
| 65 | while (!checksCopy.isEmpty()) { |
| 66 | Map.Entry<String, Check> entry = checksCopy.entrySet().iterator().next(); |
| 67 | checksCopy.remove(entry.getKey()); |
| 68 | String name = entry.getKey(); |
| 69 | Check check = entry.getValue(); |
| 70 | |
| 71 | for (int attempt = 0; attempt < confirmCount; attempt++) { |
| 72 | Pair<String, List<String>> result = check.apply(base); |
| 73 | String probe = result.getKey(); |
| 74 | List<String> expect = result.getValue(); |
| 75 | |
| 76 | Utilities.log("Trying " + probe); |
| 77 | IHttpRequestResponse attack = OldUtilities.request2(basePair, insertionPoint, probe); |
| 78 | String attackResponse = safeBytesToString(attack.getResponse()); |
| 79 | |
| 80 | boolean matched = false; |
| 81 | for (String e : expect) { |
| 82 | if (attackResponse.contains(e) && !initialResponse.contains(e)) { |
| 83 | matched = true; |
| 84 | if (attempt == confirmCount - 1) { |
| 85 | issues.add(new CustomScanIssue( |
| 86 | attack.getHttpService(), |
| 87 | helpers.analyzeRequest(attack).getUrl(), |
| 88 | new IHttpRequestResponse[]{attack}, |
| 89 | "Suspicious input transformation: " + name, |
| 90 | "The application transforms input in a way that suggests it might be vulnerable to some kind of server-side code injection:<br/><br/> " |
| 91 | + "The following probe was sent: <b>" + probe + "</b><br/>" |
| 92 | + "The server response contained the evaluated result: <b>" + e + "</b><br/><br/>Manual investigation is advised.", |
| 93 | "Tentative", CustomScanIssue.severity.High)); |
| 94 | } |
| 95 | break; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if (!matched) { |
| 100 | break; |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return issues; |
| 106 | } |
| 107 | |
| 108 | @FunctionalInterface |
| 109 | private interface Check { |
nothing calls this directly
no test coverage detected