| 1 | /******************************************************************************* | |
| 2 | * Copyhacked (H) 2012-2025. | |
| 3 | * This program and the accompanying materials | |
| 4 | * are made available under no term at all, use it like | |
| 5 | * you want, but share and discuss it | |
| 6 | * every time possible with every body. | |
| 7 | * | |
| 8 | * Contributors: | |
| 9 | * ron190 at ymail dot com - initial implementation | |
| 10 | *******************************************************************************/ | |
| 11 | package com.jsql.view.swing.tab; | |
| 12 | ||
| 13 | import com.formdev.flatlaf.extras.FlatSVGIcon; | |
| 14 | import com.jsql.model.bean.database.AbstractElementDatabase; | |
| 15 | import com.jsql.util.I18nUtil; | |
| 16 | import com.jsql.util.LogLevelUtil; | |
| 17 | import com.jsql.util.StringUtil; | |
| 18 | import com.jsql.util.reverse.ModelReverse; | |
| 19 | import com.jsql.view.swing.action.ActionCloseTabResult; | |
| 20 | import com.jsql.view.swing.action.HotkeyUtil; | |
| 21 | import com.jsql.view.swing.popupmenu.JPopupMenuText; | |
| 22 | import com.jsql.view.swing.tab.dnd.DnDTabbedPane; | |
| 23 | import com.jsql.view.swing.tab.dnd.TabTransferHandler; | |
| 24 | import com.jsql.view.swing.table.PanelTable; | |
| 25 | import com.jsql.view.swing.terminal.AbstractExploit; | |
| 26 | import com.jsql.view.swing.terminal.ExploitReverseShell; | |
| 27 | import com.jsql.view.swing.text.JPopupTextArea; | |
| 28 | import com.jsql.view.swing.text.JTextFieldPlaceholder; | |
| 29 | import com.jsql.view.swing.util.MediatorHelper; | |
| 30 | import com.jsql.view.swing.util.RadioItemPreventClose; | |
| 31 | import com.jsql.view.swing.util.UiStringUtil; | |
| 32 | import com.jsql.view.swing.util.UiUtil; | |
| 33 | import org.apache.commons.lang3.StringUtils; | |
| 34 | import org.apache.logging.log4j.LogManager; | |
| 35 | import org.apache.logging.log4j.Logger; | |
| 36 | ||
| 37 | import javax.swing.*; | |
| 38 | import javax.swing.event.HyperlinkEvent; | |
| 39 | import java.awt.*; | |
| 40 | import java.awt.event.*; | |
| 41 | import java.io.IOException; | |
| 42 | import java.net.MalformedURLException; | |
| 43 | import java.net.URISyntaxException; | |
| 44 | import java.util.Arrays; | |
| 45 | import java.util.List; | |
| 46 | import java.util.UUID; | |
| 47 | import java.util.function.BiConsumer; | |
| 48 | import java.util.function.IntConsumer; | |
| 49 | ||
| 50 | /** | |
| 51 | * TabbedPane containing result injection panels. | |
| 52 | */ | |
| 53 | public class TabResults extends DnDTabbedPane { | |
| 54 | ||
| 55 | private static final Logger LOGGER = LogManager.getRootLogger(); | |
| 56 | ||
| 57 | public static final String TAB_EXPLOIT_FAILURE_INCORRECT_URL = "Tab exploit failure: incorrect URL"; | |
| 58 | public static final String UDF_SHELL = "UDF shell"; | |
| 59 | public static final String SQL_SHELL = "sqlShell"; | |
| 60 | public static final String WEB_SHELL = "webShell"; | |
| 61 | public static final String REV_SHELL = "revShell"; | |
| 62 | public static final String REVERSE_SHELL = "Reverse shell"; | |
| 63 | ||
| 64 | /** | |
| 65 | * Create the panel containing injection results. | |
| 66 | */ | |
| 67 | public TabResults() { | |
| 68 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabResults::setName → NO_COVERAGE |
this.setName("tabResults"); |
| 69 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabResults::setTabLayoutPolicy → NO_COVERAGE |
this.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); |
| 70 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabResults::setTransferHandler → NO_COVERAGE |
this.setTransferHandler(new TabTransferHandler()); |
| 71 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabResults::putClientProperty → NO_COVERAGE |
this.putClientProperty("JTabbedPane.tabClosable", true); |
| 72 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabResults::putClientProperty → NO_COVERAGE |
this.putClientProperty("JTabbedPane.tabCloseCallback", (IntConsumer) ActionCloseTabResult::perform); |
| 73 | UIManager.put("TabbedPane.closeHoverForeground", LogLevelUtil.COLOR_RED); | |
| 74 |
1
1. <init> : removed call to com/jsql/view/swing/action/HotkeyUtil::addShortcut → NO_COVERAGE |
HotkeyUtil.addShortcut(this); // Add hotkeys to root-pane ctrl-tab, ctrl-shift-tab, ctrl-w |
| 75 |
1
1. <init> : removed call to com/jsql/view/swing/tab/TabResults::addMouseWheelListener → NO_COVERAGE |
this.addMouseWheelListener(new TabbedPaneMouseWheelListener()); |
| 76 |
1
1. <init> : removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE |
MediatorHelper.register(this); |
| 77 | } | |
| 78 | ||
| 79 | public void addFileTab(String label, String content, String path) { | |
| 80 | JTextArea fileText = new JPopupTextArea().getProxy(); | |
| 81 |
1
1. addFileTab : removed call to javax/swing/JTextArea::setText → NO_COVERAGE |
fileText.setText(content); |
| 82 |
1
1. addFileTab : removed call to javax/swing/JTextArea::setFont → NO_COVERAGE |
fileText.setFont(new Font(UiUtil.FONT_NAME_MONO_NON_ASIAN, Font.PLAIN, 14)); |
| 83 |
1
1. addFileTab : removed call to javax/swing/JTextArea::setCaretPosition → NO_COVERAGE |
fileText.setCaretPosition(0); |
| 84 |
1
1. addFileTab : removed call to com/jsql/view/swing/tab/TabResults::addTextTab → NO_COVERAGE |
this.addTextTab(label, path, fileText, UiUtil.DOWNLOAD.getIcon()); |
| 85 |
1
1. addFileTab : removed call to com/jsql/view/swing/tab/TabManagersCards::addToLists → NO_COVERAGE |
MediatorHelper.tabManagersCards().addToLists(path, label); |
| 86 | } | |
| 87 | ||
| 88 | public void addReportTab(String content) { | |
| 89 | JEditorPane editorPane = new JEditorPane(); | |
| 90 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setContentType → NO_COVERAGE |
editorPane.setContentType("text/html"); |
| 91 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setText → NO_COVERAGE |
editorPane.setText("<html><span style=\"white-space: nowrap; font-family:'"+ UiUtil.FONT_NAME_MONO_NON_ASIAN +"'\">" + content + "</span></html>"); |
| 92 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setFont → NO_COVERAGE |
editorPane.setFont(UIManager.getFont("TextArea.font")); // required to increase text size |
| 93 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setDragEnabled → NO_COVERAGE |
editorPane.setDragEnabled(true); |
| 94 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setEditable → NO_COVERAGE |
editorPane.setEditable(false); |
| 95 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setCaretPosition → NO_COVERAGE |
editorPane.setCaretPosition(0); |
| 96 |
1
1. addReportTab : removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE |
editorPane.getCaret().setBlinkRate(0); |
| 97 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setCursor → NO_COVERAGE |
editorPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); |
| 98 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::setComponentPopupMenu → NO_COVERAGE |
editorPane.setComponentPopupMenu(new JPopupMenuText(editorPane)); |
| 99 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::addHyperlinkListener → NO_COVERAGE |
editorPane.addHyperlinkListener(linkEvent -> { |
| 100 |
1
1. lambda$addReportTab$0 : negated conditional → NO_COVERAGE |
if (HyperlinkEvent.EventType.ACTIVATED.equals(linkEvent.getEventType())) { |
| 101 | try { | |
| 102 |
1
1. lambda$addReportTab$0 : removed call to java/awt/Desktop::browse → NO_COVERAGE |
Desktop.getDesktop().browse(linkEvent.getURL().toURI()); |
| 103 | } catch (IOException | URISyntaxException | UnsupportedOperationException e) { | |
| 104 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Failing to browse Url", e); | |
| 105 | } | |
| 106 | } | |
| 107 | }); | |
| 108 |
1
1. addReportTab : removed call to javax/swing/JEditorPane::addFocusListener → NO_COVERAGE |
editorPane.addFocusListener(new FocusAdapter() { |
| 109 | @Override | |
| 110 | public void focusGained(FocusEvent focusEvent) { | |
| 111 |
1
1. focusGained : removed call to javax/swing/text/Caret::setVisible → NO_COVERAGE |
editorPane.getCaret().setVisible(true); |
| 112 |
1
1. focusGained : removed call to javax/swing/text/Caret::setSelectionVisible → NO_COVERAGE |
editorPane.getCaret().setSelectionVisible(true); |
| 113 |
1
1. focusGained : removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE |
editorPane.getCaret().setBlinkRate(0); |
| 114 | } | |
| 115 | }); | |
| 116 |
1
1. addReportTab : removed call to com/jsql/view/swing/util/UiUtil::init → NO_COVERAGE |
UiUtil.init(editorPane); // silent delete |
| 117 | ||
| 118 |
1
1. addReportTab : removed call to com/jsql/view/swing/tab/TabResults::addTextTab → NO_COVERAGE |
this.addTextTab("Vulnerability report", "Analysis report with all payloads detected", editorPane, UiUtil.APP_ICON.getIcon()); |
| 119 | } | |
| 120 | ||
| 121 | public void addTextTab(String label, String toolTipText, JComponent componentText, FlatSVGIcon icon) { | |
| 122 | var scroller = new JScrollPane(componentText); | |
| 123 |
1
1. addTextTab : removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE |
this.addTab(label + StringUtils.SPACE, scroller); |
| 124 |
1
1. addTextTab : removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE |
this.setSelectedComponent(scroller); // Focus on the new tab |
| 125 |
1
1. addTextTab : removed call to com/jsql/view/swing/tab/TabResults::setToolTipTextAt → NO_COVERAGE |
this.setToolTipTextAt(this.indexOfComponent(scroller), toolTipText); |
| 126 | var header = new TabHeader(label, icon); | |
| 127 |
1
1. addTextTab : removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt(this.indexOfComponent(scroller), header); |
| 128 | ||
| 129 |
1
1. addTextTab : removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE |
this.updateUI(); // required: light, open/close prefs, dark => light artifacts |
| 130 | } | |
| 131 | ||
| 132 | public void addTabExploitWeb(String url) { | |
| 133 | try { | |
| 134 | var terminalID = UUID.randomUUID(); | |
| 135 | var terminal = new AbstractExploit(terminalID, url, "web") { | |
| 136 | @Override | |
| 137 | public void action(String command, UUID terminalID, String urlShell, String... arg) { | |
| 138 | MediatorHelper.model().getResourceAccess().runWebShell(command, terminalID, urlShell); | |
| 139 | } | |
| 140 | }; | |
| 141 |
1
1. addTabExploitWeb : removed call to com/jsql/view/swing/tab/TabResults$2::setName → NO_COVERAGE |
terminal.setName(TabResults.WEB_SHELL); |
| 142 | MediatorHelper.frame().getMapUuidShell().put(terminalID, terminal); | |
| 143 | ||
| 144 | JPanel panelTerminalWithReverse = this.getTerminalWithMenu(terminal); | |
| 145 |
1
1. addTabExploitWeb : removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE |
this.addTab("Web shell", panelTerminalWithReverse); |
| 146 |
1
1. addTabExploitWeb : removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE |
this.setSelectedComponent(panelTerminalWithReverse); // Focus on the new tab |
| 147 | ||
| 148 | var header = new TabHeader("Web shell", UiUtil.TERMINAL.getIcon()); | |
| 149 |
1
1. addTabExploitWeb : removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt(this.indexOfComponent(panelTerminalWithReverse), header); |
| 150 | terminal.requestFocusInWindow(); | |
| 151 | ||
| 152 |
1
1. addTabExploitWeb : removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE |
this.updateUI(); // required: light, open/close prefs, dark => light artifacts |
| 153 | } catch (MalformedURLException | URISyntaxException e) { | |
| 154 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, TabResults.TAB_EXPLOIT_FAILURE_INCORRECT_URL, e); | |
| 155 | } | |
| 156 | } | |
| 157 | ||
| 158 | public void addTabExploitReverseShell(String port) { | |
| 159 | try { | |
| 160 | var terminalID = UUID.randomUUID(); | |
| 161 | var terminal = new ExploitReverseShell(terminalID, port); | |
| 162 |
1
1. addTabExploitReverseShell : removed call to com/jsql/view/swing/terminal/ExploitReverseShell::setName → NO_COVERAGE |
terminal.setName(TabResults.REV_SHELL); |
| 163 | MediatorHelper.frame().getMapUuidShell().put(terminalID, terminal); | |
| 164 | ||
| 165 | JScrollPane scroller = new JScrollPane(terminal); | |
| 166 |
1
1. addTabExploitReverseShell : removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE |
this.addTab(TabResults.REVERSE_SHELL, scroller); |
| 167 |
1
1. addTabExploitReverseShell : removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE |
this.setSelectedComponent(scroller); // Focus on the new tab |
| 168 | ||
| 169 | var header = new TabHeader(TabResults.REVERSE_SHELL, UiUtil.TERMINAL.getIcon()); | |
| 170 |
1
1. addTabExploitReverseShell : removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt(this.indexOfComponent(scroller), header); |
| 171 | terminal.requestFocusInWindow(); | |
| 172 | ||
| 173 |
1
1. addTabExploitReverseShell : removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE |
this.updateUI(); // required: light, open/close prefs, dark => light artifacts |
| 174 | } catch (URISyntaxException | IOException e) { | |
| 175 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, TabResults.TAB_EXPLOIT_FAILURE_INCORRECT_URL, e); | |
| 176 | } | |
| 177 | } | |
| 178 | ||
| 179 | public void addTabExploitUdf(BiConsumer<String, UUID> biConsumerRunCmd) { | |
| 180 | try { | |
| 181 | var terminalID = UUID.randomUUID(); | |
| 182 | var terminal = new AbstractExploit(terminalID, null, "udf") { | |
| 183 | @Override | |
| 184 | public void action(String command, UUID terminalID, String urlShell, String... arg) { | |
| 185 |
1
1. action : removed call to java/util/function/BiConsumer::accept → NO_COVERAGE |
biConsumerRunCmd.accept(command, terminalID); |
| 186 | } | |
| 187 | }; | |
| 188 | MediatorHelper.frame().getMapUuidShell().put(terminalID, terminal); | |
| 189 | ||
| 190 | JPanel panelTerminalWithReverse = this.getTerminalWithMenu(terminal); | |
| 191 |
1
1. addTabExploitUdf : removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE |
this.addTab(TabResults.UDF_SHELL, panelTerminalWithReverse); |
| 192 |
1
1. addTabExploitUdf : removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE |
this.setSelectedComponent(panelTerminalWithReverse); // Focus on the new tab |
| 193 | ||
| 194 | var header = new TabHeader(TabResults.UDF_SHELL, UiUtil.TERMINAL.getIcon()); | |
| 195 |
1
1. addTabExploitUdf : removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt(this.indexOfComponent(panelTerminalWithReverse), header); |
| 196 | terminal.requestFocusInWindow(); | |
| 197 | ||
| 198 |
1
1. addTabExploitUdf : removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE |
this.updateUI(); // required: light, open/close prefs, dark => light artifacts |
| 199 | } catch (MalformedURLException | URISyntaxException e) { | |
| 200 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, TabResults.TAB_EXPLOIT_FAILURE_INCORRECT_URL, e); | |
| 201 | } | |
| 202 | } | |
| 203 | ||
| 204 | public void addTabExploitSql(String url, String user, String pass) { | |
| 205 | try { | |
| 206 | var terminalID = UUID.randomUUID(); | |
| 207 | var terminal = new AbstractExploit(terminalID, url, "sql") { | |
| 208 | @Override | |
| 209 | public void action(String cmd, UUID terminalID, String wbhPath, String... arg) { | |
| 210 | MediatorHelper.model().getResourceAccess().runSqlShell(cmd, terminalID, wbhPath, arg[0], arg[1]); | |
| 211 | } | |
| 212 | }; | |
| 213 |
1
1. addTabExploitSql : removed call to com/jsql/view/swing/tab/TabResults$4::setName → NO_COVERAGE |
terminal.setName(TabResults.SQL_SHELL); |
| 214 |
1
1. addTabExploitSql : removed call to com/jsql/view/swing/tab/TabResults$4::setLoginPassword → NO_COVERAGE |
terminal.setLoginPassword(new String[]{ user, pass }); |
| 215 | MediatorHelper.frame().getMapUuidShell().put(terminalID, terminal); | |
| 216 | ||
| 217 | JScrollPane scroller = new JScrollPane(terminal); | |
| 218 |
1
1. addTabExploitSql : removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE |
this.addTab("SQL shell", scroller); |
| 219 |
1
1. addTabExploitSql : removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE |
this.setSelectedComponent(scroller); // Focus on the new tab |
| 220 | ||
| 221 | var header = new TabHeader("SQL shell", UiUtil.TERMINAL.getIcon()); | |
| 222 |
1
1. addTabExploitSql : removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt(this.indexOfComponent(scroller), header); |
| 223 | terminal.requestFocusInWindow(); | |
| 224 | ||
| 225 |
1
1. addTabExploitSql : removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE |
this.updateUI(); // required: light, open/close prefs, dark => light artifacts |
| 226 | } catch (MalformedURLException | URISyntaxException e) { | |
| 227 | LOGGER.log(LogLevelUtil.CONSOLE_ERROR, TabResults.TAB_EXPLOIT_FAILURE_INCORRECT_URL, e); | |
| 228 | } | |
| 229 | } | |
| 230 | | |
| 231 | public void addTabValues(String[][] data, String[] columnNames, AbstractElementDatabase table) { | |
| 232 | var panelTable = new PanelTable(data, columnNames); | |
| 233 | | |
| 234 |
1
1. addTabValues : removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE |
this.addTab(StringUtil.detectUtf8(table.toString()), panelTable); |
| 235 |
1
1. addTabValues : removed call to com/jsql/view/swing/table/PanelTable::setComponentOrientation → NO_COVERAGE |
panelTable.setComponentOrientation(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale())); |
| 236 | | |
| 237 |
1
1. addTabValues : removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE |
this.setSelectedComponent(panelTable); // Focus on the new tab |
| 238 | ||
| 239 | var header = new TabHeader(UiStringUtil.detectUtf8Html(table.toString()), UiUtil.TABLE_BOLD.getIcon()); | |
| 240 |
1
1. addTabValues : removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE |
this.setTabComponentAt(this.indexOfComponent(panelTable), header); |
| 241 | ||
| 242 |
1
1. addTabValues : removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE |
this.updateUI(); // required: light, open/close prefs, dark => light artifacts |
| 243 | } | |
| 244 | ||
| 245 | private JPanel getTerminalWithMenu(AbstractExploit terminal) { | |
| 246 | JPanel panelTerminalWithReverse = new JPanel() { | |
| 247 | @Override | |
| 248 | public boolean isOptimizedDrawingEnabled() { | |
| 249 |
1
1. isOptimizedDrawingEnabled : replaced boolean return with true for com/jsql/view/swing/tab/TabResults$5::isOptimizedDrawingEnabled → NO_COVERAGE |
return false; // both components always visible |
| 250 | } | |
| 251 | }; | |
| 252 | OverlayLayout overlay = new OverlayLayout(panelTerminalWithReverse); | |
| 253 |
1
1. getTerminalWithMenu : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelTerminalWithReverse.setLayout(overlay); |
| 254 | ||
| 255 | var panelReverseMargin = new JPanel(); | |
| 256 |
1
1. getTerminalWithMenu : removed call to javax/swing/JPanel::setLayout → NO_COVERAGE |
panelReverseMargin.setLayout(new BoxLayout(panelReverseMargin, BoxLayout.LINE_AXIS)); |
| 257 |
1
1. getTerminalWithMenu : removed call to javax/swing/JPanel::setOpaque → NO_COVERAGE |
panelReverseMargin.setOpaque(false); |
| 258 |
1
1. getTerminalWithMenu : removed call to javax/swing/JPanel::setBorder → NO_COVERAGE |
panelReverseMargin.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 15)); |
| 259 | ||
| 260 | var menuReverse = new JLabel(TabResults.REVERSE_SHELL, UiUtil.ARROW_DOWN.getIcon(), SwingConstants.LEFT); | |
| 261 |
1
1. getTerminalWithMenu : removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE |
menuReverse.addMouseListener(new MouseAdapter() { |
| 262 | @Override | |
| 263 | public void mousePressed(MouseEvent e) { | |
| 264 | var popupMenu = TabResults.this.showMenu(terminal); | |
| 265 |
1
1. mousePressed : removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE |
popupMenu.updateUI(); // required: incorrect when dark/light mode switch |
| 266 |
3
1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE 2. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE 3. mousePressed : removed call to javax/swing/JPopupMenu::show → NO_COVERAGE |
popupMenu.show(e.getComponent(), e.getComponent().getX(),5 + e.getComponent().getY() + e.getComponent().getHeight()); |
| 267 |
3
1. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE 2. mousePressed : Replaced integer addition with subtraction → NO_COVERAGE 3. mousePressed : removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE |
popupMenu.setLocation(e.getComponent().getLocationOnScreen().x,5 + e.getComponent().getLocationOnScreen().y + e.getComponent().getHeight()); |
| 268 | } | |
| 269 | }); | |
| 270 |
1
1. getTerminalWithMenu : removed call to javax/swing/JLabel::setMaximumSize → NO_COVERAGE |
menuReverse.setMaximumSize(menuReverse.getPreferredSize()); |
| 271 | JScrollPane scrollerTerminal = new JScrollPane(terminal); | |
| 272 |
1
1. getTerminalWithMenu : removed call to javax/swing/JScrollPane::setAlignmentX → NO_COVERAGE |
scrollerTerminal.setAlignmentX(1f); |
| 273 |
1
1. getTerminalWithMenu : removed call to javax/swing/JScrollPane::setAlignmentY → NO_COVERAGE |
scrollerTerminal.setAlignmentY(0f); |
| 274 |
1
1. getTerminalWithMenu : removed call to javax/swing/JPanel::setAlignmentX → NO_COVERAGE |
panelReverseMargin.setAlignmentX(1f); |
| 275 |
1
1. getTerminalWithMenu : removed call to javax/swing/JPanel::setAlignmentY → NO_COVERAGE |
panelReverseMargin.setAlignmentY(0f); |
| 276 | panelReverseMargin.add(menuReverse); | |
| 277 | panelTerminalWithReverse.add(panelReverseMargin); | |
| 278 | panelTerminalWithReverse.add(scrollerTerminal); | |
| 279 | ||
| 280 |
1
1. getTerminalWithMenu : replaced return value with null for com/jsql/view/swing/tab/TabResults::getTerminalWithMenu → NO_COVERAGE |
return panelTerminalWithReverse; |
| 281 | } | |
| 282 | ||
| 283 | private JPopupMenu showMenu(AbstractExploit terminal) { | |
| 284 | JPopupMenu menuReverse = new JPopupMenu(); | |
| 285 | ||
| 286 | var menuListen = new JMenu("Listen"); | |
| 287 |
1
1. showMenu : removed call to javax/swing/JMenu::setComponentOrientation → NO_COVERAGE |
menuListen.setComponentOrientation( |
| 288 |
1
1. showMenu : negated conditional → NO_COVERAGE |
ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale())) |
| 289 | ? ComponentOrientation.LEFT_TO_RIGHT | |
| 290 | : ComponentOrientation.RIGHT_TO_LEFT | |
| 291 | ); | |
| 292 | var panelPublicAddress = new JPanel(new BorderLayout()); | |
| 293 | panelPublicAddress.add(new JLabel("<html><b>Your public address (listener) :</b></html>")); | |
| 294 | menuListen.add(panelPublicAddress); | |
| 295 | menuListen.add(new JSeparator()); | |
| 296 | var address = new JTextFieldPlaceholder("Local IP/domain", "10.0.2.2"); | |
| 297 | menuListen.add(address); | |
| 298 | var port = new JTextFieldPlaceholder("Local port", "4444"); | |
| 299 | menuListen.add(port); | |
| 300 | ||
| 301 | var panelServerConnection = new JPanel(new BorderLayout()); | |
| 302 | panelServerConnection.add(new JLabel("<html><b>Server method (connector) :</b></html>")); | |
| 303 | menuListen.add(panelServerConnection); | |
| 304 | menuListen.add(new JSeparator()); | |
| 305 | var buttonGroup = new ButtonGroup(); | |
| 306 | List<ModelReverse> commandsReverse = MediatorHelper.model().getMediatorUtils().getPreferencesUtil().getCommandsReverse(); | |
| 307 |
1
1. showMenu : removed call to java/util/List::forEach → NO_COVERAGE |
commandsReverse.forEach(modelReverse -> { |
| 308 | var radio = new RadioItemPreventClose(modelReverse.getName()); | |
| 309 |
1
1. lambda$showMenu$1 : removed call to com/jsql/view/swing/util/RadioItemPreventClose::setActionCommand → NO_COVERAGE |
radio.setActionCommand(modelReverse.getName()); |
| 310 |
1
1. lambda$showMenu$1 : removed call to com/jsql/view/swing/util/RadioItemPreventClose::setSelected → NO_COVERAGE |
radio.setSelected("bash".equals(modelReverse.getName())); |
| 311 |
1
1. lambda$showMenu$1 : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonGroup.add(radio); |
| 312 | menuListen.add(radio); | |
| 313 | }); | |
| 314 | ||
| 315 | Runnable runnableReverse = () -> { | |
| 316 | try { | |
| 317 |
1
1. lambda$showMenu$4 : removed call to java/lang/Thread::sleep → NO_COVERAGE |
Thread.sleep(2500); |
| 318 | MediatorHelper.model().getMediatorUtils().getPreferencesUtil().getCommandsReverse().stream() | |
| 319 |
2
1. lambda$showMenu$2 : replaced boolean return with false for com/jsql/view/swing/tab/TabResults::lambda$showMenu$2 → NO_COVERAGE 2. lambda$showMenu$2 : replaced boolean return with true for com/jsql/view/swing/tab/TabResults::lambda$showMenu$2 → NO_COVERAGE |
.filter(modelReverse -> modelReverse.getName().equals(buttonGroup.getSelection().getActionCommand())) |
| 320 | .findFirst() | |
| 321 |
1
1. lambda$showMenu$4 : removed call to java/util/Optional::ifPresent → NO_COVERAGE |
.ifPresent(modelReverse -> MediatorHelper.model().getResourceAccess().runWebShell( |
| 322 | String.format(modelReverse.getCommand(), address.getText(), port.getText()), | |
| 323 | null, // ignore connection response | |
| 324 | terminal.getUrlShell(), | |
| 325 | true | |
| 326 | )); | |
| 327 | } catch (InterruptedException e) { | |
| 328 | LOGGER.log(LogLevelUtil.IGNORE, e, e); | |
| 329 |
1
1. lambda$showMenu$4 : removed call to java/lang/Thread::interrupt → NO_COVERAGE |
Thread.currentThread().interrupt(); |
| 330 | } | |
| 331 | }; | |
| 332 | ||
| 333 | var panelOpenIn = new JPanel(new BorderLayout()); | |
| 334 | panelOpenIn.add(new JLabel("<html><b>Open In :</b></html>")); | |
| 335 | menuListen.add(panelOpenIn); | |
| 336 | menuListen.add(new JSeparator()); | |
| 337 | ||
| 338 | var menuBuiltInShell = new RadioItemPreventClose("Built-in shell", true); | |
| 339 | var menuExternalShell = new RadioItemPreventClose("External listening shell"); | |
| 340 | var buttonTypeShell = new ButtonGroup(); | |
| 341 |
1
1. showMenu : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonTypeShell.add(menuBuiltInShell); |
| 342 |
1
1. showMenu : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonTypeShell.add(menuExternalShell); |
| 343 | menuListen.add(menuBuiltInShell); | |
| 344 | menuListen.add(menuExternalShell); | |
| 345 | menuListen.add(new JSeparator()); | |
| 346 | var panelCreate = new JPanel(new BorderLayout()); | |
| 347 | panelCreate.add(new JButton(new AbstractAction("Create reverse shell") { | |
| 348 | @Override | |
| 349 | public void actionPerformed(ActionEvent e) { | |
| 350 |
1
1. actionPerformed : negated conditional → NO_COVERAGE |
if (menuBuiltInShell.isSelected()) { |
| 351 |
2
1. lambda$actionPerformed$0 : removed call to com/jsql/view/swing/tab/TabResults::addTabExploitReverseShell → NO_COVERAGE 2. actionPerformed : removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE |
SwingUtilities.invokeLater(() -> MediatorHelper.tabResults().addTabExploitReverseShell(port.getText())); |
| 352 | } | |
| 353 |
1
1. actionPerformed : removed call to java/lang/Thread::start → NO_COVERAGE |
new Thread(runnableReverse).start(); |
| 354 |
1
1. actionPerformed : removed call to javax/swing/JPopupMenu::setVisible → NO_COVERAGE |
menuReverse.setVisible(false); |
| 355 | } | |
| 356 | })); | |
| 357 | menuListen.add(panelCreate); | |
| 358 | ||
| 359 | var menuConnect = new JMenu("Connect"); | |
| 360 |
1
1. showMenu : removed call to javax/swing/JMenu::setComponentOrientation → NO_COVERAGE |
menuConnect.setComponentOrientation( |
| 361 |
1
1. showMenu : negated conditional → NO_COVERAGE |
ComponentOrientation.RIGHT_TO_LEFT.equals(ComponentOrientation.getOrientation(I18nUtil.getCurrentLocale())) |
| 362 | ? ComponentOrientation.LEFT_TO_RIGHT | |
| 363 | : ComponentOrientation.RIGHT_TO_LEFT | |
| 364 | ); | |
| 365 | var panelServerPublicAddress = new JPanel(new BorderLayout()); | |
| 366 | panelServerPublicAddress.add(new JLabel("<html><b>Server public address (listener) :</b></html>")); | |
| 367 | menuConnect.add(panelServerPublicAddress); | |
| 368 | menuConnect.add(new JSeparator()); | |
| 369 | menuConnect.add(new JTextFieldPlaceholder("Target IP/domain")); | |
| 370 | menuConnect.add(new JTextFieldPlaceholder("Target port")); | |
| 371 | menuConnect.add(new JSeparator()); | |
| 372 | ||
| 373 | var panelServerListeningConnection = new JPanel(new BorderLayout()); | |
| 374 | panelServerListeningConnection.add(new JLabel("<html><b>Server listening method :</b></html>")); | |
| 375 | menuConnect.add(panelServerListeningConnection); | |
| 376 | var buttonGroupListening = new ButtonGroup(); | |
| 377 |
1
1. showMenu : removed call to java/util/List::forEach → NO_COVERAGE |
Arrays.asList("netcat").forEach(method -> { |
| 378 | var radio = new JRadioButtonMenuItem(method) { | |
| 379 | @Override | |
| 380 | protected void processMouseEvent(MouseEvent evt) { | |
| 381 |
2
1. processMouseEvent : negated conditional → NO_COVERAGE 2. processMouseEvent : negated conditional → NO_COVERAGE |
if (evt.getID() == MouseEvent.MOUSE_RELEASED && this.contains(evt.getPoint())) { |
| 382 |
1
1. processMouseEvent : removed call to com/jsql/view/swing/tab/TabResults$8::doClick → NO_COVERAGE |
this.doClick(); |
| 383 |
1
1. processMouseEvent : removed call to com/jsql/view/swing/tab/TabResults$8::setArmed → NO_COVERAGE |
this.setArmed(true); |
| 384 | } else { | |
| 385 |
1
1. processMouseEvent : removed call to javax/swing/JRadioButtonMenuItem::processMouseEvent → NO_COVERAGE |
super.processMouseEvent(evt); |
| 386 | } | |
| 387 | } | |
| 388 | }; | |
| 389 |
1
1. lambda$showMenu$5 : removed call to com/jsql/view/swing/tab/TabResults$8::setSelected → NO_COVERAGE |
radio.setSelected("netcat".equals(method)); |
| 390 |
1
1. lambda$showMenu$5 : removed call to javax/swing/ButtonGroup::add → NO_COVERAGE |
buttonGroupListening.add(radio); |
| 391 | menuConnect.add(radio); | |
| 392 | }); | |
| 393 | menuConnect.add(new JSeparator()); | |
| 394 | menuConnect.add(new JMenuItem("Create")); | |
| 395 | ||
| 396 | menuReverse.add(menuListen); | |
| 397 | menuReverse.add(menuConnect); | |
| 398 | ||
| 399 |
1
1. showMenu : replaced return value with null for com/jsql/view/swing/tab/TabResults::showMenu → NO_COVERAGE |
return menuReverse; |
| 400 | } | |
| 401 | } | |
Mutations | ||
| 68 |
1.1 |
|
| 69 |
1.1 |
|
| 70 |
1.1 |
|
| 71 |
1.1 |
|
| 72 |
1.1 |
|
| 74 |
1.1 |
|
| 75 |
1.1 |
|
| 76 |
1.1 |
|
| 81 |
1.1 |
|
| 82 |
1.1 |
|
| 83 |
1.1 |
|
| 84 |
1.1 |
|
| 85 |
1.1 |
|
| 90 |
1.1 |
|
| 91 |
1.1 |
|
| 92 |
1.1 |
|
| 93 |
1.1 |
|
| 94 |
1.1 |
|
| 95 |
1.1 |
|
| 96 |
1.1 |
|
| 97 |
1.1 |
|
| 98 |
1.1 |
|
| 99 |
1.1 |
|
| 100 |
1.1 |
|
| 102 |
1.1 |
|
| 108 |
1.1 |
|
| 111 |
1.1 |
|
| 112 |
1.1 |
|
| 113 |
1.1 |
|
| 116 |
1.1 |
|
| 118 |
1.1 |
|
| 123 |
1.1 |
|
| 124 |
1.1 |
|
| 125 |
1.1 |
|
| 127 |
1.1 |
|
| 129 |
1.1 |
|
| 141 |
1.1 |
|
| 145 |
1.1 |
|
| 146 |
1.1 |
|
| 149 |
1.1 |
|
| 152 |
1.1 |
|
| 162 |
1.1 |
|
| 166 |
1.1 |
|
| 167 |
1.1 |
|
| 170 |
1.1 |
|
| 173 |
1.1 |
|
| 185 |
1.1 |
|
| 191 |
1.1 |
|
| 192 |
1.1 |
|
| 195 |
1.1 |
|
| 198 |
1.1 |
|
| 213 |
1.1 |
|
| 214 |
1.1 |
|
| 218 |
1.1 |
|
| 219 |
1.1 |
|
| 222 |
1.1 |
|
| 225 |
1.1 |
|
| 234 |
1.1 |
|
| 235 |
1.1 |
|
| 237 |
1.1 |
|
| 240 |
1.1 |
|
| 242 |
1.1 |
|
| 249 |
1.1 |
|
| 253 |
1.1 |
|
| 256 |
1.1 |
|
| 257 |
1.1 |
|
| 258 |
1.1 |
|
| 261 |
1.1 |
|
| 265 |
1.1 |
|
| 266 |
1.1 2.2 3.3 |
|
| 267 |
1.1 2.2 3.3 |
|
| 270 |
1.1 |
|
| 272 |
1.1 |
|
| 273 |
1.1 |
|
| 274 |
1.1 |
|
| 275 |
1.1 |
|
| 280 |
1.1 |
|
| 287 |
1.1 |
|
| 288 |
1.1 |
|
| 307 |
1.1 |
|
| 309 |
1.1 |
|
| 310 |
1.1 |
|
| 311 |
1.1 |
|
| 317 |
1.1 |
|
| 319 |
1.1 2.2 |
|
| 321 |
1.1 |
|
| 329 |
1.1 |
|
| 341 |
1.1 |
|
| 342 |
1.1 |
|
| 350 |
1.1 |
|
| 351 |
1.1 2.2 |
|
| 353 |
1.1 |
|
| 354 |
1.1 |
|
| 360 |
1.1 |
|
| 361 |
1.1 |
|
| 377 |
1.1 |
|
| 381 |
1.1 2.2 |
|
| 382 |
1.1 |
|
| 383 |
1.1 |
|
| 385 |
1.1 |
|
| 389 |
1.1 |
|
| 390 |
1.1 |
|
| 399 |
1.1 |