View Javadoc
1   package com.jsql.model.injection.strategy.blind;
2   
3   import com.jsql.model.injection.strategy.blind.patch.Diff;
4   import com.jsql.model.injection.strategy.blind.patch.DiffMatchPatch;
5   
6   import java.util.LinkedList;
7   import java.util.List;
8   import java.util.concurrent.CopyOnWriteArrayList;
9   
10  public class CallableVendor extends AbstractCallableBinary<CallableVendor> {
11  
12      // List of differences found between the reference page, and the present page
13      private LinkedList<Diff> opcodes = new LinkedList<>();
14  
15      private static final DiffMatchPatch DIFF_MATCH_PATCH = new DiffMatchPatch();
16  
17      private final InjectionVendor injectionCharInsertion;
18  
19      private final String metadataInjectionProcess;
20  
21      public CallableVendor(String inj, InjectionVendor injectionCharInsertion, String metadataInjectionProcess) {
22          this.injectionCharInsertion = injectionCharInsertion;
23          this.metadataInjectionProcess = metadataInjectionProcess;
24          this.booleanUrl = inj;
25      }
26  
27      @Override
28      public boolean isTrue() {
29          List<Diff> copyTrueMarks = new CopyOnWriteArrayList<>(this.injectionCharInsertion.getConstantTrueMark());
30          for (Diff trueDiff: copyTrueMarks) {
31              if (!this.opcodes.contains(trueDiff)) {
32                  return false;
33              }
34          }
35          return true;
36      }
37  
38      @Override
39      public CallableVendor call() {
40          String source = this.injectionCharInsertion.callUrl(this.booleanUrl, this.metadataInjectionProcess, this);
41          this.opcodes = CallableVendor.DIFF_MATCH_PATCH.diffMain(
42              this.injectionCharInsertion.getBlankFalseMark(),
43              source,
44              false
45          );
46          CallableVendor.DIFF_MATCH_PATCH.diffCleanupEfficiency(this.opcodes);
47          return this;
48      }
49      
50      public List<Diff> getOpcodes() {
51          return this.opcodes;
52      }
53  }