1 | package com.jsql.model.injection.vendor.model; | |
2 | ||
3 | import com.jsql.model.InjectionModel; | |
4 | import com.jsql.model.bean.database.Database; | |
5 | import com.jsql.model.bean.database.Table; | |
6 | import com.jsql.model.injection.strategy.blind.AbstractInjectionBit.BlindOperator; | |
7 | import com.jsql.model.injection.vendor.model.yaml.Method; | |
8 | import com.jsql.model.injection.vendor.model.yaml.ModelYaml; | |
9 | import com.jsql.util.LogLevelUtil; | |
10 | import com.jsql.util.StringUtil; | |
11 | import org.apache.commons.codec.binary.Hex; | |
12 | import org.apache.commons.lang3.RandomStringUtils; | |
13 | import org.apache.commons.lang3.StringUtils; | |
14 | import org.apache.logging.log4j.LogManager; | |
15 | import org.apache.logging.log4j.Logger; | |
16 | import org.yaml.snakeyaml.Yaml; | |
17 | ||
18 | import java.net.URLEncoder; | |
19 | import java.nio.charset.StandardCharsets; | |
20 | import java.util.ArrayList; | |
21 | import java.util.Collections; | |
22 | import java.util.List; | |
23 | import java.util.regex.Pattern; | |
24 | ||
25 | import static com.jsql.model.accessible.DataAccess.*; | |
26 | ||
27 | public class VendorYaml implements AbstractVendor { | |
28 | | |
29 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
30 | ||
31 | /** | |
32 | * SQL characters marking the end of the result of an injection. | |
33 | * Process stops when this schema is encountered: | |
34 | * <pre>SqLix01x03x03x07 | |
35 | */ | |
36 | public static final String LEAD_HEX = "0x53714c69"; | |
37 | public static final String LEAD_PIPE = "Sq'||'Li"; | |
38 | public static final String TRAIL_SQL = "%01%03%03%07"; | |
39 | public static final String TRAIL_HEX = "0x01030307"; | |
40 | ||
41 | /** | |
42 | * SQL character used between each table cells. | |
43 | * Expected schema of multiple table cells : | |
44 | * <pre> | |
45 | * %04[table cell]%05[number of occurrences]%04%06%04[table cell]%05[number of occurrences]%04 | |
46 | */ | |
47 | public static final String SEPARATOR_CELL_SQL = "%06"; | |
48 | public static final String SEPARATOR_CELL_HEX = "0x06"; | |
49 | ||
50 | public static final String ENCLOSE_VALUE_HEX = "0x04"; | |
51 | ||
52 | /** | |
53 | * SQL character used between the table cell and the number of occurrence of the cell text. | |
54 | * Expected schema of a table cell data is | |
55 | * <pre>%04[table cell]%05[number of occurrences]%04 | |
56 | */ | |
57 | public static final String SEPARATOR_QTE_SQL = "%05"; | |
58 | public static final String SEPARATOR_QTE_HEX = "0x05"; | |
59 | ||
60 | /** | |
61 | * SQL character enclosing a table cell returned by injection. | |
62 | * It allows to detect the correct end of a table cell data during parsing. | |
63 | * Expected schema of a table cell data is | |
64 | * <pre>%04[table cell]%05[number of occurrences]%04 | |
65 | */ | |
66 | public static final String ENCLOSE_VALUE_SQL = "%04"; | |
67 | ||
68 | public static final String CALIBRATOR_SQL = "a"; | |
69 | public static final String CALIBRATOR_HEX = "0x61"; | |
70 | | |
71 | public static final String FORMAT_INDEX = "1337%s7331"; | |
72 | ||
73 | private static final String BINARY_MODE = "${binary.mode}"; | |
74 | public static final String LIMIT = "${limit}"; | |
75 | private static final String LIMIT_VALUE = "${limit.value}"; | |
76 | private static final String RESULT_RANGE = "${result_range}"; | |
77 | private static final String INDICE_UNIQUE = "${indice_unique}"; | |
78 | private static final String CALIBRATOR = "${calibrator}"; | |
79 | private static final String INDICES = "${indices}"; | |
80 | public static final String INDICE = "${indice}"; | |
81 | public static final String WINDOW_CHAR = "${window.char}"; | |
82 | public static final String BLOCK_MULTIBIT = "${multibit.block}"; | |
83 | public static final String WINDOW = "${window}"; | |
84 | public static final String CAPACITY = "${capacity}"; | |
85 | public static final String DEFAULT_CAPACITY = "65565"; | |
86 | private static final String SLEEP_TIME = "${sleep_time}"; | |
87 | private static final String BIT = "${bit}"; | |
88 | private static final String MID_CHR = "${mid}"; | |
89 | private static final String MID_INT = "${mid.int}"; | |
90 | public static final String INJECTION = "${injection}"; | |
91 | public static final String TEST = "${test}"; | |
92 | public static final String FILEPATH_HEX = "${filepath.hex}"; | |
93 | private static final String FIELDS = "${fields}"; | |
94 | private static final String FIELD = "${field.value}"; | |
95 | private static final String TABLE = "${table}"; | |
96 | private static final String DATABASE = "${database}"; | |
97 | private static final String TABLE_HEX = "${table.hex}"; | |
98 | private static final String DATABASE_HEX = "${database.hex}"; | |
99 | | |
100 | private final ModelYaml modelYaml; | |
101 | private final InjectionModel injectionModel; | |
102 | | |
103 | public VendorYaml(String fileYaml, InjectionModel injectionModel) { | |
104 | this.injectionModel = injectionModel; | |
105 | var yaml = new Yaml(); | |
106 | this.modelYaml = yaml.loadAs( | |
107 | VendorYaml.class.getClassLoader().getResourceAsStream("vendor/"+ fileYaml), | |
108 | ModelYaml.class | |
109 | ); | |
110 | } | |
111 | ||
112 | @Override | |
113 | public String sqlDatabases() { | |
114 | String sqlQuery = this.modelYaml.getResource().getSchema().getDatabase(); | |
115 | | |
116 |
1
1. sqlDatabases : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) { |
117 |
1
1. sqlDatabases : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getDatabase())) { |
118 | sqlQuery = this.modelYaml.getResource().getDios().getDatabase(); | |
119 | } else { | |
120 | LOGGER.log( | |
121 | LogLevelUtil.CONSOLE_INFORM, | |
122 | "Strategy [Dios] activated but database query is undefined for [{}], fallback to default", | |
123 |
1
1. lambda$sqlDatabases$0 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlDatabases$0 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
124 | ); | |
125 | } | |
126 |
1
1. sqlDatabases : negated conditional → NO_COVERAGE |
} else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) { |
127 |
1
1. sqlDatabases : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getDatabase())) { |
128 | sqlQuery = this.modelYaml.getResource().getZip().getDatabase(); | |
129 | } else { | |
130 | LOGGER.log( | |
131 | LogLevelUtil.CONSOLE_INFORM, | |
132 | "Strategy [Zip] activated but database query is undefined for [{}], fallback to default", | |
133 |
1
1. lambda$sqlDatabases$1 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlDatabases$1 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
134 | ); | |
135 | } | |
136 | } | |
137 |
1
1. sqlDatabases : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlDatabases → NO_COVERAGE |
return sqlQuery; |
138 | } | |
139 | | |
140 | @Override | |
141 | public String sqlTables(Database database) { | |
142 | String sqlQuery = this.modelYaml.getResource().getSchema().getTable(); | |
143 | | |
144 |
1
1. sqlTables : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) { |
145 |
1
1. sqlTables : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getTable())) { |
146 | sqlQuery = this.modelYaml.getResource().getDios().getTable(); | |
147 | } else { | |
148 | LOGGER.log( | |
149 | LogLevelUtil.CONSOLE_INFORM, | |
150 | "Strategy [Dios] activated but table query is undefined for [{}], fallback to default", | |
151 |
1
1. lambda$sqlTables$2 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlTables$2 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
152 | ); | |
153 | } | |
154 |
1
1. sqlTables : negated conditional → NO_COVERAGE |
} else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) { |
155 |
1
1. sqlTables : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getTable())) { |
156 | sqlQuery = this.modelYaml.getResource().getZip().getTable(); | |
157 | } else { | |
158 | LOGGER.log( | |
159 | LogLevelUtil.CONSOLE_INFORM, | |
160 | "Strategy [Zip] activated but table query is undefined for [{}], fallback to default", | |
161 |
1
1. lambda$sqlTables$3 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlTables$3 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
162 | ); | |
163 | } | |
164 | } | |
165 | | |
166 | String databaseUtf8 = Hex.encodeHexString(database.toString().getBytes(StandardCharsets.UTF_8)); | |
167 |
1
1. sqlTables : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTables → NO_COVERAGE |
return sqlQuery |
168 | .replace(VendorYaml.DATABASE_HEX, databaseUtf8) | |
169 | .replace(VendorYaml.DATABASE, database.toString()); | |
170 | } | |
171 | ||
172 | @Override | |
173 | public String sqlColumns(Table table) { | |
174 | String sqlQuery = this.modelYaml.getResource().getSchema().getColumn(); | |
175 | | |
176 |
1
1. sqlColumns : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) { |
177 |
1
1. sqlColumns : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getColumn())) { |
178 | sqlQuery = this.modelYaml.getResource().getDios().getColumn(); | |
179 | } else { | |
180 | LOGGER.log( | |
181 | LogLevelUtil.CONSOLE_INFORM, | |
182 | "Strategy [Dios] activated but column query is undefined for [{}], fallback to default", | |
183 |
1
1. lambda$sqlColumns$4 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlColumns$4 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
184 | ); | |
185 | } | |
186 |
1
1. sqlColumns : negated conditional → NO_COVERAGE |
} else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) { |
187 |
1
1. sqlColumns : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getColumn())) { |
188 | sqlQuery = this.modelYaml.getResource().getZip().getColumn(); | |
189 | } else { | |
190 | LOGGER.log( | |
191 | LogLevelUtil.CONSOLE_INFORM, | |
192 | "Strategy [Zip] activated but column query is undefined for [{}], fallback to default", | |
193 |
1
1. lambda$sqlColumns$5 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlColumns$5 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
194 | ); | |
195 | } | |
196 | } | |
197 | | |
198 | String databaseUtf8 = Hex.encodeHexString(table.getParent().toString().getBytes(StandardCharsets.UTF_8)); | |
199 | String tableUtf8 = Hex.encodeHexString(table.toString().getBytes(StandardCharsets.UTF_8)); | |
200 | | |
201 |
1
1. sqlColumns : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlColumns → NO_COVERAGE |
return sqlQuery |
202 | .replace(VendorYaml.DATABASE_HEX, databaseUtf8) | |
203 | .replace(VendorYaml.TABLE_HEX, tableUtf8) | |
204 | .replace(VendorYaml.DATABASE, table.getParent().toString()) | |
205 | .replace(VendorYaml.TABLE, table.toString()); | |
206 | } | |
207 | ||
208 | @Override | |
209 | public String sqlRows(String[] namesColumns, Database database, Table table) { | |
210 | String sqlField = this.modelYaml.getResource().getSchema().getRow().getFields().getField(); | |
211 | String sqlConcatFields = this.modelYaml.getResource().getSchema().getRow().getFields().getConcat(); | |
212 | String sqlQuery = this.modelYaml.getResource().getSchema().getRow().getQuery(); | |
213 | | |
214 |
1
1. sqlRows : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) { |
215 |
1
1. sqlRows : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getDatabase())) { |
216 | sqlField = this.modelYaml.getResource().getDios().getRow().getFields().getField(); | |
217 | sqlConcatFields = this.modelYaml.getResource().getDios().getRow().getFields().getConcat(); | |
218 | sqlQuery = this.modelYaml.getResource().getDios().getRow().getQuery(); | |
219 | } else { | |
220 | LOGGER.log( | |
221 | LogLevelUtil.CONSOLE_INFORM, | |
222 | "Strategy [Dios] activated but row query is undefined for [{}], fallback to default", | |
223 |
1
1. lambda$sqlRows$6 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlRows$6 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
224 | ); | |
225 | } | |
226 |
1
1. sqlRows : negated conditional → NO_COVERAGE |
} else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) { |
227 |
1
1. sqlRows : negated conditional → NO_COVERAGE |
if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getDatabase())) { |
228 | sqlField = this.modelYaml.getResource().getZip().getRow().getFields().getField(); | |
229 | sqlConcatFields = this.modelYaml.getResource().getZip().getRow().getFields().getConcat(); | |
230 | sqlQuery = this.modelYaml.getResource().getZip().getRow().getQuery(); | |
231 | } else { | |
232 | LOGGER.log( | |
233 | LogLevelUtil.CONSOLE_INFORM, | |
234 | "Strategy [Zip] activated but row query is undefined for [{}], fallback to default", | |
235 |
1
1. lambda$sqlRows$7 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlRows$7 → NO_COVERAGE |
() -> this.injectionModel.getMediatorVendor().getVendor() |
236 | ); | |
237 | } | |
238 | } | |
239 | | |
240 | var matcherSqlField = Pattern.compile("(?s)(.*)"+ Pattern.quote(VendorYaml.FIELD) +"(.*)").matcher(sqlField); | |
241 | String leadSqlField = StringUtils.EMPTY; | |
242 | String trailSqlField = StringUtils.EMPTY; | |
243 | | |
244 |
1
1. sqlRows : negated conditional → NO_COVERAGE |
if (matcherSqlField.find()) { |
245 | leadSqlField = matcherSqlField.group(1); | |
246 | trailSqlField = matcherSqlField.group(2); | |
247 | } | |
248 | | |
249 | var namesColumnUtf8 = new String[namesColumns.length]; | |
250 |
2
1. sqlRows : changed conditional boundary → NO_COVERAGE 2. sqlRows : negated conditional → NO_COVERAGE |
for (var i = 0 ; i < namesColumns.length ; i++) { |
251 | namesColumnUtf8[i] = StringUtil.detectUtf8(namesColumns[i]); | |
252 | namesColumnUtf8[i] = URLEncoder.encode(namesColumnUtf8[i], StandardCharsets.UTF_8); | |
253 | } | |
254 | | |
255 | var nameDatabaseUtf8 = StringUtil.detectUtf8(database.toString()); | |
256 | nameDatabaseUtf8 = URLEncoder.encode(nameDatabaseUtf8, StandardCharsets.UTF_8); | |
257 | | |
258 | var nameTableUtf8 = StringUtil.detectUtf8(table.toString()); | |
259 | nameTableUtf8 = URLEncoder.encode(nameTableUtf8, StandardCharsets.UTF_8); | |
260 | | |
261 |
1
1. sqlRows : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlRows → NO_COVERAGE |
return sqlQuery.replace( |
262 | VendorYaml.FIELDS, | |
263 | leadSqlField | |
264 | + String.join( | |
265 | trailSqlField + sqlConcatFields + leadSqlField, | |
266 | namesColumnUtf8 | |
267 | ) | |
268 | + trailSqlField | |
269 | ) | |
270 | .replace(VendorYaml.DATABASE, nameDatabaseUtf8) | |
271 | .replace(VendorYaml.TABLE, nameTableUtf8); | |
272 | } | |
273 | ||
274 | @Override | |
275 | public String sqlTestBlindWithOperator(String check, BlindOperator blindOperator) { | |
276 | String replacement = this.getMode(blindOperator); | |
277 |
1
1. sqlTestBlindWithOperator : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTestBlindWithOperator → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getBlind() |
278 | .replace(VendorYaml.BINARY_MODE, replacement) | |
279 | .replace(VendorYaml.TEST, check) | |
280 | .trim(); // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql() | |
281 | } | |
282 | ||
283 | @Override | |
284 | public String sqlBlindBit(String inj, int indexChar, int bit, BlindOperator blindOperator) { | |
285 | String replacement = this.getMode(blindOperator); | |
286 |
1
1. sqlBlindBit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindBit → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getBlind() |
287 | .replace(VendorYaml.BINARY_MODE, replacement) | |
288 | .replace( | |
289 | VendorYaml.TEST, | |
290 | this.modelYaml.getStrategy().getBinary().getTest().getBit() | |
291 | .replace(VendorYaml.INJECTION, inj) | |
292 | .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar)) | |
293 | .replace(VendorYaml.BIT, Integer.toString(bit)) | |
294 | ) | |
295 | .trim(); // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql() | |
296 | } | |
297 | ||
298 | @Override | |
299 | public String sqlBlindBin(String inj, int indexChar, int mid, BlindOperator blindOperator) { | |
300 | String replacement = this.getMode(blindOperator); | |
301 |
1
1. sqlBlindBin : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindBin → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getBlind() |
302 | .replace(VendorYaml.BINARY_MODE, replacement) | |
303 | .replace( | |
304 | VendorYaml.TEST, | |
305 | this.modelYaml.getStrategy().getBinary().getTest().getBin() | |
306 | .replace(VendorYaml.INJECTION, inj) | |
307 | .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar)) | |
308 | .replace( | |
309 | VendorYaml.MID_CHR, | |
310 | StringUtil.toUrl(Character.toString((char) mid).replace("'", "''")) // escape quote | |
311 | ) | |
312 | .replace(VendorYaml.MID_INT, String.valueOf(mid)) | |
313 | ) | |
314 | .trim(); // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql() | |
315 | } | |
316 | ||
317 | @Override | |
318 | public String sqlTestTimeWithOperator(String check, BlindOperator blindOperator) { | |
319 | String replacement = this.getMode(blindOperator); | |
320 |
1
1. sqlTestTimeWithOperator : negated conditional → NO_COVERAGE |
int countSleepTimeStrategy = this.injectionModel.getMediatorUtils().getPreferencesUtil().isLimitingSleepTimeStrategy() |
321 | ? this.injectionModel.getMediatorUtils().getPreferencesUtil().countSleepTimeStrategy() | |
322 | : 5; | |
323 |
1
1. sqlTestTimeWithOperator : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTestTimeWithOperator → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTime() |
324 | .replace(VendorYaml.BINARY_MODE, replacement) | |
325 | .replace(VendorYaml.TEST, check) | |
326 | .replace(VendorYaml.SLEEP_TIME, Long.toString(countSleepTimeStrategy)) | |
327 | .trim(); // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql() | |
328 | } | |
329 | ||
330 | @Override | |
331 | public String sqlTimeBit(String inj, int indexChar, int bit, BlindOperator blindOperator) { | |
332 | String replacement = this.getMode(blindOperator); | |
333 |
1
1. sqlTimeBit : negated conditional → NO_COVERAGE |
int countSleepTimeStrategy = this.injectionModel.getMediatorUtils().getPreferencesUtil().isLimitingSleepTimeStrategy() |
334 | ? this.injectionModel.getMediatorUtils().getPreferencesUtil().countSleepTimeStrategy() | |
335 | : 5; | |
336 |
1
1. sqlTimeBit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTimeBit → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTime() |
337 | .replace(VendorYaml.BINARY_MODE, replacement) | |
338 | .replace( | |
339 | VendorYaml.TEST, | |
340 | this.modelYaml.getStrategy().getBinary().getTest() | |
341 | .getBit() | |
342 | .replace(VendorYaml.INJECTION, inj) | |
343 | .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar)) | |
344 | .replace(VendorYaml.BIT, Integer.toString(bit)) | |
345 | ) | |
346 | .replace(VendorYaml.SLEEP_TIME, Long.toString(countSleepTimeStrategy)) | |
347 | .trim(); // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql() | |
348 | } | |
349 | ||
350 | private String getMode(BlindOperator blindOperator) { | |
351 | String replacement; | |
352 | switch (blindOperator) { | |
353 | case AND: replacement = this.modelYaml.getStrategy().getBinary().getModeAnd(); break; | |
354 | case OR: replacement = this.modelYaml.getStrategy().getBinary().getModeOr(); break; | |
355 | case STACK: replacement = this.modelYaml.getStrategy().getBinary().getModeStack(); break; | |
356 | case NO_MODE: default: replacement = StringUtils.EMPTY; break; | |
357 | } | |
358 | return replacement; | |
359 | } | |
360 | ||
361 | @Override | |
362 | public String sqlBlind(String sqlQuery, String startPosition, boolean isReport) { | |
363 |
1
1. sqlBlind : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlind → NO_COVERAGE |
return VendorYaml.replaceTags( |
364 | this.getSlidingWindow(isReport) | |
365 | .replace(VendorYaml.INJECTION, sqlQuery) | |
366 | .replace(VendorYaml.WINDOW_CHAR, startPosition) | |
367 | .replace(VendorYaml.CAPACITY, VendorYaml.DEFAULT_CAPACITY) | |
368 | ); | |
369 | } | |
370 | ||
371 | @Override | |
372 | public String sqlTime(String sqlQuery, String startPosition, boolean isReport) { | |
373 |
1
1. sqlTime : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTime → NO_COVERAGE |
return VendorYaml.replaceTags( |
374 | this.getSlidingWindow(isReport) | |
375 | .replace(VendorYaml.INJECTION, sqlQuery) | |
376 | .replace(VendorYaml.WINDOW_CHAR, startPosition) | |
377 | .replace(VendorYaml.CAPACITY, VendorYaml.DEFAULT_CAPACITY) | |
378 | ); | |
379 | } | |
380 | ||
381 | @Override | |
382 | public String sqlMultibit(String inj, int indexChar, int block){ | |
383 |
1
1. sqlMultibit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlMultibit → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getMultibit() |
384 | .replace(VendorYaml.INJECTION, inj) | |
385 | .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar)) | |
386 | .replace(VendorYaml.BLOCK_MULTIBIT, Integer.toString(block)); | |
387 | } | |
388 | ||
389 | @Override | |
390 | public String sqlErrorCalibrator(Method errorMethod) { | |
391 |
1
1. sqlErrorCalibrator : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlErrorCalibrator → NO_COVERAGE |
return VendorYaml.replaceTags( |
392 | errorMethod.getQuery() | |
393 | .replace(VendorYaml.WINDOW, this.modelYaml.getStrategy().getConfiguration().getSlidingWindow()) | |
394 | .replace(VendorYaml.INJECTION, this.modelYaml.getStrategy().getConfiguration().getCalibrator()) | |
395 | .replace(VendorYaml.WINDOW_CHAR, "1") | |
396 | .replace(VendorYaml.CAPACITY, Integer.toString(errorMethod.getCapacity())) | |
397 | ); | |
398 | } | |
399 | ||
400 | @Override | |
401 | public String sqlErrorIndice(Method errorMethod) { | |
402 | var indexZeroToFind = "0"; | |
403 |
1
1. sqlErrorIndice : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlErrorIndice → NO_COVERAGE |
return VendorYaml.replaceTags( |
404 | errorMethod.getQuery() | |
405 | .replace(VendorYaml.WINDOW, this.modelYaml.getStrategy().getConfiguration().getSlidingWindow()) | |
406 | .replace(VendorYaml.INJECTION, this.modelYaml.getStrategy().getConfiguration().getFailsafe().replace(VendorYaml.INDICE, indexZeroToFind)) | |
407 | .replace(VendorYaml.WINDOW_CHAR, "1") | |
408 | .replace(VendorYaml.CAPACITY, Integer.toString(errorMethod.getCapacity())) | |
409 | ); | |
410 | } | |
411 | ||
412 | @Override | |
413 | public String sqlError(String sqlQuery, String startPosition, int indexMethodError, boolean isReport) { | |
414 |
1
1. sqlError : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlError → NO_COVERAGE |
return VendorYaml.replaceTags( |
415 | this.modelYaml.getStrategy().getError().getMethod().get(indexMethodError).getQuery() | |
416 | .replace(VendorYaml.WINDOW, this.getSlidingWindow(isReport)) | |
417 | .replace(VendorYaml.INJECTION, sqlQuery) | |
418 | .replace(VendorYaml.WINDOW_CHAR, startPosition) | |
419 | .replace( | |
420 | VendorYaml.CAPACITY, | |
421 | Integer.toString( | |
422 | this.modelYaml.getStrategy().getError() | |
423 | .getMethod() | |
424 | .get(indexMethodError) | |
425 | .getCapacity() | |
426 | ) | |
427 | ) | |
428 | ); | |
429 | } | |
430 | ||
431 | @Override | |
432 | public String sqlUnion(String sqlQuery, String startPosition, boolean isReport) { | |
433 |
1
1. sqlUnion : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlUnion → NO_COVERAGE |
return VendorYaml.replaceTags( |
434 | this.getSlidingWindow(isReport) | |
435 | .replace(VendorYaml.INJECTION, sqlQuery) | |
436 | .replace(VendorYaml.WINDOW_CHAR, startPosition) | |
437 | .replace(VendorYaml.CAPACITY, this.injectionModel.getMediatorStrategy().getUnion().getPerformanceLength()) | |
438 | ); | |
439 | } | |
440 | ||
441 | @Override | |
442 | public String sqlStack(String sqlQuery, String startPosition, boolean isReport) { | |
443 |
1
1. sqlStack : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlStack → NO_COVERAGE |
return this.modelYaml.getStrategy().getStack().replace( |
444 | VendorYaml.WINDOW, | |
445 | VendorYaml.replaceTags( | |
446 | this.getSlidingWindow(isReport) | |
447 | .replace(VendorYaml.INJECTION, sqlQuery) | |
448 | .replace(VendorYaml.WINDOW_CHAR, startPosition) | |
449 | .replace(VendorYaml.CAPACITY, VendorYaml.DEFAULT_CAPACITY) | |
450 | ) | |
451 | ); | |
452 | } | |
453 | ||
454 | @Override | |
455 | public String sqlCapacity(String[] indexes) { | |
456 | String regexIndexes = String.join("|", indexes); | |
457 | String regexVisibleIndexesToFind = String.format(VendorYaml.FORMAT_INDEX, "(%s)"); | |
458 |
1
1. sqlCapacity : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlCapacity → NO_COVERAGE |
return this.injectionModel.getIndexesInUrl().replaceAll( |
459 | String.format(regexVisibleIndexesToFind, regexIndexes), | |
460 | VendorYaml.replaceTags( | |
461 | this.modelYaml.getStrategy().getUnion().getCapacity() | |
462 | .replace(VendorYaml.CALIBRATOR, this.modelYaml.getStrategy().getConfiguration().getCalibrator()) | |
463 | .replace(VendorYaml.INDICE, "$1") | |
464 | ) | |
465 | ); | |
466 | } | |
467 | ||
468 | @Override | |
469 | public String sqlIndices(Integer nbFields) { | |
470 | String replaceTag = StringUtils.EMPTY; | |
471 | List<String> fields = new ArrayList<>(); | |
472 | var indice = 1; | |
473 |
2
1. sqlIndices : changed conditional boundary → NO_COVERAGE 2. sqlIndices : negated conditional → NO_COVERAGE |
for ( ; indice <= nbFields ; indice++) { |
474 | String field = this.modelYaml.getStrategy().getConfiguration().getFailsafe().replace(VendorYaml.INDICE, Integer.toString(indice)); | |
475 | fields.add(field); | |
476 | replaceTag = field; | |
477 | } | |
478 |
1
1. sqlIndices : Changed increment from -1 to 1 → NO_COVERAGE |
indice--; |
479 |
1
1. sqlIndices : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlIndices → NO_COVERAGE |
return this.modelYaml.getStrategy().getUnion() |
480 | .getIndices() | |
481 | .replace( | |
482 | VendorYaml.INDICES, | |
483 | String.join(",", fields.toArray(new String[0])) | |
484 | ) | |
485 | .replace(VendorYaml.INDICE_UNIQUE, replaceTag) | |
486 | .replace( | |
487 | VendorYaml.RESULT_RANGE, | |
488 | String.join(",", Collections.nCopies(indice, "r")) | |
489 | ); | |
490 | } | |
491 | ||
492 | @Override | |
493 | public String sqlLimit(Integer limitSqlResult) { | |
494 | var limitBoundary = 0; | |
495 | try { | |
496 | limitBoundary = Integer.parseInt(this.modelYaml.getStrategy().getConfiguration().getLimitBoundary()); | |
497 | } catch (NumberFormatException e) { | |
498 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Incorrect Limit start index, force to 0"); | |
499 | } | |
500 |
1
1. sqlLimit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlLimit → NO_COVERAGE |
return this.modelYaml.getStrategy().getConfiguration() |
501 | .getLimit() | |
502 |
1
1. sqlLimit : Replaced integer addition with subtraction → NO_COVERAGE |
.replace(VendorYaml.LIMIT_VALUE, Integer.toString(limitSqlResult + limitBoundary)); |
503 | } | |
504 | | |
505 | @Override | |
506 | public String fingerprintErrorsAsRegex() { | |
507 |
1
1. fingerprintErrorsAsRegex : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::fingerprintErrorsAsRegex → NO_COVERAGE |
return "(?si)"+ StringUtils.join( |
508 | this.modelYaml.getStrategy().getConfiguration().getFingerprint() | |
509 | .getErrorMessage() | |
510 | .stream() | |
511 |
1
1. lambda$fingerprintErrorsAsRegex$8 : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::lambda$fingerprintErrorsAsRegex$8 → NO_COVERAGE |
.map(m -> ".*"+ m +".*") |
512 | .toArray(), | |
513 | "|" | |
514 | ); | |
515 | } | |
516 | | |
517 | public static String replaceTags(String sqlRequest) { | |
518 |
1
1. replaceTags : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::replaceTags → NO_COVERAGE |
return sqlRequest |
519 | .replace("${enclose_value_sql}", VendorYaml.ENCLOSE_VALUE_SQL) | |
520 | .replace("${enclose_value_hex}", VendorYaml.ENCLOSE_VALUE_HEX) | |
521 | .replace("${separator_qte_sql}", VendorYaml.SEPARATOR_QTE_SQL) | |
522 | .replace("${separator_qte_hex}", VendorYaml.SEPARATOR_QTE_HEX) | |
523 | .replace("${separator_cell_sql}", VendorYaml.SEPARATOR_CELL_SQL) | |
524 | .replace("${separator_cell_hex}", VendorYaml.SEPARATOR_CELL_HEX) | |
525 | .replace("${calibrator_sql}", VendorYaml.CALIBRATOR_SQL) | |
526 | .replace("${calibrator_raw}", VendorYaml.CALIBRATOR_SQL.repeat(100)) | |
527 | .replace("${calibrator_hex}", VendorYaml.CALIBRATOR_HEX) | |
528 | .replace("${trail_sql}", VendorYaml.TRAIL_SQL) | |
529 | .replace("${trail_hex}", VendorYaml.TRAIL_HEX) | |
530 | .replace("${lead}", LEAD) | |
531 | .replace("${lead_hex}", VendorYaml.LEAD_HEX) | |
532 | .replace("${lead_pipe}", VendorYaml.LEAD_PIPE); | |
533 | } | |
534 | ||
535 | /** | |
536 | * Get payload with sliding window except for vulnerability report | |
537 | */ | |
538 | private String getSlidingWindow(boolean isReport) { | |
539 |
2
1. getSlidingWindow : negated conditional → NO_COVERAGE 2. getSlidingWindow : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::getSlidingWindow → NO_COVERAGE |
return isReport |
540 | ? "(" + VendorYaml.INJECTION + ")" | |
541 | : this.modelYaml.getStrategy().getConfiguration().getSlidingWindow(); | |
542 | } | |
543 | | |
544 | | |
545 | // Getter and setter | |
546 | ||
547 | @Override | |
548 | public String sqlInfos() { | |
549 |
1
1. sqlInfos : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlInfos → NO_COVERAGE |
return this.modelYaml.getResource().getInfo(); |
550 | } | |
551 | ||
552 | @Override | |
553 | public List<String> getFalsyBit() { | |
554 |
1
1. getFalsyBit : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getFalsyBit → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTest().getFalsyBit(); |
555 | } | |
556 | ||
557 | @Override | |
558 | public List<String> getTruthyBit() { | |
559 |
1
1. getTruthyBit : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getTruthyBit → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTest().getTruthyBit(); |
560 | } | |
561 | ||
562 | @Override | |
563 | public List<String> getFalsyBin() { | |
564 |
1
1. getFalsyBin : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getFalsyBin → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTest().getFalsyBin(); |
565 | } | |
566 | ||
567 | @Override | |
568 | public List<String> getTruthyBin() { | |
569 |
1
1. getTruthyBin : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getTruthyBin → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTest().getTruthyBin(); |
570 | } | |
571 | ||
572 | @Override | |
573 | public String sqlBlindConfirm() { | |
574 |
1
1. sqlBlindConfirm : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindConfirm → NO_COVERAGE |
return this.modelYaml.getStrategy().getBinary().getTest().getInit(); |
575 | } | |
576 | ||
577 | @Override | |
578 | public String sqlOrderBy() { | |
579 |
1
1. sqlOrderBy : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlOrderBy → NO_COVERAGE |
return this.modelYaml.getStrategy().getUnion().getOrderBy(); |
580 | } | |
581 | | |
582 | @Override | |
583 | public String endingComment() { | |
584 |
1
1. endingComment : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isUrlRandomSuffixDisabled()) { |
585 |
1
1. endingComment : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::endingComment → NO_COVERAGE |
return this.modelYaml.getStrategy().getConfiguration().getEndingComment(); |
586 | } else { | |
587 |
1
1. endingComment : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::endingComment → NO_COVERAGE |
return this.modelYaml.getStrategy().getConfiguration().getEndingComment() |
588 | + RandomStringUtils.secure().nextAlphanumeric(4); // Allows binary match fingerprinting on host errors | |
589 | } | |
590 | } | |
591 | ||
592 | @Override | |
593 | public ModelYaml getModelYaml() { | |
594 |
1
1. getModelYaml : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::getModelYaml → KILLED |
return this.modelYaml; |
595 | } | |
596 | } | |
Mutations | ||
116 |
1.1 |
|
117 |
1.1 |
|
123 |
1.1 |
|
126 |
1.1 |
|
127 |
1.1 |
|
133 |
1.1 |
|
137 |
1.1 |
|
144 |
1.1 |
|
145 |
1.1 |
|
151 |
1.1 |
|
154 |
1.1 |
|
155 |
1.1 |
|
161 |
1.1 |
|
167 |
1.1 |
|
176 |
1.1 |
|
177 |
1.1 |
|
183 |
1.1 |
|
186 |
1.1 |
|
187 |
1.1 |
|
193 |
1.1 |
|
201 |
1.1 |
|
214 |
1.1 |
|
215 |
1.1 |
|
223 |
1.1 |
|
226 |
1.1 |
|
227 |
1.1 |
|
235 |
1.1 |
|
244 |
1.1 |
|
250 |
1.1 2.2 |
|
261 |
1.1 |
|
277 |
1.1 |
|
286 |
1.1 |
|
301 |
1.1 |
|
320 |
1.1 |
|
323 |
1.1 |
|
333 |
1.1 |
|
336 |
1.1 |
|
363 |
1.1 |
|
373 |
1.1 |
|
383 |
1.1 |
|
391 |
1.1 |
|
403 |
1.1 |
|
414 |
1.1 |
|
433 |
1.1 |
|
443 |
1.1 |
|
458 |
1.1 |
|
473 |
1.1 2.2 |
|
478 |
1.1 |
|
479 |
1.1 |
|
500 |
1.1 |
|
502 |
1.1 |
|
507 |
1.1 |
|
511 |
1.1 |
|
518 |
1.1 |
|
539 |
1.1 2.2 |
|
549 |
1.1 |
|
554 |
1.1 |
|
559 |
1.1 |
|
564 |
1.1 |
|
569 |
1.1 |
|
574 |
1.1 |
|
579 |
1.1 |
|
584 |
1.1 |
|
585 |
1.1 |
|
587 |
1.1 |
|
594 |
1.1 |