| 1 | /******************************************************************************* | |
| 2 | * Copyhacked (H) 2012-2025. | |
| 3 | * This program and the accompanying materials | |
| 4 | * are made available under no term at all, use it like | |
| 5 | * you want, but share and discuss it | |
| 6 | * every time possible with every body. | |
| 7 | * | |
| 8 | * Contributors: | |
| 9 | * ron190 at ymail dot com - initial implementation | |
| 10 | *******************************************************************************/ | |
| 11 | package com.jsql.model.injection.strategy; | |
| 12 | ||
| 13 | import com.jsql.model.InjectionModel; | |
| 14 | import com.jsql.model.bean.util.Interaction; | |
| 15 | import com.jsql.model.bean.util.Request; | |
| 16 | import com.jsql.model.exception.StoppedByUserSlidingException; | |
| 17 | import com.jsql.model.injection.strategy.blind.AbstractInjectionBit.BlindOperator; | |
| 18 | import com.jsql.model.injection.strategy.blind.InjectionBlindBit; | |
| 19 | import com.jsql.model.injection.vendor.model.VendorYaml; | |
| 20 | import com.jsql.model.suspendable.AbstractSuspendable; | |
| 21 | import com.jsql.util.I18nUtil; | |
| 22 | import com.jsql.util.LogLevelUtil; | |
| 23 | import com.jsql.util.StringUtil; | |
| 24 | import org.apache.commons.lang3.StringUtils; | |
| 25 | import org.apache.logging.log4j.LogManager; | |
| 26 | import org.apache.logging.log4j.Logger; | |
| 27 | ||
| 28 | public class StrategyBlindBit extends AbstractStrategy { | |
| 29 | | |
| 30 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 31 | ||
| 32 | private InjectionBlindBit injection; | |
| 33 | | |
| 34 | public StrategyBlindBit(InjectionModel injectionModel) { | |
| 35 | super(injectionModel); | |
| 36 | } | |
| 37 | ||
| 38 | @Override | |
| 39 | public void checkApplicability() throws StoppedByUserSlidingException { | |
| 40 |
1
1. checkApplicability : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isStrategyBlindBitDisabled()) { |
| 41 | LOGGER.log(LogLevelUtil.CONSOLE_INFORM, AbstractStrategy.FORMAT_SKIP_STRATEGY_DISABLED, this.getName()); | |
| 42 | return; | |
| 43 |
1
1. checkApplicability : negated conditional → NO_COVERAGE |
} else if (StringUtils.isEmpty( |
| 44 | this.injectionModel.getMediatorVendor().getVendor().instance().getModelYaml().getStrategy().getBinary().getTest().getBit() | |
| 45 | )) { | |
| 46 | LOGGER.log( | |
| 47 | LogLevelUtil.CONSOLE_INFORM, | |
| 48 | AbstractStrategy.FORMAT_STRATEGY_NOT_IMPLEMENTED, | |
| 49 | this.getName(), | |
| 50 | this.injectionModel.getMediatorVendor().getVendor() | |
| 51 | ); | |
| 52 | return; | |
| 53 | } | |
| 54 | ||
| 55 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::checkInjection → NO_COVERAGE |
this.checkInjection(BlindOperator.OR); |
| 56 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::checkInjection → NO_COVERAGE |
this.checkInjection(BlindOperator.AND); |
| 57 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::checkInjection → NO_COVERAGE |
this.checkInjection(BlindOperator.STACK); |
| 58 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::checkInjection → NO_COVERAGE |
this.checkInjection(BlindOperator.NO_MODE); |
| 59 | ||
| 60 |
1
1. checkApplicability : negated conditional → NO_COVERAGE |
if (this.isApplicable) { |
| 61 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::allow → NO_COVERAGE |
this.allow(); |
| 62 | var requestMessageBinary = new Request(); | |
| 63 |
1
1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE |
requestMessageBinary.setMessage(Interaction.MESSAGE_BINARY); |
| 64 |
1
1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE |
requestMessageBinary.setParameters(this.injection.getInfoMessage()); |
| 65 |
1
1. checkApplicability : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE |
this.injectionModel.sendToViews(requestMessageBinary); |
| 66 | } else { | |
| 67 |
1
1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::unallow → NO_COVERAGE |
this.unallow(); |
| 68 | } | |
| 69 | } | |
| 70 | ||
| 71 | private void checkInjection(BlindOperator blindOperator) throws StoppedByUserSlidingException { | |
| 72 |
1
1. checkInjection : negated conditional → NO_COVERAGE |
if (this.isApplicable) { |
| 73 | return; | |
| 74 | } | |
| 75 | LOGGER.log( | |
| 76 | LogLevelUtil.CONSOLE_DEFAULT, | |
| 77 | "{} [{}] with [{}]...", | |
| 78 |
1
1. lambda$checkInjection$0 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBit::lambda$checkInjection$0 → NO_COVERAGE |
() -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_CHECKING_STRATEGY), |
| 79 | this::getName, | |
| 80 |
1
1. lambda$checkInjection$1 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBit::lambda$checkInjection$1 → NO_COVERAGE |
() -> blindOperator |
| 81 | ); | |
| 82 | this.injection = new InjectionBlindBit(this.injectionModel, blindOperator); | |
| 83 | this.isApplicable = this.injection.isInjectable(); | |
| 84 |
1
1. checkInjection : negated conditional → NO_COVERAGE |
if (this.isApplicable) { |
| 85 | LOGGER.log( | |
| 86 | LogLevelUtil.CONSOLE_SUCCESS, | |
| 87 | "{} [{}] injection with [{}]", | |
| 88 |
1
1. lambda$checkInjection$2 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBit::lambda$checkInjection$2 → NO_COVERAGE |
() -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_VULNERABLE), |
| 89 | this::getName, | |
| 90 |
1
1. lambda$checkInjection$3 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBit::lambda$checkInjection$3 → NO_COVERAGE |
() -> blindOperator |
| 91 | ); | |
| 92 | } | |
| 93 | } | |
| 94 | ||
| 95 | @Override | |
| 96 | public void allow(int... i) { | |
| 97 |
1
1. allow : removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE |
this.injectionModel.appendAnalysisReport( |
| 98 | StringUtil.formatReport(LogLevelUtil.COLOR_BLU, "### Strategy: " + this.getName()) | |
| 99 | + this.injectionModel.getReportWithoutIndex( | |
| 100 | this.injectionModel.getMediatorVendor().getVendor().instance().sqlTestBlindWithOperator( | |
| 101 | this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "<query>"), "0", true), | |
| 102 | this.injection.getBlindOperator() | |
| 103 | ), | |
| 104 | "metadataInjectionProcess", | |
| 105 | null | |
| 106 | ) | |
| 107 | ); | |
| 108 |
1
1. allow : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::markVulnerability → NO_COVERAGE |
this.markVulnerability(Interaction.MARK_BLIND_BIT_VULNERABLE); |
| 109 | } | |
| 110 | ||
| 111 | @Override | |
| 112 | public void unallow(int... i) { | |
| 113 |
1
1. unallow : removed call to com/jsql/model/injection/strategy/StrategyBlindBit::markVulnerability → NO_COVERAGE |
this.markVulnerability(Interaction.MARK_BLIND_BIT_INVULNERABLE); |
| 114 | } | |
| 115 | ||
| 116 | @Override | |
| 117 | public String inject(String sqlQuery, String startPosition, AbstractSuspendable stoppable, String metadataInjectionProcess) throws StoppedByUserSlidingException { | |
| 118 |
1
1. inject : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBit::inject → NO_COVERAGE |
return this.injection.inject( |
| 119 | this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(sqlQuery, startPosition, false), | |
| 120 | stoppable | |
| 121 | ); | |
| 122 | } | |
| 123 | ||
| 124 | @Override | |
| 125 | public void activateWhenApplicable() { | |
| 126 |
2
1. activateWhenApplicable : negated conditional → NO_COVERAGE 2. activateWhenApplicable : negated conditional → NO_COVERAGE |
if (this.injectionModel.getMediatorStrategy().getStrategy() == null && this.isApplicable()) { |
| 127 | LOGGER.log( | |
| 128 | LogLevelUtil.CONSOLE_INFORM, | |
| 129 | "{} [{}] with [{}]", | |
| 130 |
1
1. lambda$activateWhenApplicable$4 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBit::lambda$activateWhenApplicable$4 → NO_COVERAGE |
() -> I18nUtil.valueByKey("LOG_USING_STRATEGY"), |
| 131 | this::getName, | |
| 132 |
1
1. lambda$activateWhenApplicable$5 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBit::lambda$activateWhenApplicable$5 → NO_COVERAGE |
() -> this.injection.getBlindOperator().name() |
| 133 | ); | |
| 134 |
1
1. activateWhenApplicable : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE |
this.injectionModel.getMediatorStrategy().setStrategy(this); |
| 135 | ||
| 136 | var request = new Request(); | |
| 137 |
1
1. activateWhenApplicable : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE |
request.setMessage(Interaction.MARK_BLIND_BIT_STRATEGY); |
| 138 |
1
1. activateWhenApplicable : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE |
this.injectionModel.sendToViews(request); |
| 139 | } | |
| 140 | } | |
| 141 | | |
| 142 | @Override | |
| 143 | public String getPerformanceLength() { | |
| 144 |
1
1. getPerformanceLength : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBit::getPerformanceLength → NO_COVERAGE |
return VendorYaml.DEFAULT_CAPACITY; |
| 145 | } | |
| 146 | | |
| 147 | @Override | |
| 148 | public String getName() { | |
| 149 |
1
1. getName : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBit::getName → NO_COVERAGE |
return "Blind bit"; |
| 150 | } | |
| 151 | } | |
Mutations | ||
| 40 |
1.1 |
|
| 43 |
1.1 |
|
| 55 |
1.1 |
|
| 56 |
1.1 |
|
| 57 |
1.1 |
|
| 58 |
1.1 |
|
| 60 |
1.1 |
|
| 61 |
1.1 |
|
| 63 |
1.1 |
|
| 64 |
1.1 |
|
| 65 |
1.1 |
|
| 67 |
1.1 |
|
| 72 |
1.1 |
|
| 78 |
1.1 |
|
| 80 |
1.1 |
|
| 84 |
1.1 |
|
| 88 |
1.1 |
|
| 90 |
1.1 |
|
| 97 |
1.1 |
|
| 108 |
1.1 |
|
| 113 |
1.1 |
|
| 118 |
1.1 |
|
| 126 |
1.1 2.2 |
|
| 130 |
1.1 |
|
| 132 |
1.1 |
|
| 134 |
1.1 |
|
| 137 |
1.1 |
|
| 138 |
1.1 |
|
| 144 |
1.1 |
|
| 149 |
1.1 |