AbstractInjectionMonobit.java

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

Mutations

48

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

51

1.1
Location : initializeBinaryMask
Killed by : none
Replaced double addition with subtraction → NO_COVERAGE

52

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

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

56

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

58

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

Active mutators

Tests examined


Report generated by PIT 1.16.1