■ ■ ■ ■ ■ ■
src/burp/MutationGuesser.java
| skipped 30 lines |
31 | 31 | | public ArrayList<String> guessMutations() { |
32 | 32 | | byte[] baseReq = this.removeHeader(this.req.getRequest(), "Content-Length"); |
33 | 33 | | ArrayList<String> ret = new ArrayList<String>(); |
34 | | - | |
35 | | - | // Get the front-end error |
36 | | - | IHttpRequestResponse frontErrReq = this.requestHeader(baseReq, "Content-Length: z"); |
37 | | - | byte[] frontError = frontErrReq.getResponse(); |
38 | | - | |
39 | | - | // Check we've managed to generate an error |
40 | | - | IHttpRequestResponse noErrReq = this.requestHeader(baseReq, "Content-Length: 0"); |
41 | | - | byte[] noErr = noErrReq.getResponse(); |
42 | | - | if (this.requestMatch(frontError, noErr)) { |
43 | | - | Utilities.out("Failed to generate error against host " + this.service.getHost()); |
44 | | - | return ret; |
45 | | - | } |
| 34 | + | HeaderMutator mutator = new HeaderMutator(); |
46 | 35 | | |
47 | 36 | | // Test all the mutations to find back-end errors |
48 | | - | HeaderMutator mutator = new HeaderMutator(); |
49 | 37 | | for (int i = 0; i< this.testHeaders.length; i++) { |
50 | 38 | | Iterator<String> iterator = mutator.mutations.iterator(); |
51 | 39 | | String testHeaderValid = this.testHeaders[i][0]; |
52 | 40 | | String testHeaderInvalid = this.testHeaders[i][1]; |
| 41 | + | |
| 42 | + | // Get the front-end error |
| 43 | + | IHttpRequestResponse frontErrReq = this.requestHeader(baseReq, testHeaderInvalid); |
| 44 | + | byte[] frontError = frontErrReq.getResponse(); |
| 45 | + | |
| 46 | + | // Check we've managed to generate an error |
| 47 | + | IHttpRequestResponse noErrReq = this.requestHeader(baseReq, testHeaderValid); |
| 48 | + | byte[] noErr = noErrReq.getResponse(); |
| 49 | + | if (this.requestMatch(frontError, noErr)) { |
| 50 | + | continue; |
| 51 | + | } |
| 52 | + | |
| 53 | + | if (frontError.length == 0 || noErr.length == 0) { |
| 54 | + | String host = frontErrReq.getHttpService().getHost(); |
| 55 | + | Utilities.out("Failed to fetch request while guessing mutations " + host); |
| 56 | + | continue; |
| 57 | + | } |
| 58 | + | |
53 | 59 | | while (iterator.hasNext()) { |
54 | 60 | | String mutation = iterator.next(); |
55 | 61 | | if (ret.contains(mutation)) { |
| skipped 46 lines |
102 | 108 | | int start = offsets[0]; |
103 | 109 | | int end = offsets[2] + 2; |
104 | 110 | | byte[] ret = new byte[req.length - (end - start)]; |
| 111 | + | // TODO: sometimes getting null point exceptions from this line |
105 | 112 | | System.arraycopy(req, 0, ret, 0, start); |
106 | 113 | | System.arraycopy(req, end, ret, start, req.length - end); |
107 | 114 | | return ret; |
| skipped 42 lines |