View Javadoc
1   package com.jsql.model.injection.strategy.blind;
2   
3   import com.jsql.model.InjectionModel;
4   import com.jsql.model.injection.strategy.blind.patch.Diff;
5   import com.jsql.model.injection.strategy.blind.patch.DiffMatchPatch;
6   
7   import java.util.HashSet;
8   import java.util.LinkedList;
9   import java.util.List;
10  
11  public class CallableMultibit extends AbstractCallableBinary<CallableMultibit> {
12  
13      private LinkedList<Diff> diffsWithReference = new LinkedList<>();
14  
15      private static final DiffMatchPatch DIFF_MATCH_PATCH = new DiffMatchPatch();
16  
17      private final InjectionMultibit injectionMultibit;
18  
19      private final String metadataInjectionProcess;
20  
21      public CallableMultibit(String sqlQuery, InjectionMultibit injectionMultibit, String metadataInjectionProcess) {
22          this.injectionMultibit = injectionMultibit;
23          this.metadataInjectionProcess = metadataInjectionProcess;
24          this.booleanUrl = sqlQuery;
25          this.isMultibit = true;
26      }
27  
28      public CallableMultibit(
29          String sqlQuery,
30          int indexCharacter,
31          int block,
32          InjectionModel injectionModel,
33          InjectionMultibit injectionMultibit,
34          String metadataInjectionProcess
35      ) {
36          this(
37              injectionModel.getMediatorVendor().getVendor().instance().sqlMultibit(
38                  sqlQuery,
39                  indexCharacter,
40                  3 * block - 2
41              ),
42              injectionMultibit,
43              metadataInjectionProcess
44          );
45          this.block = block;
46          this.currentIndex = indexCharacter;
47      }
48  
49      @Override
50      public CallableMultibit call() {
51          String result = this.injectionMultibit.callUrl(this.booleanUrl, this.metadataInjectionProcess, this);
52          this.diffsWithReference = CallableMultibit.DIFF_MATCH_PATCH.diffMain(this.injectionMultibit.getSourceReference(), result, true);
53          CallableMultibit.DIFF_MATCH_PATCH.diffCleanupEfficiency(this.diffsWithReference);
54  
55          this.diffsWithReference.removeAll(this.injectionMultibit.getDiffsCommonWithAllIds());
56  
57          for (int i = 0; i < this.injectionMultibit.getDiffsById().size() ; i++) {
58              if (new HashSet<>(this.injectionMultibit.getDiffsById().get(i)).containsAll(this.diffsWithReference)) {
59                  this.idPage = i;
60              }
61          }
62          return this;
63      }
64  
65      @Override
66      public boolean isTrue() {
67          return false;  // ignored
68      }
69  
70      public List<Diff> getDiffsWithReference() {
71          return this.diffsWithReference;
72      }
73      public int getIdPage() {
74          return this.idPage;
75      }
76  }