View Javadoc
1   package com.jsql.model.injection.strategy.blind.callable;
2   
3   import com.jsql.model.injection.strategy.blind.InjectionVendor;
4   import name.fraser.neil.plaintext.diff_match_patch;
5   import static name.fraser.neil.plaintext.diff_match_patch.Diff;
6   
7   import java.util.LinkedList;
8   import java.util.List;
9   import java.util.concurrent.CopyOnWriteArrayList;
10  
11  public class CallableVendor extends AbstractCallableBit<CallableVendor> {
12  
13      private LinkedList<Diff> opcodes = new LinkedList<>();  // List of differences found between the reference page, and the present page
14  
15      private static final diff_match_patch DIFF_MATCH_PATCH = new diff_match_patch();
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.diff_main(
42              this.injectionCharInsertion.getBlankFalseMark(),
43              source,
44              false
45          );
46          CallableVendor.DIFF_MATCH_PATCH.diff_cleanupEfficiency(this.opcodes);
47          return this;
48      }
49      
50      public List<Diff> getOpcodes() {
51          return this.opcodes;
52      }
53  }