View Javadoc
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.interaction;
12  
13  import com.jsql.view.interaction.InteractionCommand;
14  import com.jsql.view.swing.terminal.AbstractExploit;
15  import com.jsql.view.swing.util.MediatorHelper;
16  
17  import java.util.UUID;
18  
19  /**
20   * Append the result of a command in the terminal.
21   */
22  public class GetTerminalResult implements InteractionCommand {
23      
24      /**
25       * Unique identifier for the terminal. Used to output results of
26       * commands in the right shell tab (in case of multiple shell opened).
27       */
28      private final UUID terminalID;
29  
30      /**
31       * The result of a command executed in shell.
32       */
33      private final String result;
34  
35      /**
36       * @param interactionParams The unique identifier of the terminal and the command's result to display
37       */
38      public GetTerminalResult(Object[] interactionParams) {
39          this.terminalID = (UUID) interactionParams[0];
40          this.result = (String) interactionParams[1];
41      }
42  
43      @Override
44      public void execute() {
45          AbstractExploit terminal = MediatorHelper.frame().getMapUuidShell().get(this.terminalID);
46          if (terminal != null) {  // null on reverse shell connection
47              terminal.append(this.result);
48              terminal.append("\n");
49              terminal.reset();
50          }
51      }
52  }