Skip to content

Commit c7a1f08

Browse files
committed
Try tigervnc to speed up GUI unit tests
- Rename strategy Normal to Union - Invite user to post missing strategy - Fix bug in SqlEngine presto
1 parent 8c7e4ff commit c7a1f08

File tree

106 files changed

+275
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+275
-274
lines changed

model/src/main/java/com/jsql/model/InjectionModel.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ public InjectionModel() {
118118
* Reset each injection attributes: Database metadata, General Thread status, Strategy.
119119
*/
120120
public void resetModel() {
121-
this.mediatorStrategy.getSpecificNormal().setVisibleIndex(null);
121+
this.mediatorStrategy.getSpecificUnion().setVisibleIndex(null);
122122

123-
this.mediatorStrategy.getNormal().setApplicable(false);
123+
this.mediatorStrategy.getUnion().setApplicable(false);
124124
this.mediatorStrategy.getError().setApplicable(false);
125125
this.mediatorStrategy.getBlind().setApplicable(false);
126126
this.mediatorStrategy.getMultibit().setApplicable(false);
@@ -530,10 +530,10 @@ private String initializeRawInjection(String paramLead, boolean isUsingIndex, St
530530
// in that case concat SQL expression to the end of param.
531531
query = paramLead + sqlTrail;
532532
} else {
533-
// Concat indexes found for Normal strategy to params
533+
// Concat indexes found for Union strategy to params
534534
// and use visible Index for injection
535535
query = paramLead + this.indexesInUrl.replaceAll(
536-
String.format(VendorYaml.FORMAT_INDEX, this.mediatorStrategy.getSpecificNormal().getVisibleIndex()),
536+
String.format(VendorYaml.FORMAT_INDEX, this.mediatorStrategy.getSpecificUnion().getVisibleIndex()),
537537
// Oracle column often contains $, which is reserved for regex.
538538
// => need to be escape with quoteReplacement()
539539
Matcher.quoteReplacement(sqlTrail)
@@ -555,12 +555,12 @@ private String initializeStarInjection(String paramLead, boolean isUsingIndex, S
555555
sqlTrail + this.mediatorVendor.getVendor().instance().endingComment()
556556
);
557557
} else {
558-
// Replace injection point by indexes found for Normal strategy
558+
// Replace injection point by indexes found for Union strategy
559559
// and use visible Index for injection
560560
query = paramLead.replace(
561561
InjectionModel.STAR,
562562
this.indexesInUrl.replace(
563-
String.format(VendorYaml.FORMAT_INDEX, this.mediatorStrategy.getSpecificNormal().getVisibleIndex()),
563+
String.format(VendorYaml.FORMAT_INDEX, this.mediatorStrategy.getSpecificUnion().getVisibleIndex()),
564564
sqlTrail
565565
)
566566
+ this.mediatorVendor.getVendor().instance().endingComment()

model/src/main/java/com/jsql/model/accessible/ResourceAccess.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public String createExploit(
276276
}
277277
};
278278

279-
var nbIndexesFound = this.injectionModel.getMediatorStrategy().getSpecificNormal().getNbIndexesFound() - 1;
279+
var nbIndexesFound = this.injectionModel.getMediatorStrategy().getSpecificUnion().getNbIndexesFound() - 1;
280280
String nameExploitValidated = StringUtils.EMPTY;
281281

282282
if (exploitMethod == ExploitMethod.NETSHARE) {
@@ -446,7 +446,7 @@ public String runWebShell(String command, UUID uuidShell, String urlExploit) {
446446
urlExploit + "?c="+ URLEncoder.encode(command.trim(), StandardCharsets.ISO_8859_1)
447447
);
448448
if (StringUtils.isBlank(result)) {
449-
// TODO Payload should redirect directly error to normal output
449+
// TODO Payload should redirect directly error to default output
450450
result = "No result.\nTry '"+ command.trim() +" 2>&1' to get a system error message.\n";
451451
}
452452

model/src/main/java/com/jsql/model/accessible/UdfAccess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void createUdf(String pathNetshareFolder, ExploitMethod exploitMethod) th
115115
return;
116116
}
117117

118-
var nbIndexesFound = this.injectionModel.getMediatorStrategy().getSpecificNormal().getNbIndexesFound() - 1;
118+
var nbIndexesFound = this.injectionModel.getMediatorStrategy().getSpecificUnion().getNbIndexesFound() - 1;
119119
var pathPlugin = this.getResult("select@@plugin_dir", "udf#dir");
120120
if (StringUtils.isEmpty(pathPlugin)) {
121121
throw new JSqlException("Incorrect plugin folder: path is empty");

model/src/main/java/com/jsql/model/bean/util/Interaction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public enum Interaction {
3838
MARK_ERROR_INVULNERABLE("MarkErrorInvulnerable"),
3939
MARK_ERROR_STRATEGY("MarkErrorStrategy"),
4040
MARK_ERROR_VULNERABLE("MarkErrorVulnerable"),
41-
MARK_NORMAL_INVULNERABLE("MarkNormalInvulnerable"),
42-
MARK_NORMAL_STRATEGY("MarkNormalStrategy"),
43-
MARK_NORMAL_VULNERABLE("MarkNormalVulnerable"),
41+
MARK_UNION_INVULNERABLE("MarkUnionInvulnerable"),
42+
MARK_UNION_STRATEGY("MarkUnionStrategy"),
43+
MARK_UNION_VULNERABLE("MarkUnionVulnerable"),
4444
MARK_TIME_INVULNERABLE("MarkTimeInvulnerable"),
4545
MARK_TIME_STRATEGY("MarkTimeStrategy"),
4646
MARK_TIME_VULNERABLE("MarkTimeVulnerable"),

model/src/main/java/com/jsql/model/exception/LoopDetectedSlidingException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
package com.jsql.model.exception;
1212

1313
/**
14-
* Exception class thrown during normal injection process,
14+
* Exception class thrown during injection process,
1515
* concerns every step when user interact with
1616
* database elements (database, table, column).
1717
*/

model/src/main/java/com/jsql/model/exception/StoppedByUserSlidingException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
package com.jsql.model.exception;
1212

1313
/**
14-
* Exception class thrown during normal injection process,
14+
* Exception class thrown during injection process,
1515
* concerns every step when user interact with
1616
* database elements (database, table, column).
1717
*/

model/src/main/java/com/jsql/model/injection/strategy/AbstractStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public abstract class AbstractStrategy {
1818

1919
protected static final String KEY_LOG_CHECKING_STRATEGY = "LOG_CHECKING_STRATEGY";
2020
protected static final String KEY_LOG_VULNERABLE = "LOG_VULNERABLE";
21-
protected static final String FORMAT_STRATEGY_NOT_IMPLEMENTED = "Strategy [{}] for [{}] missing";
21+
protected static final String FORMAT_STRATEGY_NOT_IMPLEMENTED = "Strategy [{}] for [{}] not implemented, speed up release by posting a working example to GitHub";
2222
protected static final String FORMAT_SKIP_STRATEGY_DISABLED = "Skipping strategy [{}] disabled";
2323
protected static final String FORMAT_CHECKING_STRATEGY = "{} [{}]...";
2424

@@ -56,7 +56,7 @@ protected AbstractStrategy(InjectionModel injectionModel) {
5656

5757
/**
5858
* Change model strategy to current applicable strategy only when not already set.
59-
* Normal > Stacked > Error > Multibit > Blind > Time
59+
* Union > Stacked > Error > Multibit > Blind > Time
6060
*/
6161
public abstract void activateWhenApplicable();
6262

model/src/main/java/com/jsql/model/injection/strategy/MediatorStrategy.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MediatorStrategy {
2727
private final AbstractStrategy blind;
2828
private final AbstractStrategy multibit;
2929
private final StrategyInjectionError error;
30-
private final AbstractStrategy normal;
30+
private final AbstractStrategy union;
3131
private final AbstractStrategy stack;
3232

3333
private final List<AbstractStrategy> strategies;
@@ -46,10 +46,10 @@ public MediatorStrategy(InjectionModel injectionModel) {
4646
this.blind = new StrategyInjectionBlind(this.injectionModel);
4747
this.multibit = new StrategyInjectionMultibit(this.injectionModel);
4848
this.error = new StrategyInjectionError(this.injectionModel);
49-
this.normal = new StrategyInjectionNormal(this.injectionModel);
49+
this.union = new StrategyInjectionUnion(this.injectionModel);
5050
this.stack = new StrategyInjectionStack(this.injectionModel);
5151

52-
this.strategies = Arrays.asList(this.time, this.blind, this.multibit, this.error, this.stack, this.normal);
52+
this.strategies = Arrays.asList(this.time, this.blind, this.multibit, this.error, this.stack, this.union);
5353
}
5454

5555
public String getMeta() {
@@ -83,7 +83,7 @@ public String buildPath(String urlBase, boolean isUsingIndex, String sqlTrail) {
8383
InjectionModel.STAR,
8484
this.encodePath(
8585
this.injectionModel.getIndexesInUrl().replaceAll(
86-
String.format(VendorYaml.FORMAT_INDEX, this.getSpecificNormal().getVisibleIndex()),
86+
String.format(VendorYaml.FORMAT_INDEX, this.getSpecificUnion().getVisibleIndex()),
8787
Matcher.quoteReplacement(sqlTrail) // Oracle column can contain regex char $ => quoteReplacement()
8888
)
8989
)
@@ -169,8 +169,8 @@ public boolean testStrategies(SimpleEntry<String, String> parameterToInject) thr
169169
new SuspendableGetVendor(this.injectionModel).run();
170170
}
171171

172-
// Test each injection strategies: time < blind < error < normal
173-
// Choose the most efficient strategy: normal > error > blind > time
172+
// Test each injection strategies: time < blind < error < union
173+
// Choose the most efficient strategy: union > error > blind > time
174174
this.time.checkApplicability();
175175
this.blind.checkApplicability();
176176

@@ -187,10 +187,10 @@ public boolean testStrategies(SimpleEntry<String, String> parameterToInject) thr
187187

188188
this.error.checkApplicability();
189189
this.stack.checkApplicability();
190-
this.normal.checkApplicability();
190+
this.union.checkApplicability();
191191

192192
// Set most efficient strategy
193-
this.normal.activateWhenApplicable();
193+
this.union.activateWhenApplicable();
194194
this.stack.activateWhenApplicable();
195195
this.error.activateWhenApplicable();
196196
this.multibit.activateWhenApplicable();
@@ -214,12 +214,12 @@ public boolean testStrategies(SimpleEntry<String, String> parameterToInject) thr
214214

215215
// Getter and setter
216216

217-
public AbstractStrategy getNormal() {
218-
return this.normal;
217+
public AbstractStrategy getUnion() {
218+
return this.union;
219219
}
220220

221-
public StrategyInjectionNormal getSpecificNormal() {
222-
return (StrategyInjectionNormal) this.normal;
221+
public StrategyInjectionUnion getSpecificUnion() {
222+
return (StrategyInjectionUnion) this.union;
223223
}
224224

225225
public StrategyInjectionError getError() {

model/src/main/java/com/jsql/model/injection/strategy/StrategyInjectionNormal.java renamed to model/src/main/java/com/jsql/model/injection/strategy/StrategyInjectionUnion.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.List;
2222
import java.util.regex.Pattern;
2323

24-
public class StrategyInjectionNormal extends AbstractStrategy {
24+
public class StrategyInjectionUnion extends AbstractStrategy {
2525

2626
/**
2727
* Log4j logger sent to view.
@@ -42,13 +42,13 @@ public class StrategyInjectionNormal extends AbstractStrategy {
4242

4343
private String performanceLength = "0";
4444

45-
public StrategyInjectionNormal(InjectionModel injectionModel) {
45+
public StrategyInjectionUnion(InjectionModel injectionModel) {
4646
super(injectionModel);
4747
}
4848

4949
@Override
5050
public void checkApplicability() throws JSqlException {
51-
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isStrategyNormalDisabled()) {
51+
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isStrategyUnionDisabled()) {
5252
LOGGER.log(LogLevelUtil.CONSOLE_INFORM, AbstractStrategy.FORMAT_SKIP_STRATEGY_DISABLED, this.getName());
5353
return;
5454
}
@@ -67,7 +67,7 @@ public void checkApplicability() throws JSqlException {
6767
}
6868

6969
this.isApplicable = StringUtils.isNotEmpty(this.injectionModel.getIndexesInUrl())
70-
&& Integer.parseInt(this.injectionModel.getMediatorStrategy().getNormal().getPerformanceLength()) > 0
70+
&& Integer.parseInt(this.injectionModel.getMediatorStrategy().getUnion().getPerformanceLength()) > 0
7171
&& StringUtils.isNotBlank(this.visibleIndex);
7272

7373
if (this.isApplicable) {
@@ -90,22 +90,22 @@ public void allow(int... i) {
9090
this.injectionModel.appendAnalysisReport(
9191
StringUtil.formatReport(LogLevelUtil.COLOR_BLU, "### Strategy: " + this.getName())
9292
+ this.injectionModel.getReportWithIndexes(
93-
this.injectionModel.getMediatorVendor().getVendor().instance().sqlNormal(StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "&lt;query&gt;"), "0", true),
93+
this.injectionModel.getMediatorVendor().getVendor().instance().sqlUnion(StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "&lt;query&gt;"), "0", true),
9494
"metadataInjectionProcess"
9595
)
9696
);
97-
this.markVulnerability(Interaction.MARK_NORMAL_VULNERABLE);
97+
this.markVulnerability(Interaction.MARK_UNION_VULNERABLE);
9898
}
9999

100100
@Override
101101
public void unallow(int... i) {
102-
this.markVulnerability(Interaction.MARK_NORMAL_INVULNERABLE);
102+
this.markVulnerability(Interaction.MARK_UNION_INVULNERABLE);
103103
}
104104

105105
@Override
106106
public String inject(String sqlQuery, String startPosition, AbstractSuspendable stoppable, String metadataInjectionProcess) {
107107
return this.injectionModel.injectWithIndexes(
108-
this.injectionModel.getMediatorVendor().getVendor().instance().sqlNormal(sqlQuery, startPosition, false),
108+
this.injectionModel.getMediatorVendor().getVendor().instance().sqlUnion(sqlQuery, startPosition, false),
109109
metadataInjectionProcess
110110
);
111111
}
@@ -119,10 +119,10 @@ public void activateWhenApplicable() {
119119
() -> I18nUtil.valueByKey("LOG_USING_STRATEGY"),
120120
this::getName
121121
);
122-
this.injectionModel.getMediatorStrategy().setStrategy(this.injectionModel.getMediatorStrategy().getNormal());
122+
this.injectionModel.getMediatorStrategy().setStrategy(this.injectionModel.getMediatorStrategy().getUnion());
123123

124124
var request = new Request();
125-
request.setMessage(Interaction.MARK_NORMAL_STRATEGY);
125+
request.setMessage(Interaction.MARK_UNION_STRATEGY);
126126
this.injectionModel.sendToViews(request);
127127
}
128128
}
@@ -158,7 +158,7 @@ public String getVisibleIndex(String firstSuccessPageSource) {
158158
// ==> ${lead}(index)######...######
159159
// Search for index that displays the most #
160160
String performanceQuery = this.injectionModel.getMediatorVendor().getVendor().instance().sqlCapacity(indexes);
161-
String performanceSourcePage = this.injectionModel.injectWithoutIndex(performanceQuery, "normal#size");
161+
String performanceSourcePage = this.injectionModel.injectWithoutIndex(performanceQuery, "union#size");
162162

163163
// Build a 2D array of string with:
164164
// column 1: index
@@ -213,7 +213,7 @@ public String getPerformanceLength() {
213213

214214
@Override
215215
public String getName() {
216-
return "Normal";
216+
return "Union";
217217
}
218218

219219
public String getVisibleIndex() {

model/src/main/java/com/jsql/model/injection/vendor/model/AbstractVendor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface AbstractVendor {
1818
String sqlColumns(Table table);
1919
String sqlRows(String[] arrayColumns, Database database, Table table);
2020

21-
String sqlNormal(String sqlQuery, String startPosition, boolean isReport);
21+
String sqlUnion(String sqlQuery, String startPosition, boolean isReport);
2222
String sqlErrorIndice(Method errorMethod);
2323
String sqlErrorCalibrator(Method errorMethod);
2424
String sqlError(String sqlQuery, String startPosition, int indexMethodError, boolean isReport);

0 commit comments

Comments
 (0)