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