Search in sources :

Example 1 with TabHeader

use of com.jsql.view.swing.tab.TabHeader in project jsql-injection by ron190.

the class CreateAdminPageTab method execute.

@Override
public void execute() {
    if (MediatorGui.tabResults() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.tabResults() in " + this.getClass());
    }
    String htmlSource = "";
    // 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).get().html().replaceAll("<img.*>", "").replaceAll("<input.*type=\"?hidden\"?.*>", "").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.error(e.getMessage(), e);
    } catch (ExceptionInInitializerError | NoClassDefFoundError e) {
        LOGGER.warn("Jsoup not properly configured, please update jsql", e);
    }
    final JTextPane browser = new JTextPane();
    browser.setContentType("text/html");
    browser.setEditable(false);
    // Fix #43220: EmptyStackException on setText()
    try {
        browser.setText(htmlSource);
    } catch (EmptyStackException e) {
        LOGGER.error(e, e);
    }
    final JPopupMenu menu = new JPopupMenu();
    JMenuItem itemCopyUrl = new JMenuItem(I18n.valueByKey("CONTEXT_MENU_COPY_PAGE_URL"));
    I18nView.addComponentForKey("CONTEXT_MENU_COPY_PAGE_URL", itemCopyUrl);
    itemCopyUrl.setIcon(HelperUi.ICON_EMPTY);
    JMenuItem itemCopy = new JMenuItem();
    itemCopy.setAction(browser.getActionMap().get(DefaultEditorKit.copyAction));
    itemCopy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
    itemCopy.setMnemonic('C');
    itemCopy.setText(I18n.valueByKey("CONTEXT_MENU_COPY"));
    I18nView.addComponentForKey("CONTEXT_MENU_COPY", itemCopy);
    itemCopy.setIcon(HelperUi.ICON_EMPTY);
    JMenuItem itemSelectAll = new JMenuItem();
    itemSelectAll.setIcon(HelperUi.ICON_EMPTY);
    itemSelectAll.setAction(browser.getActionMap().get(DefaultEditorKit.selectAllAction));
    itemSelectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    itemSelectAll.setText(I18n.valueByKey("CONTEXT_MENU_SELECT_ALL"));
    I18nView.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(I18n.getLocaleDefault()));
    itemCopyUrl.addActionListener(actionEvent -> {
        StringSelection stringSelection = new StringSelection(CreateAdminPageTab.this.url);
        Clipboard 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.error(e, e);
                }
                menu.setLocation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? evt.getXOnScreen() - menu.getWidth() : evt.getXOnScreen(), evt.getYOnScreen());
            }
        }
    });
    final LightScrollPane scroller = new LightScrollPane(1, 0, 0, 0, browser);
    MediatorGui.tabResults().addTab(this.url.replaceAll(".*/", "") + " ", scroller);
    // Focus on the new tab
    MediatorGui.tabResults().setSelectedComponent(scroller);
    // Create a custom tab header with close button
    TabHeader header = new TabHeader(this.url.replaceAll(".*/", ""), HelperUi.ICON_ADMIN_SERVER);
    MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), "<html>" + this.url + "</html>");
    // Apply the custom header to the tab
    MediatorGui.tabResults().setTabComponentAt(MediatorGui.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)));
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) FocusAdapter(java.awt.event.FocusAdapter) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) IOException(java.io.IOException) FocusEvent(java.awt.event.FocusEvent) IllegalComponentStateException(java.awt.IllegalComponentStateException) JPopupMenu(javax.swing.JPopupMenu) JSeparator(javax.swing.JSeparator) StringSelection(java.awt.datatransfer.StringSelection) EmptyStackException(java.util.EmptyStackException) JTextPane(javax.swing.JTextPane) Clipboard(java.awt.datatransfer.Clipboard) JMenuItem(javax.swing.JMenuItem)

Example 2 with TabHeader

use of com.jsql.view.swing.tab.TabHeader 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);
    }
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) LightScrollPaneShell(com.jsql.view.swing.scrollpane.LightScrollPaneShell) MalformedURLException(java.net.MalformedURLException) ShellSql(com.jsql.view.swing.shell.ShellSql) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) UUID(java.util.UUID)

Example 3 with TabHeader

use of com.jsql.view.swing.tab.TabHeader in project jsql-injection by ron190.

the class CreateFileTab method execute.

@Override
public void execute() {
    if (MediatorGui.tabResults() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.tabResults() in " + this.getClass());
    }
    JTextArea fileText = new JPopupTextArea().getProxy();
    fileText.setText(this.content);
    fileText.setFont(new Font(HelperUi.FONT_NAME_UBUNTU_MONO, Font.PLAIN, 14));
    LightScrollPane scroller = new LightScrollPane(1, 0, 0, 0, fileText);
    fileText.setCaretPosition(0);
    MediatorGui.tabResults().addTab(this.name + " ", scroller);
    // Focus on the new tab
    MediatorGui.tabResults().setSelectedComponent(scroller);
    // Create a custom tab header with close button
    TabHeader header = new TabHeader(this.name, HelperUi.ICON_FILE_SERVER);
    MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), this.path);
    // Apply the custom header to the tab
    MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(scroller), header);
    // Add the path String to the list of files only if there is no same StringObject value already
    MediatorGui.managerWebshell().addToList(this.path.replace(this.name, ""));
    MediatorGui.managerUpload().addToList(this.path.replace(this.name, ""));
    MediatorGui.managerSqlshell().addToList(this.path.replace(this.name, ""));
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) JTextArea(javax.swing.JTextArea) JPopupTextArea(com.jsql.view.swing.text.JPopupTextArea) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) Font(java.awt.Font)

Example 4 with TabHeader

use of com.jsql.view.swing.tab.TabHeader in project jsql-injection by ron190.

the class CreateShellTab method execute.

@Override
public void execute() {
    if (MediatorGui.frame() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
    }
    try {
        UUID terminalID = UUID.randomUUID();
        ShellWeb terminal = new ShellWeb(terminalID, this.url);
        MediatorGui.frame().getConsoles().put(terminalID, terminal);
        LightScrollPane scroller = new LightScrollPaneShell(terminal);
        MediatorGui.tabResults().addTab("Web shell ", scroller);
        // Focus on the new tab
        MediatorGui.tabResults().setSelectedComponent(scroller);
        // Create a custom tab header with close button
        TabHeader header = new TabHeader("Web shell", HelperUi.ICON_SHELL_SERVER);
        MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(scroller), "<html><b>URL</b><br>" + this.url + RessourceAccess.FILENAME_WEBSHELL + "<br><b>Path</b><br>" + this.path + RessourceAccess.FILENAME_WEBSHELL + "</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);
    }
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) LightScrollPaneShell(com.jsql.view.swing.scrollpane.LightScrollPaneShell) MalformedURLException(java.net.MalformedURLException) ShellWeb(com.jsql.view.swing.shell.ShellWeb) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) UUID(java.util.UUID)

Example 5 with TabHeader

use of com.jsql.view.swing.tab.TabHeader in project jsql-injection by ron190.

the class CreateValuesTab method execute.

@Override
public void execute() {
    if (MediatorGui.frame() == null) {
        LOGGER.error("Unexpected unregistered MediatorGui.frame() in " + this.getClass());
    }
    // Report NullPointerException #1683
    DefaultMutableTreeNode node = MediatorGui.frame().getTreeNodeModels().get(this.table);
    if (node != null) {
        // Get the node
        AbstractNodeModel progressingTreeNodeModel = (AbstractNodeModel) node.getUserObject();
        // Update the progress value of the model, end the progress
        progressingTreeNodeModel.setIndexProgress(this.table.getChildCount());
        // Mark the node model as 'no stop/pause/resume button'
        progressingTreeNodeModel.setRunning(false);
        // Create a new table to display the values
        PanelTable newTableJPanel = new PanelTable(this.data, this.columnNames);
        // Create a new tab: add header and table
        MediatorGui.tabResults().addTab(StringUtil.detectUtf8(this.table.toString()), newTableJPanel);
        newTableJPanel.setComponentOrientation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()));
        // Focus on the new tab
        MediatorGui.tabResults().setSelectedComponent(newTableJPanel);
        // Create a custom tab header with close button
        TabHeader header = new TabHeader(StringUtil.detectUtf8Html(this.table.toString()));
        MediatorGui.tabResults().setToolTipTextAt(MediatorGui.tabResults().indexOfComponent(newTableJPanel), "<html>" + "<b>" + this.table.getParent() + "." + this.table + "</b><br>" + "<i>" + String.join("<br>", Arrays.copyOfRange(this.columnNames, 2, this.columnNames.length)) + "</i>" + "</html>");
        // Apply the custom header to the tab
        MediatorGui.tabResults().setTabComponentAt(MediatorGui.tabResults().indexOfComponent(newTableJPanel), header);
    }
}
Also used : TabHeader(com.jsql.view.swing.tab.TabHeader) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractNodeModel(com.jsql.view.swing.tree.model.AbstractNodeModel) PanelTable(com.jsql.view.swing.table.PanelTable)

Aggregations

TabHeader (com.jsql.view.swing.tab.TabHeader)5 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)4 LightScrollPaneShell (com.jsql.view.swing.scrollpane.LightScrollPaneShell)2 MalformedURLException (java.net.MalformedURLException)2 UUID (java.util.UUID)2 ShellSql (com.jsql.view.swing.shell.ShellSql)1 ShellWeb (com.jsql.view.swing.shell.ShellWeb)1 PanelTable (com.jsql.view.swing.table.PanelTable)1 JPopupTextArea (com.jsql.view.swing.text.JPopupTextArea)1 AbstractNodeModel (com.jsql.view.swing.tree.model.AbstractNodeModel)1 Font (java.awt.Font)1 IllegalComponentStateException (java.awt.IllegalComponentStateException)1 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1 FocusAdapter (java.awt.event.FocusAdapter)1 FocusEvent (java.awt.event.FocusEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 IOException (java.io.IOException)1 EmptyStackException (java.util.EmptyStackException)1