| 1 | package com.jsql.view.swing.panel.preferences; | |
| 2 | ||
| 3 | import com.jsql.util.LogLevelUtil; | |
| 4 | import com.jsql.util.StringUtil; | |
| 5 | import com.jsql.view.swing.text.SyntaxTextArea; | |
| 6 | import com.jsql.view.swing.text.listener.DocumentListenerEditing; | |
| 7 | import com.jsql.view.swing.util.MediatorHelper; | |
| 8 | import com.jsql.view.swing.util.UiUtil; | |
| 9 | import org.fife.ui.rsyntaxtextarea.SyntaxConstants; | |
| 10 | import org.fife.ui.rtextarea.RTextScrollPane; | |
| 11 | import org.yaml.snakeyaml.parser.ParserException; | |
| 12 | import org.yaml.snakeyaml.scanner.ScannerException; | |
| 13 | ||
| 14 | import javax.swing.*; | |
| 15 | ||
| 16 | public class PanelExploit extends JPanel { | |
| 17 | ||
| 18 | private static final SyntaxTextArea textareaRevshells = new SyntaxTextArea("Reverse shell list"); | |
| 19 | private static final String TITLE = "Reverse shell server (connector)"; | |
| 20 | private static final String PATTERN = "<html><b>%s</b></html>"; | |
| 21 | ||
| 22 | public PanelExploit() { | |
| 23 |
1
1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setSyntaxEditingStyle → NO_COVERAGE |
PanelExploit.textareaRevshells.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_YAML); |
| 24 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelExploit::applyTheme → NO_COVERAGE |
PanelExploit.applyTheme(); |
| 25 | ||
| 26 | var preferencesUtil = MediatorHelper.model().getMediatorUtils().getPreferencesUtil(); | |
| 27 | var labelOrigin = new JLabel(String.format(PanelExploit.PATTERN, PanelExploit.TITLE)); | |
| 28 |
1
1. <init> : removed call to javax/swing/text/Document::addDocumentListener → NO_COVERAGE |
PanelExploit.textareaRevshells.getDocument().addDocumentListener(new DocumentListenerEditing() { |
| 29 | @Override | |
| 30 | public void process() { | |
| 31 | try { | |
| 32 |
1
1. process : removed call to com/jsql/util/PreferencesUtil::parseReverseCommands → NO_COVERAGE |
preferencesUtil.parseReverseCommands(PanelExploit.textareaRevshells.getText()); |
| 33 |
1
1. process : removed call to javax/swing/JLabel::setText → NO_COVERAGE |
labelOrigin.setText(String.format(PanelExploit.PATTERN, PanelExploit.TITLE)); |
| 34 | } catch ( | |
| 35 | ParserException | ScannerException // yml | |
| 36 | | NullPointerException // map missing key | |
| 37 | | ClassCastException // incorrect model | |
| 38 | e | |
| 39 | ) { | |
| 40 |
1
1. process : removed call to javax/swing/JLabel::setText → NO_COVERAGE |
labelOrigin.setText(String.format(PanelExploit.PATTERN, StringUtil.formatReport( |
| 41 | LogLevelUtil.COLOR_RED, | |
| 42 | PanelExploit.TITLE | |
| 43 | + ", YAML must follow the name and command template :<br>" | |
| 44 | // Fix #96073: NullPointerException on e.getMessage().replace() | |
| 45 | + e.toString().replace("\n", "<br>") // toString to prevent NPE (jdk11) | |
| 46 | ))); | |
| 47 | } | |
| 48 | } | |
| 49 | }); | |
| 50 |
1
1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setText → NO_COVERAGE |
PanelExploit.textareaRevshells.setText( |
| 51 | preferencesUtil.getCommandsReverseYaml().replace("\r\n", "\n") // required to prevent \ra\n issue | |
| 52 | ); | |
| 53 |
1
1. <init> : removed call to com/jsql/view/swing/text/SyntaxTextArea::setCaretPosition → NO_COVERAGE |
PanelExploit.textareaRevshells.setCaretPosition(0); |
| 54 | ||
| 55 | var scrollPane = new RTextScrollPane(PanelExploit.textareaRevshells); | |
| 56 | ||
| 57 |
1
1. <init> : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE |
labelOrigin.setBorder(PanelGeneral.MARGIN); |
| 58 | ||
| 59 | var groupLayout = new GroupLayout(this); | |
| 60 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelExploit::setLayout → NO_COVERAGE |
this.setLayout(groupLayout); |
| 61 | ||
| 62 |
1
1. <init> : removed call to javax/swing/GroupLayout::setHorizontalGroup → NO_COVERAGE |
groupLayout.setHorizontalGroup( |
| 63 | groupLayout | |
| 64 | .createSequentialGroup() | |
| 65 | .addGroup( | |
| 66 | groupLayout | |
| 67 | .createParallelGroup(GroupLayout.Alignment.LEADING) | |
| 68 | .addComponent(labelOrigin) | |
| 69 | .addComponent(scrollPane) | |
| 70 | ) | |
| 71 | ); | |
| 72 | ||
| 73 |
1
1. <init> : removed call to javax/swing/GroupLayout::setVerticalGroup → NO_COVERAGE |
groupLayout.setVerticalGroup( |
| 74 | groupLayout | |
| 75 | .createSequentialGroup() | |
| 76 | .addGroup( | |
| 77 | groupLayout | |
| 78 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 79 | .addComponent(labelOrigin) | |
| 80 | ) | |
| 81 | .addGroup( | |
| 82 | groupLayout | |
| 83 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
| 84 | .addComponent(scrollPane) | |
| 85 | ) | |
| 86 | ); | |
| 87 | } | |
| 88 | ||
| 89 | public static void applyTheme() { | |
| 90 |
1
1. applyTheme : removed call to com/jsql/view/swing/util/UiUtil::applySyntaxTheme → NO_COVERAGE |
UiUtil.applySyntaxTheme(PanelExploit.textareaRevshells); |
| 91 | } | |
| 92 | } | |
Mutations | ||
| 23 |
1.1 |
|
| 24 |
1.1 |
|
| 28 |
1.1 |
|
| 32 |
1.1 |
|
| 33 |
1.1 |
|
| 40 |
1.1 |
|
| 50 |
1.1 |
|
| 53 |
1.1 |
|
| 57 |
1.1 |
|
| 60 |
1.1 |
|
| 62 |
1.1 |
|
| 73 |
1.1 |
|
| 90 |
1.1 |