AbstractInjectionMonobit.java

1
package com.jsql.model.injection.strategy.blind;
2
3
import com.jsql.model.InjectionModel;
4
import com.jsql.model.injection.strategy.blind.callable.AbstractCallableBit;
5
6
import java.util.List;
7
import java.util.concurrent.CompletionService;
8
import java.util.concurrent.atomic.AtomicInteger;
9
10
public abstract class AbstractInjectionMonobit<T extends AbstractCallableBit<T>> extends AbstractInjectionBit<T> {
11
12
    protected AbstractInjectionMonobit(InjectionModel injectionModel, BlindOperator blindOperator) {
13
        super(injectionModel, blindOperator);
14
    }
15
    
16
    abstract T getCallableBitTest(String sqlQuery, int indexChar, int bit);
17
18
    public void initNextChar(
19
        String sqlQuery,
20
        List<char[]> bytes,
21
        AtomicInteger indexChar,
22
        CompletionService<T> taskCompletionService,
23
        AtomicInteger countTasksSubmitted,
24
        T currentCallable
25
    ) {
26
        indexChar.incrementAndGet();
27
        
28
        // New undefined bits of the next character
29
        // Chars all have the last bit set to 0 in Ascii table
30
        bytes.add(AbstractInjectionBit.getBitsUnset());
31
        
32
        // Test the 7 bits for the next character, save its position and current bit for later
33
        // Ignore last bit 128 and only check for first seven bits
34
        for (int bit: new int[]{ 1, 2, 4, 8, 16, 32, 64 }) {
35
            taskCompletionService.submit(
36
                this.getCallableBitTest(
37
                    sqlQuery,
38
                    indexChar.get(),
39
                    bit
40
                )
41
            );
42
            countTasksSubmitted.addAndGet(1);
43
        }
44
    }
45
46
    public char[] initMaskAsciiChar(List<char[]> bytes, T currentCallable) {
47 1 1. initMaskAsciiChar : Replaced integer subtraction with addition → NO_COVERAGE
        char[] asciiCodeMask = bytes.get(currentCallable.getCurrentIndex() - 1);  // bits for current url
48
        int positionInMask = (int) (
49 3 1. initMaskAsciiChar : Replaced double division with multiplication → NO_COVERAGE
2. initMaskAsciiChar : Replaced double addition with subtraction → NO_COVERAGE
3. initMaskAsciiChar : Replaced double subtraction with addition → NO_COVERAGE
            8 - (Math.log(2) + Math.log(currentCallable.getCurrentBit())) / Math.log(2)  // some math (2^x => x)
50
        );
51 1 1. initMaskAsciiChar : negated conditional → NO_COVERAGE
        asciiCodeMask[positionInMask] = currentCallable.isTrue() ? '1' : '0';  // set current bit
52 1 1. initMaskAsciiChar : replaced return value with null for com/jsql/model/injection/strategy/blind/AbstractInjectionMonobit::initMaskAsciiChar → NO_COVERAGE
        return asciiCodeMask;
53
    }
54
}

Mutations

47

1.1
Location : initMaskAsciiChar
Killed by : none
Replaced integer subtraction with addition → NO_COVERAGE

49

1.1
Location : initMaskAsciiChar
Killed by : none
Replaced double division with multiplication → NO_COVERAGE

2.2
Location : initMaskAsciiChar
Killed by : none
Replaced double addition with subtraction → NO_COVERAGE

3.3
Location : initMaskAsciiChar
Killed by : none
Replaced double subtraction with addition → NO_COVERAGE

51

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

52

1.1
Location : initMaskAsciiChar
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/blind/AbstractInjectionMonobit::initMaskAsciiChar → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1