TabResults.java

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

Mutations

71

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setName → NO_COVERAGE

72

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabLayoutPolicy → NO_COVERAGE

73

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTransferHandler → NO_COVERAGE

74

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::putClientProperty → NO_COVERAGE

75

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::putClientProperty → NO_COVERAGE

77

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/action/HotkeyUtil::addShortcut → NO_COVERAGE

78

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addMouseWheelListener → NO_COVERAGE

79

1.1
Location : <init>
Killed by : none
removed call to com/jsql/view/swing/util/MediatorHelper::register → NO_COVERAGE

84

1.1
Location : addFileTab
Killed by : none
removed call to javax/swing/JTextArea::setText → NO_COVERAGE

85

1.1
Location : addFileTab
Killed by : none
removed call to javax/swing/JTextArea::setFont → NO_COVERAGE

86

1.1
Location : addFileTab
Killed by : none
removed call to javax/swing/JTextArea::setCaretPosition → NO_COVERAGE

87

1.1
Location : addFileTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTextTab → NO_COVERAGE

88

1.1
Location : addFileTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabManagersCards::addToLists → NO_COVERAGE

93

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setContentType → NO_COVERAGE

94

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setText → NO_COVERAGE

95

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setFont → NO_COVERAGE

96

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setDragEnabled → NO_COVERAGE

97

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setEditable → NO_COVERAGE

98

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setCaretPosition → NO_COVERAGE

99

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE

100

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setCursor → NO_COVERAGE

101

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::setComponentPopupMenu → NO_COVERAGE

102

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::addHyperlinkListener → NO_COVERAGE

103

1.1
Location : lambda$addReportTab$0
Killed by : none
negated conditional → NO_COVERAGE

105

1.1
Location : lambda$addReportTab$0
Killed by : none
removed call to java/awt/Desktop::browse → NO_COVERAGE

111

1.1
Location : addReportTab
Killed by : none
removed call to javax/swing/JEditorPane::addFocusListener → NO_COVERAGE

114

1.1
Location : focusGained
Killed by : none
removed call to javax/swing/text/Caret::setVisible → NO_COVERAGE

115

1.1
Location : focusGained
Killed by : none
removed call to javax/swing/text/Caret::setSelectionVisible → NO_COVERAGE

116

1.1
Location : focusGained
Killed by : none
removed call to javax/swing/text/Caret::setBlinkRate → NO_COVERAGE

119

1.1
Location : addReportTab
Killed by : none
removed call to com/jsql/view/swing/util/UiUtil::init → NO_COVERAGE

121

1.1
Location : addReportTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTextTab → NO_COVERAGE

126

1.1
Location : addTextTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE

127

1.1
Location : addTextTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE

128

1.1
Location : addTextTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setToolTipTextAt → NO_COVERAGE

130

1.1
Location : addTextTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE

132

1.1
Location : addTextTab
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE

144

1.1
Location : addTabExploitWeb
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults$2::setName → NO_COVERAGE

148

1.1
Location : addTabExploitWeb
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE

149

1.1
Location : addTabExploitWeb
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE

152

1.1
Location : addTabExploitWeb
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE

155

1.1
Location : addTabExploitWeb
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE

165

1.1
Location : addTabExploitReverseShell
Killed by : none
removed call to com/jsql/view/swing/terminal/ExploitReverseShell::setName → NO_COVERAGE

169

1.1
Location : addTabExploitReverseShell
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE

170

1.1
Location : addTabExploitReverseShell
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE

173

1.1
Location : addTabExploitReverseShell
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE

176

1.1
Location : addTabExploitReverseShell
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE

188

1.1
Location : action
Killed by : none
removed call to java/util/function/BiConsumer::accept → NO_COVERAGE

194

1.1
Location : addTabExploitRce
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE

195

1.1
Location : addTabExploitRce
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE

198

1.1
Location : addTabExploitRce
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE

201

1.1
Location : addTabExploitRce
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE

216

1.1
Location : addTabExploitSql
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults$4::setName → NO_COVERAGE

217

1.1
Location : addTabExploitSql
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults$4::setLoginPassword → NO_COVERAGE

221

1.1
Location : addTabExploitSql
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE

222

1.1
Location : addTabExploitSql
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE

225

1.1
Location : addTabExploitSql
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE

228

1.1
Location : addTabExploitSql
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE

237

1.1
Location : addTabValues
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTab → NO_COVERAGE

238

1.1
Location : addTabValues
Killed by : none
removed call to com/jsql/view/swing/table/PanelTable::setComponentOrientation → NO_COVERAGE

240

1.1
Location : addTabValues
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setSelectedComponent → NO_COVERAGE

243

1.1
Location : addTabValues
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::setTabComponentAt → NO_COVERAGE

245

1.1
Location : addTabValues
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::updateUI → NO_COVERAGE

252

1.1
Location : isOptimizedDrawingEnabled
Killed by : none
replaced boolean return with true for com/jsql/view/swing/tab/TabResults$5::isOptimizedDrawingEnabled → NO_COVERAGE

256

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JPanel::setLayout → NO_COVERAGE

259

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JPanel::setLayout → NO_COVERAGE

260

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JPanel::setOpaque → NO_COVERAGE

261

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JPanel::setBorder → NO_COVERAGE

264

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JLabel::addMouseListener → NO_COVERAGE

268

1.1
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::updateUI → NO_COVERAGE

269

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

3.3
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::show → NO_COVERAGE

270

1.1
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

2.2
Location : mousePressed
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

3.3
Location : mousePressed
Killed by : none
removed call to javax/swing/JPopupMenu::setLocation → NO_COVERAGE

273

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JLabel::setMaximumSize → NO_COVERAGE

275

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JScrollPane::setAlignmentX → NO_COVERAGE

276

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JScrollPane::setAlignmentY → NO_COVERAGE

277

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JPanel::setAlignmentX → NO_COVERAGE

278

1.1
Location : getTerminalWithMenu
Killed by : none
removed call to javax/swing/JPanel::setAlignmentY → NO_COVERAGE

283

1.1
Location : getTerminalWithMenu
Killed by : none
replaced return value with null for com/jsql/view/swing/tab/TabResults::getTerminalWithMenu → NO_COVERAGE

290

1.1
Location : showMenu
Killed by : none
removed call to javax/swing/JMenu::setComponentOrientation → NO_COVERAGE

291

1.1
Location : showMenu
Killed by : none
negated conditional → NO_COVERAGE

310

1.1
Location : showMenu
Killed by : none
removed call to java/util/List::forEach → NO_COVERAGE

312

1.1
Location : lambda$showMenu$1
Killed by : none
removed call to com/jsql/view/swing/util/RadioItemPreventClose::setActionCommand → NO_COVERAGE

313

1.1
Location : lambda$showMenu$1
Killed by : none
removed call to com/jsql/view/swing/util/RadioItemPreventClose::setSelected → NO_COVERAGE

314

1.1
Location : lambda$showMenu$1
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

320

1.1
Location : lambda$showMenu$4
Killed by : none
removed call to java/lang/Thread::sleep → NO_COVERAGE

322

1.1
Location : lambda$showMenu$2
Killed by : none
replaced boolean return with false for com/jsql/view/swing/tab/TabResults::lambda$showMenu$2 → NO_COVERAGE

2.2
Location : lambda$showMenu$2
Killed by : none
replaced boolean return with true for com/jsql/view/swing/tab/TabResults::lambda$showMenu$2 → NO_COVERAGE

324

1.1
Location : lambda$showMenu$4
Killed by : none
removed call to java/util/Optional::ifPresent → NO_COVERAGE

333

1.1
Location : lambda$showMenu$4
Killed by : none
removed call to java/lang/Thread::interrupt → NO_COVERAGE

345

1.1
Location : showMenu
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

346

1.1
Location : showMenu
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

354

1.1
Location : actionPerformed
Killed by : none
negated conditional → NO_COVERAGE

355

1.1
Location : lambda$actionPerformed$0
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults::addTabExploitReverseShell → NO_COVERAGE

2.2
Location : actionPerformed
Killed by : none
removed call to javax/swing/SwingUtilities::invokeLater → NO_COVERAGE

357

1.1
Location : actionPerformed
Killed by : none
removed call to java/lang/Thread::start → NO_COVERAGE

358

1.1
Location : actionPerformed
Killed by : none
removed call to javax/swing/JPopupMenu::setVisible → NO_COVERAGE

364

1.1
Location : showMenu
Killed by : none
removed call to javax/swing/JMenu::setComponentOrientation → NO_COVERAGE

365

1.1
Location : showMenu
Killed by : none
negated conditional → NO_COVERAGE

381

1.1
Location : showMenu
Killed by : none
removed call to java/util/List::forEach → NO_COVERAGE

385

1.1
Location : processMouseEvent
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : processMouseEvent
Killed by : none
negated conditional → NO_COVERAGE

386

1.1
Location : processMouseEvent
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults$8::doClick → NO_COVERAGE

387

1.1
Location : processMouseEvent
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults$8::setArmed → NO_COVERAGE

389

1.1
Location : processMouseEvent
Killed by : none
removed call to javax/swing/JRadioButtonMenuItem::processMouseEvent → NO_COVERAGE

393

1.1
Location : lambda$showMenu$5
Killed by : none
removed call to com/jsql/view/swing/tab/TabResults$8::setSelected → NO_COVERAGE

394

1.1
Location : lambda$showMenu$5
Killed by : none
removed call to javax/swing/ButtonGroup::add → NO_COVERAGE

403

1.1
Location : showMenu
Killed by : none
replaced return value with null for com/jsql/view/swing/tab/TabResults::showMenu → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1