1 package com.jsql.model.injection.strategy.blind.callable;
2
3 import com.jsql.model.InjectionModel;
4 import com.jsql.model.injection.strategy.blind.InjectionMultibit;
5 import name.fraser.neil.plaintext.diff_match_patch;
6 import static name.fraser.neil.plaintext.diff_match_patch.Diff;
7
8 import java.util.LinkedList;
9 import java.util.List;
10
11 public class CallableMultibit extends AbstractCallableBit<CallableMultibit> {
12
13 private LinkedList<Diff> diffsWithReference = new LinkedList<>();
14
15 private static final diff_match_patch DIFF_MATCH_PATCH = new diff_match_patch();
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 indexChar,
31 int block,
32 InjectionModel injectionModel,
33 InjectionMultibit injectionMultibit,
34 String metadataInjectionProcess
35 ) {
36 this(
37 injectionModel.getMediatorVendor().getVendor().instance().sqlMultibit(
38 sqlQuery,
39 indexChar,
40 3 * block - 2
41 ),
42 injectionMultibit,
43 metadataInjectionProcess
44 );
45 this.block = block;
46 this.currentIndex = indexChar;
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.diff_main(this.injectionMultibit.getSourceReference(), result, true);
53 CallableMultibit.DIFF_MATCH_PATCH.diff_cleanupEfficiency(this.diffsWithReference);
54
55 this.diffsWithReference.removeAll(this.injectionMultibit.getDiffsCommonWithAllIds());
56
57 for (int i = 0 ; i < this.injectionMultibit.getDiffsById().size() ; i++) {
58 if (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;
68 }
69
70 public List<Diff> getDiffsWithReference() {
71 return this.diffsWithReference;
72 }
73
74 public int getIdPage() {
75 return this.idPage;
76 }
77 }