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