ExploitSqlserver.java

package com.jsql.model.accessible.engine;

import com.jsql.model.InjectionModel;
import com.jsql.model.accessible.ResourceAccess;
import com.jsql.model.accessible.engine.sqlserver.ModelYamlSqlserver;
import com.jsql.model.bean.database.MockElement;
import com.jsql.model.exception.AbstractSlidingException;
import com.jsql.model.suspendable.Input;
import com.jsql.model.suspendable.SuspendableGetRows;
import org.apache.commons.lang3.StringUtils;
import org.yaml.snakeyaml.Yaml;

public class ExploitSqlserver {

    private final InjectionModel injectionModel;
    private final ModelYamlSqlserver modelYaml;

    public ExploitSqlserver(InjectionModel injectionModel) {
        this.injectionModel = injectionModel;
        var yaml = new Yaml();
        this.modelYaml = yaml.loadAs(
            injectionModel.getMediatorEngine().getSqlserver().instance().getModelYaml().getResource().getExploit(),
            ModelYamlSqlserver.class
        );
    }

    public String getRead(String pathFile) throws AbstractSlidingException {
        return new SuspendableGetRows(this.injectionModel).run(new Input(
            String.format(
                this.modelYaml.getFile().getRead(),
                pathFile
            ),
            new String[]{ StringUtils.EMPTY },
            false,
            1,
            MockElement.MOCK,
            ResourceAccess.FILE_READ
        ));
    }
}