StrategyBlindBin.java

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.InjectionBlindBin;
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 StrategyBlindBin extends AbstractStrategy {
29
30
    /**
31
     * Log4j logger sent to view.
32
     */
33
    private static final Logger LOGGER = LogManager.getRootLogger();
34
35
    private InjectionBlindBin injectionBlindBin;
36
37
    public StrategyBlindBin(InjectionModel injectionModel) {
38
        super(injectionModel);
39
    }
40
41
    @Override
42
    public void checkApplicability() throws StoppedByUserSlidingException {
43 1 1. checkApplicability : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isStrategyBlindBinDisabled()) {
44
            LOGGER.log(LogLevelUtil.CONSOLE_INFORM, AbstractStrategy.FORMAT_SKIP_STRATEGY_DISABLED, this.getName());
45
            return;
46 1 1. checkApplicability : negated conditional → NO_COVERAGE
        } else if (StringUtils.isEmpty(
47
            this.injectionModel.getMediatorVendor().getVendor().instance().getModelYaml().getStrategy().getBinary().getTest().getBin()
48
        )) {
49
            LOGGER.log(
50
                LogLevelUtil.CONSOLE_ERROR,
51
                AbstractStrategy.FORMAT_STRATEGY_NOT_IMPLEMENTED,
52
                this.getName(),
53
                this.injectionModel.getMediatorVendor().getVendor()
54
            );
55
            return;
56
        }
57
58 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.OR);
59 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.AND);
60 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.STACK);
61 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE
        this.checkInjection(BlindOperator.NO_MODE);
62
63 1 1. checkApplicability : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
64 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::allow → NO_COVERAGE
            this.allow();
65
            var requestMessageBinary = new Request();
66 1 1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE
            requestMessageBinary.setMessage(Interaction.MESSAGE_BINARY);
67 1 1. checkApplicability : removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE
            requestMessageBinary.setParameters(this.injectionBlindBin.getInfoMessage());
68 1 1. checkApplicability : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            this.injectionModel.sendToViews(requestMessageBinary);
69
        } else {
70 1 1. checkApplicability : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::unallow → NO_COVERAGE
            this.unallow();
71
        }
72
    }
73
74
    private void checkInjection(BlindOperator blindOperator) throws StoppedByUserSlidingException {
75 1 1. checkInjection : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
76
            return;
77
        }
78
        LOGGER.log(
79
            LogLevelUtil.CONSOLE_DEFAULT,
80
            "{} [{}] with [{}]...",
81 1 1. lambda$checkInjection$0 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$0 → NO_COVERAGE
            () -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_CHECKING_STRATEGY),
82
            this::getName,
83 1 1. lambda$checkInjection$1 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$1 → NO_COVERAGE
            () -> blindOperator
84
        );
85
        this.injectionBlindBin = new InjectionBlindBin(this.injectionModel, blindOperator);
86
        this.isApplicable = this.injectionBlindBin.isInjectable();
87 1 1. checkInjection : negated conditional → NO_COVERAGE
        if (this.isApplicable) {
88
            LOGGER.log(
89
                LogLevelUtil.CONSOLE_SUCCESS,
90
                "{} [{}] injection with [{}]",
91 1 1. lambda$checkInjection$2 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$2 → NO_COVERAGE
                () -> I18nUtil.valueByKey(AbstractStrategy.KEY_LOG_VULNERABLE),
92
                this::getName,
93 1 1. lambda$checkInjection$3 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$3 → NO_COVERAGE
                () -> blindOperator
94
            );
95
        }
96
    }
97
98
    @Override
99
    public void allow(int... i) {
100 1 1. allow : removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE
        this.injectionModel.appendAnalysisReport(
101
            StringUtil.formatReport(LogLevelUtil.COLOR_BLU, "### Strategy: " + this.getName())
102
            + this.injectionModel.getReportWithoutIndex(
103
                this.injectionModel.getMediatorVendor().getVendor().instance().sqlTestBlindWithOperator(
104
                    this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(StringUtil.formatReport(LogLevelUtil.COLOR_GREEN, "<query>"), "0", true),
105
                    this.injectionBlindBin.getBooleanMode()
106
                ),
107
                "metadataInjectionProcess",
108
                null
109
            )
110
        );
111 1 1. allow : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::markVulnerability → NO_COVERAGE
        this.markVulnerability(Interaction.MARK_BLIND_BIN_VULNERABLE);
112
    }
113
114
    @Override
115
    public void unallow(int... i) {
116 1 1. unallow : removed call to com/jsql/model/injection/strategy/StrategyBlindBin::markVulnerability → NO_COVERAGE
        this.markVulnerability(Interaction.MARK_BLIND_BIN_INVULNERABLE);
117
    }
118
119
    @Override
120
    public String inject(String sqlQuery, String startPosition, AbstractSuspendable stoppable, String metadataInjectionProcess) throws StoppedByUserSlidingException {
121 1 1. inject : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::inject → NO_COVERAGE
        return this.injectionBlindBin.inject(
122
            this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlind(sqlQuery, startPosition, false),
123
            stoppable
124
        );
125
    }
126
127
    @Override
128
    public void activateWhenApplicable() {
129 2 1. activateWhenApplicable : negated conditional → NO_COVERAGE
2. activateWhenApplicable : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorStrategy().getStrategy() == null && this.isApplicable()) {
130
            LOGGER.log(
131
                LogLevelUtil.CONSOLE_INFORM,
132
                "{} [{}] with [{}]",
133 1 1. lambda$activateWhenApplicable$4 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$activateWhenApplicable$4 → NO_COVERAGE
                () -> I18nUtil.valueByKey("LOG_USING_STRATEGY"),
134
                this::getName,
135 1 1. lambda$activateWhenApplicable$5 : replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$activateWhenApplicable$5 → NO_COVERAGE
                () -> this.injectionBlindBin.getBooleanMode().name()
136
            );
137 1 1. activateWhenApplicable : removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE
            this.injectionModel.getMediatorStrategy().setStrategy(this);
138
139
            var requestMarkBlindBinStrategy = new Request();
140 1 1. activateWhenApplicable : removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE
            requestMarkBlindBinStrategy.setMessage(Interaction.MARK_BLIND_BIN_STRATEGY);
141 1 1. activateWhenApplicable : removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE
            this.injectionModel.sendToViews(requestMarkBlindBinStrategy);
142
        }
143
    }
144
    
145
    @Override
146
    public String getPerformanceLength() {
147 1 1. getPerformanceLength : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::getPerformanceLength → NO_COVERAGE
        return VendorYaml.DEFAULT_CAPACITY;
148
    }
149
    
150
    @Override
151
    public String getName() {
152 1 1. getName : replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::getName → NO_COVERAGE
        return "Blind bin";
153
    }
154
}

Mutations

43

1.1
Location : checkApplicability
Killed by : none
negated conditional → NO_COVERAGE

46

1.1
Location : checkApplicability
Killed by : none
negated conditional → NO_COVERAGE

58

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE

59

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE

60

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE

61

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::checkInjection → NO_COVERAGE

63

1.1
Location : checkApplicability
Killed by : none
negated conditional → NO_COVERAGE

64

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::allow → NO_COVERAGE

66

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE

67

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/bean/util/Request::setParameters → NO_COVERAGE

68

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE

70

1.1
Location : checkApplicability
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::unallow → NO_COVERAGE

75

1.1
Location : checkInjection
Killed by : none
negated conditional → NO_COVERAGE

81

1.1
Location : lambda$checkInjection$0
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$0 → NO_COVERAGE

83

1.1
Location : lambda$checkInjection$1
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$1 → NO_COVERAGE

87

1.1
Location : checkInjection
Killed by : none
negated conditional → NO_COVERAGE

91

1.1
Location : lambda$checkInjection$2
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$2 → NO_COVERAGE

93

1.1
Location : lambda$checkInjection$3
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$checkInjection$3 → NO_COVERAGE

100

1.1
Location : allow
Killed by : none
removed call to com/jsql/model/InjectionModel::appendAnalysisReport → NO_COVERAGE

111

1.1
Location : allow
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::markVulnerability → NO_COVERAGE

116

1.1
Location : unallow
Killed by : none
removed call to com/jsql/model/injection/strategy/StrategyBlindBin::markVulnerability → NO_COVERAGE

121

1.1
Location : inject
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::inject → NO_COVERAGE

129

1.1
Location : activateWhenApplicable
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : activateWhenApplicable
Killed by : none
negated conditional → NO_COVERAGE

133

1.1
Location : lambda$activateWhenApplicable$4
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$activateWhenApplicable$4 → NO_COVERAGE

135

1.1
Location : lambda$activateWhenApplicable$5
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/StrategyBlindBin::lambda$activateWhenApplicable$5 → NO_COVERAGE

137

1.1
Location : activateWhenApplicable
Killed by : none
removed call to com/jsql/model/injection/strategy/MediatorStrategy::setStrategy → NO_COVERAGE

140

1.1
Location : activateWhenApplicable
Killed by : none
removed call to com/jsql/model/bean/util/Request::setMessage → NO_COVERAGE

141

1.1
Location : activateWhenApplicable
Killed by : none
removed call to com/jsql/model/InjectionModel::sendToViews → NO_COVERAGE

147

1.1
Location : getPerformanceLength
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::getPerformanceLength → NO_COVERAGE

152

1.1
Location : getName
Killed by : none
replaced return value with "" for com/jsql/model/injection/strategy/StrategyBlindBin::getName → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1