View Javadoc
1   package com.jsql.model.accessible.engine;
2   
3   import com.jsql.model.InjectionModel;
4   import com.jsql.model.accessible.ResourceAccess;
5   import com.jsql.model.accessible.engine.sqlserver.ModelYamlSqlserver;
6   import com.jsql.model.bean.database.MockElement;
7   import com.jsql.model.exception.AbstractSlidingException;
8   import com.jsql.model.suspendable.Input;
9   import com.jsql.model.suspendable.SuspendableGetRows;
10  import org.apache.commons.lang3.StringUtils;
11  import org.yaml.snakeyaml.Yaml;
12  
13  public class ExploitSqlserver {
14  
15      private final InjectionModel injectionModel;
16      private final ModelYamlSqlserver modelYaml;
17  
18      public ExploitSqlserver(InjectionModel injectionModel) {
19          this.injectionModel = injectionModel;
20          var yaml = new Yaml();
21          this.modelYaml = yaml.loadAs(
22              injectionModel.getMediatorEngine().getSqlserver().instance().getModelYaml().getResource().getExploit(),
23              ModelYamlSqlserver.class
24          );
25      }
26  
27      public String getRead(String pathFile) throws AbstractSlidingException {
28          return new SuspendableGetRows(this.injectionModel).run(new Input(
29              String.format(
30                  this.modelYaml.getFile().getRead(),
31                  pathFile
32              ),
33              new String[]{ StringUtils.EMPTY },
34              false,
35              1,
36              MockElement.MOCK,
37              ResourceAccess.FILE_READ
38          ));
39      }
40  }