Search in sources :

Example 36 with Request

use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.

the class StrategyInjectionNormal method activateStrategy.

@Override
public void activateStrategy() {
    LOGGER.info(I18n.valueByKey("LOG_USING_STRATEGY") + " [" + this.getName() + "]");
    MediatorModel.model().setStrategy(StrategyInjection.NORMAL);
    Request request = new Request();
    request.setMessage(Interaction.MARK_NORMAL_STRATEGY);
    MediatorModel.model().sendToViews(request);
}
Also used : Request(com.jsql.model.bean.util.Request)

Example 37 with Request

use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.

the class StrategyInjectionTime method activateStrategy.

@Override
public void activateStrategy() {
    LOGGER.info(I18n.valueByKey("LOG_USING_STRATEGY") + " [" + this.getName() + "]");
    MediatorModel.model().setStrategy(StrategyInjection.TIME);
    Request requestMarkTimeStrategy = new Request();
    requestMarkTimeStrategy.setMessage(Interaction.MARK_TIME_STRATEGY);
    MediatorModel.model().sendToViews(requestMarkTimeStrategy);
}
Also used : Request(com.jsql.model.bean.util.Request)

Example 38 with Request

use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.

the class ApplicationUiTest method shouldFindDatabase.

@Test
public void shouldFindDatabase() {
    window.tabbedPane("tabManagers").selectTab("Database");
    var nameDatabase = "database";
    Database database = new Database(nameDatabase, "1");
    var requestDatabase = new Request();
    requestDatabase.setMessage(Interaction.ADD_DATABASES);
    requestDatabase.setParameters(Arrays.asList(database));
    MediatorHelper.model().sendToViews(requestDatabase);
    Assert.assertEquals(nameDatabase + " (1 table)", window.tree("treeDatabases").valueAt(0));
    var nameTable = "table";
    Table table = new Table(nameTable, "2", database);
    var requestTable = new Request();
    requestTable.setMessage(Interaction.ADD_TABLES);
    requestTable.setParameters(Arrays.asList(table));
    MediatorHelper.model().sendToViews(requestTable);
    Assert.assertEquals(nameTable + " (2 rows)", window.tree("treeDatabases").valueAt(1));
    var nameColumn0 = "column 0";
    var nameColumn1 = "column 1";
    Column column1 = new Column(nameColumn0, table);
    Column column2 = new Column(nameColumn1, table);
    var request = new Request();
    request.setMessage(Interaction.ADD_COLUMNS);
    request.setParameters(Arrays.asList(column1, column2));
    MediatorHelper.model().sendToViews(request);
    Assert.assertEquals(nameColumn0, window.tree("treeDatabases").valueAt(2));
    Assert.assertEquals(nameColumn1, window.tree("treeDatabases").valueAt(3));
    var arrayColumns = new String[] { Strings.EMPTY, Strings.EMPTY, nameColumn0, nameColumn1 };
    var tableDatas = new String[][] { { "", "", "[0, 0]", "[0, 1]" }, { "", "", "[1, 0]", "[1, 1]" } };
    var objectData = new Object[] { arrayColumns, tableDatas, table };
    var requestValues = new Request();
    requestValues.setMessage(Interaction.CREATE_VALUES_TAB);
    requestValues.setParameters(objectData);
    MediatorHelper.model().sendToViews(requestValues);
    window.tabbedPane("tabResults").selectTab(nameTable).requireVisible();
    window.tree("treeDatabases").rightClickRow(0);
    window.tabbedPane("tabResults").click();
    window.tree("treeDatabases").rightClickRow(1);
    GuiActionRunner.execute(() -> {
        window.tabbedPane("tabResults").target().removeTabAt(0);
    });
}
Also used : Table(com.jsql.model.bean.database.Table) Column(com.jsql.model.bean.database.Column) Database(com.jsql.model.bean.database.Database) Request(com.jsql.model.bean.util.Request) Test(org.junit.Test)

Example 39 with Request

use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.

the class ApplicationUiTest method shouldDnDTabs.

@Test
public void shouldDnDTabs() {
    var request = new Request();
    request.setMessage(Interaction.CREATE_FILE_TAB);
    request.setParameters("dragfile", "content", "path");
    MediatorHelper.model().sendToViews(request);
    request = new Request();
    request.setMessage(Interaction.CREATE_FILE_TAB);
    request.setParameters("jumpfile", "content", "path");
    MediatorHelper.model().sendToViews(request);
    request = new Request();
    request.setMessage(Interaction.CREATE_FILE_TAB);
    request.setParameters("dropfile", "content", "path");
    MediatorHelper.model().sendToViews(request);
    window.tabbedPane("tabResults").requireTitle("dragfile ", Index.atIndex(0));
    window.tabbedPane("tabResults").requireTitle("jumpfile ", Index.atIndex(1));
    window.tabbedPane("tabResults").requireTitle("dropfile ", Index.atIndex(2));
    window.robot().pressMouse(window.label("dragfile").target(), window.label("dragfile").target().getLocation());
    // required
    window.robot().moveMouse(window.label("dragfile").target());
    window.label("dropfile").drop();
    try {
        window.tabbedPane("tabResults").requireTitle("jumpfile ", Index.atIndex(0));
        window.tabbedPane("tabResults").requireTitle("dragfile ", Index.atIndex(1));
        window.tabbedPane("tabResults").requireTitle("dropfile ", Index.atIndex(2));
    } catch (Exception e) {
        Assert.fail();
    }
    GuiActionRunner.execute(() -> {
        window.tabbedPane("tabResults").target().removeTabAt(0);
        window.tabbedPane("tabResults").target().removeTabAt(0);
        window.tabbedPane("tabResults").target().removeTabAt(0);
    });
}
Also used : Request(com.jsql.model.bean.util.Request) NoSuchElementException(java.util.NoSuchElementException) DecoderException(org.apache.commons.codec.DecoderException) IOException(java.io.IOException) AWTException(java.awt.AWTException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Test(org.junit.Test)

Example 40 with Request

use of com.jsql.model.bean.util.Request in project jsql-injection by ron190.

the class ManagerAdminPage method createAdminPages.

/**
 * Check if every page in the list responds 200 Success.
 * @param urlInjection
 * @param pageNames List of admin pages to test
 * @throws InterruptedException
 */
public void createAdminPages(String urlInjection, List<ItemList> pageNames) throws InterruptedException {
    var matcher = Pattern.compile("^((https?://)?[^/]*)(.*)").matcher(urlInjection);
    matcher.find();
    String urlProtocol = matcher.group(1);
    String urlWithoutProtocol = matcher.group(3);
    List<String> folderSplits = new ArrayList<>();
    // Hostname only
    if (urlWithoutProtocol.isEmpty() || !Pattern.matches("^/.*", urlWithoutProtocol)) {
        urlWithoutProtocol = "/dummy";
    }
    String[] splits = urlWithoutProtocol.split("/", -1);
    String[] folderNames = Arrays.copyOf(splits, splits.length - 1);
    for (String folderName : Arrays.asList(folderNames)) {
        folderSplits.add(folderName + "/");
    }
    ExecutorService taskExecutor = Executors.newFixedThreadPool(10, new ThreadFactoryCallable("CallableGetAdminPage"));
    CompletionService<CallableHttpHead> taskCompletionService = new ExecutorCompletionService<>(taskExecutor);
    var urlPart = new StringBuilder();
    for (String segment : folderSplits) {
        urlPart.append(segment);
        for (ItemList pageName : pageNames) {
            taskCompletionService.submit(new CallableHttpHead(urlProtocol + urlPart.toString() + pageName.toString(), MediatorHelper.model(), "check:page"));
        }
    }
    var resourceAccess = MediatorHelper.model().getResourceAccess();
    var nbAdminPagesFound = 0;
    int submittedTasks = folderSplits.size() * pageNames.size();
    int tasksHandled;
    for (tasksHandled = 0; tasksHandled < submittedTasks && !resourceAccess.isSearchAdminStopped(); tasksHandled++) {
        nbAdminPagesFound = resourceAccess.callAdminPage(taskCompletionService, nbAdminPagesFound);
    }
    taskExecutor.shutdown();
    taskExecutor.awaitTermination(5, TimeUnit.SECONDS);
    resourceAccess.setSearchAdminStopped(false);
    resourceAccess.logSearchAdminPage(nbAdminPagesFound, submittedTasks, tasksHandled);
    var request = new Request();
    request.setMessage(Interaction.END_ADMIN_SEARCH);
    MediatorHelper.model().sendToViews(request);
}
Also used : CallableHttpHead(com.jsql.model.accessible.CallableHttpHead) ArrayList(java.util.ArrayList) Request(com.jsql.model.bean.util.Request) ExecutorCompletionService(java.util.concurrent.ExecutorCompletionService) ThreadFactoryCallable(com.jsql.model.suspendable.callable.ThreadFactoryCallable) ItemList(com.jsql.view.swing.list.ItemList) ExecutorService(java.util.concurrent.ExecutorService)

Aggregations

Request (com.jsql.model.bean.util.Request)47 ArrayList (java.util.ArrayList)13 Header (com.jsql.model.bean.util.Header)12 EnumMap (java.util.EnumMap)12 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)11 ExecutorService (java.util.concurrent.ExecutorService)11 JSqlException (com.jsql.model.exception.JSqlException)10 SuspendableGetRows (com.jsql.model.suspendable.SuspendableGetRows)9 IOException (java.io.IOException)9 ThreadFactoryCallable (com.jsql.model.suspendable.callable.ThreadFactoryCallable)8 ExecutionException (java.util.concurrent.ExecutionException)8 InjectionFailureException (com.jsql.model.exception.InjectionFailureException)7 ItemList (com.jsql.view.swing.list.ItemList)7 MalformedURLException (java.net.MalformedURLException)6 HttpRequest (java.net.http.HttpRequest)6 URL (java.net.URL)5 List (java.util.List)5 Matcher (java.util.regex.Matcher)5 IgnoreMessageException (com.jsql.model.exception.IgnoreMessageException)4 StoppedByUserSlidingException (com.jsql.model.exception.StoppedByUserSlidingException)4