use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.
the class CreateSQLShellTab method execute.
@Override
public void execute() {
if (MediatorGui.frame() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
}
try {
UUID terminalID = UUID.randomUUID();
ShellSql terminal = new ShellSql(terminalID, this.url, this.user, this.pass);
MediatorGui.frame().getConsoles().put(terminalID, terminal);
LightScrollPane scroller = new LightScrollPaneShell(terminal);
MediatorGui.tabResults().addTab("SQL shell ", scroller);
// Focus on the new tab
MediatorGui.tabResults().setSelectedComponent(scroller);
// Create a custom tab header with close button
TabHeader header = new TabHeader("SQL shell", HelperUi.ICON_SHELL_SERVER);
MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), "<html><b>URL</b><br>" + this.url + RessourceAccess.FILENAME_SQLSHELL + "<br><b>Path</b><br>" + this.path + RessourceAccess.FILENAME_SQLSHELL + "</html>");
// Apply the custom header to the tab
MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(scroller), header);
terminal.requestFocusInWindow();
} catch (MalformedURLException e) {
LOGGER.warn("Incorrect shell Url", e);
}
}
use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.
the class MenuActionNewValue method actionPerformed.
@Override
public void actionPerformed(ActionEvent arg0) {
var panel = new JPanel(new BorderLayout());
final JTextArea textarea = new JPopupTextArea(new JTextArea()).getProxy();
var labelAddValue = new JLabel(I18nUtil.valueByKey("LIST_ADD_VALUE_LABEL") + ":");
panel.add(labelAddValue, BorderLayout.NORTH);
I18nViewUtil.addComponentForKey("LIST_ADD_VALUE_LABEL", labelAddValue);
panel.add(new LightScrollPane(1, 1, 1, 1, textarea));
panel.setPreferredSize(new Dimension(600, 400));
panel.setMinimumSize(new Dimension(600, 400));
textarea.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
textarea.requestFocusInWindow();
}
});
int result = -1;
// Fix #70832: ClassCastException on showOptionDialog()
try {
result = JOptionPane.showOptionDialog(this.myList.getTopLevelAncestor(), panel, I18nUtil.valueByKey("LIST_ADD_VALUE_TITLE"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { I18nUtil.valueByKey("LIST_ADD_VALUE_OK"), I18nUtil.valueByKey("LIST_ADD_VALUE_CANCEL") }, I18nUtil.valueByKey("LIST_ADD_VALUE_CANCEL"));
} catch (NullPointerException | IllegalArgumentException | ClassCastException e) {
LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
}
if (StringUtils.isEmpty(textarea.getText()) || result != JOptionPane.YES_OPTION) {
return;
}
var lastIndex = 0;
if (this.myList.getSelectedIndex() > 0) {
lastIndex = this.myList.getSelectedIndex();
}
int firstIndex = lastIndex;
if ("scan".equals(this.myList.getName())) {
lastIndex = this.addToScanList(textarea, lastIndex);
} else {
lastIndex = this.addToList(textarea, lastIndex);
}
this.myList.setSelectionInterval(firstIndex, lastIndex - 1);
this.myList.scrollRectToVisible(this.myList.getCellBounds(this.myList.getMinSelectionIndex(), this.myList.getMaxSelectionIndex()));
textarea.setText(null);
}
use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.
the class CreateAdminPageTab method execute.
@Override
public void execute() {
String htmlSource = StringUtils.EMPTY;
// Fix #44641: ExceptionInInitializerError on get()
try {
// Previous test for 2xx Success and 3xx Redirection was Header only,
// now get the HTML content.
// Proxy is used by jsoup
htmlSource = Jsoup.clean(Jsoup.connect(this.url).ignoreContentType(true).ignoreHttpErrors(true).get().html().replaceAll("<img[^>]*>", StringUtils.EMPTY).replaceAll("<input[^>]*type=\"?hidden\"?[^>]*>", StringUtils.EMPTY).replaceAll("<input[^>]*type=\"?(submit|button)\"?[^>]*>", "<div style=\"background-color:#eeeeee;text-align:center;border:1px solid black;width:100px;\">button</div>").replaceAll("<input[^>]*>", "<div style=\"text-align:center;border:1px solid black;width:100px;\">input</div>"), Whitelist.relaxed().addTags("center", "div", "span").addAttributes(":all", "style"));
} catch (IOException e) {
LOGGER.log(LogLevel.CONSOLE_ERROR, "Failure opening page: {}", e.getMessage());
} catch (ExceptionInInitializerError | NoClassDefFoundError e) {
LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
}
final var browser = new JTextPane();
browser.setContentType("text/html");
browser.setEditable(false);
// Fix #94242: IndexOutOfBoundsException on setText()
try {
browser.setText(htmlSource);
} catch (IndexOutOfBoundsException | EmptyStackException e) {
LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
}
final var menu = new JPopupMenu();
JMenuItem itemCopyUrl = new JMenuItemWithMargin(I18nUtil.valueByKey("CONTEXT_MENU_COPY_PAGE_URL"));
I18nViewUtil.addComponentForKey("CONTEXT_MENU_COPY_PAGE_URL", itemCopyUrl);
JMenuItem itemCopy = new JMenuItemWithMargin();
itemCopy.setAction(browser.getActionMap().get(DefaultEditorKit.copyAction));
itemCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
itemCopy.setMnemonic('C');
itemCopy.setText(I18nUtil.valueByKey("CONTEXT_MENU_COPY"));
I18nViewUtil.addComponentForKey("CONTEXT_MENU_COPY", itemCopy);
JMenuItem itemSelectAll = new JMenuItemWithMargin();
itemSelectAll.setAction(browser.getActionMap().get(DefaultEditorKit.selectAllAction));
itemSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
itemSelectAll.setText(I18nUtil.valueByKey("CONTEXT_MENU_SELECT_ALL"));
I18nViewUtil.addComponentForKey("CONTEXT_MENU_SELECT_ALL", itemSelectAll);
itemSelectAll.setMnemonic('A');
menu.add(itemCopyUrl);
menu.add(new JSeparator());
menu.add(itemCopy);
menu.add(itemSelectAll);
menu.applyComponentOrientation(ComponentOrientation.getOrientation(I18nUtil.getLocaleDefault()));
itemCopyUrl.addActionListener(actionEvent -> {
var stringSelection = new StringSelection(CreateAdminPageTab.this.url);
var clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
});
itemSelectAll.addActionListener(actionEvent -> browser.selectAll());
browser.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent arg0) {
browser.getCaret().setVisible(true);
browser.getCaret().setSelectionVisible(true);
}
});
browser.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent evt) {
browser.requestFocusInWindow();
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent(), evt.getX(), evt.getY());
}
}
@Override
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
// Fix #45348: IllegalComponentStateException on show()
try {
menu.show(evt.getComponent(), evt.getX(), evt.getY());
} catch (IllegalComponentStateException e) {
LOGGER.log(LogLevel.CONSOLE_JAVA, e, e);
}
menu.setLocation(ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getLocaleDefault())) ? evt.getXOnScreen() - menu.getWidth() : evt.getXOnScreen(), evt.getYOnScreen());
}
}
});
final var scroller = new LightScrollPane(1, 0, 0, 0, browser);
MediatorHelper.tabResults().addTab(this.url.replaceAll(".*/", StringUtils.EMPTY) + StringUtils.SPACE, scroller);
// Focus on the new tab
MediatorHelper.tabResults().setSelectedComponent(scroller);
// Create a custom tab header with close button
var header = new TabHeader(this.url.replaceAll(".*/", StringUtils.EMPTY), UiUtil.ICON_ADMIN_SERVER);
MediatorHelper.tabResults().setToolTipTextAt(MediatorHelper.tabResults().indexOfComponent(scroller), String.format("<html>%s</html>", this.url));
// Apply the custom header to the tab
MediatorHelper.tabResults().setTabComponentAt(MediatorHelper.tabResults().indexOfComponent(scroller), header);
// Give focus to the admin page
browser.requestFocusInWindow();
// Get back to the top
SwingUtilities.invokeLater(() -> scroller.scrollPane.getViewport().setViewPosition(new java.awt.Point(0, 0)));
}
use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.
the class TabResults method createFileTab.
public void createFileTab(String name, String content, String path) {
JTextArea fileText = new JPopupTextArea().getProxy();
fileText.setText(content);
fileText.setFont(new Font(UiUtil.FONT_NAME_MONO_NON_ASIAN, Font.PLAIN, 14));
var scroller = new LightScrollPane(1, 0, 0, 0, fileText);
fileText.setCaretPosition(0);
this.addTab(name + StringUtils.SPACE, scroller);
// Focus on the new tab
this.setSelectedComponent(scroller);
// Create a custom tab header with close button
var header = new TabHeader(name, UiUtil.ICON_FILE_SERVER);
this.setToolTipTextAt(this.indexOfComponent(scroller), path);
// Apply the custom header to the tab
this.setTabComponentAt(this.indexOfComponent(scroller), header);
MediatorHelper.tabManagers().createFileTab(path, name);
}
use of com.jsql.view.swing.scrollpane.LightScrollPane in project jsql-injection by ron190.
the class TabResults method createShell.
public void createShell(String url, String path) {
try {
var terminalID = UUID.randomUUID();
var terminal = new ShellWeb(terminalID, url);
MediatorHelper.frame().getConsoles().put(terminalID, terminal);
LightScrollPane scroller = new LightScrollPaneShell(terminal);
this.addTab("Web shell ", scroller);
// Focus on the new tab
this.setSelectedComponent(scroller);
// Create a custom tab header with close button
var header = new TabHeader("Web shell", UiUtil.ICON_SHELL_SERVER);
this.setToolTipTextAt(this.indexOfComponent(scroller), String.format("<html><b>URL</b><br>%s%s<br><b>Path</b><br>%s%s</html>", url, MediatorHelper.model().getResourceAccess().filenameWebshell, path, MediatorHelper.model().getResourceAccess().filenameWebshell));
// Apply the custom header to the tab
this.setTabComponentAt(this.indexOfComponent(scroller), header);
terminal.requestFocusInWindow();
} catch (MalformedURLException e) {
LOGGER.log(LogLevel.CONSOLE_ERROR, "Incorrect shell Url", e);
}
}
Aggregations