Search in sources :

Example 1 with MediatorVendor

use of com.jsql.model.injection.vendor.MediatorVendor in project jsql-injection by ron190.

the class SuspendableGetCharInsertion method run.

@Override
public String run(Object... args) throws JSqlException {
    String characterInsertionByUser = (String) args[0];
    ExecutorService taskExecutor = this.injectionModel.getMediatorUtils().getThreadUtil().getExecutor("CallableGetInsertionCharacter");
    CompletionService<CallablePageSource> taskCompletionService = new ExecutorCompletionService<>(taskExecutor);
    var charFromBooleanMatch = new String[1];
    List<String> charactersInsertion = this.initializeCallables(taskCompletionService, characterInsertionByUser, charFromBooleanMatch);
    var mediatorVendor = this.injectionModel.getMediatorVendor();
    LOGGER.log(LogLevel.CONSOLE_DEFAULT, "Fingerprinting database and character insertion with Order by match...");
    String charFromOrderBy = null;
    int total = charactersInsertion.size();
    while (0 < total) {
        if (this.isSuspended()) {
            throw new StoppedByUserSlidingException();
        }
        try {
            CallablePageSource currentCallable = taskCompletionService.take().get();
            total--;
            String pageSource = currentCallable.getContent();
            List<Vendor> vendorsOrderByMatch = this.getVendorsOrderByMatch(mediatorVendor, pageSource);
            if (!vendorsOrderByMatch.isEmpty()) {
                this.setVendor(mediatorVendor, vendorsOrderByMatch);
                LOGGER.log(LogLevel.CONSOLE_INFORM, "Using [{}]", mediatorVendor.getVendor());
                var requestSetVendor = new Request();
                requestSetVendor.setMessage(Interaction.SET_VENDOR);
                requestSetVendor.setParameters(mediatorVendor.getVendor());
                this.injectionModel.sendToViews(requestSetVendor);
                // Char insertion
                charFromOrderBy = currentCallable.getCharacterInsertion();
                LOGGER.log(LogLevel.CONSOLE_SUCCESS, "Character insertion [{}] matching with Order by and compatible with Error strategy", charFromOrderBy);
                break;
            }
        } catch (InterruptedException e) {
            LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
            Thread.currentThread().interrupt();
        } catch (ExecutionException e) {
            LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
        }
    }
    // End the job
    try {
        taskExecutor.shutdown();
        if (!taskExecutor.awaitTermination(15, TimeUnit.SECONDS)) {
            taskExecutor.shutdownNow();
        }
    } catch (InterruptedException e) {
        LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
        Thread.currentThread().interrupt();
    }
    if (charFromOrderBy == null && charFromBooleanMatch[0] != null) {
        charFromOrderBy = charFromBooleanMatch[0];
    }
    return this.getCharacterInsertion(characterInsertionByUser, charFromOrderBy);
}
Also used : Request(com.jsql.model.bean.util.Request) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) CallablePageSource(com.jsql.model.suspendable.callable.CallablePageSource) Vendor(com.jsql.model.injection.vendor.model.Vendor) MediatorVendor(com.jsql.model.injection.vendor.MediatorVendor) ExecutorService(java.util.concurrent.ExecutorService) StoppedByUserSlidingException(com.jsql.model.exception.StoppedByUserSlidingException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Request (com.jsql.model.bean.util.Request)1 StoppedByUserSlidingException (com.jsql.model.exception.StoppedByUserSlidingException)1 MediatorVendor (com.jsql.model.injection.vendor.MediatorVendor)1 Vendor (com.jsql.model.injection.vendor.model.Vendor)1 CallablePageSource (com.jsql.model.suspendable.callable.CallablePageSource)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)1 ExecutorService (java.util.concurrent.ExecutorService)1