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);
}
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);
}
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);
});
}
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);
});
}
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);
}
Aggregations