예제 #1
0
  public void _sendString(String text) {
    if (writeCommand == null) return;

    /* intercept sessions -i and deliver it to a listener within armitage */
    if (sessionListener != null) {
      Matcher m = interact.matcher(text);
      if (m.matches()) {
        sessionListener.actionPerformed(new ActionEvent(this, 0, m.group(1)));
        return;
      }
    }

    Map read = null;

    try {
      synchronized (this) {
        if (window != null && echo) {
          window.append(window.getPromptText() + text);
        }
      }

      if ("armitage.push".equals(writeCommand)) {
        read = (Map) connection.execute(writeCommand, new Object[] {session, text});
      } else {
        connection.execute(writeCommand, new Object[] {session, text});
        read = readResponse();
      }
      processRead(read);

      fireSessionWroteEvent(text);
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
예제 #2
0
  private void processRead(Map read) throws Exception {
    if (!"".equals(read.get("data"))) {
      String text = read.get("data") + "";

      synchronized (this) {
        if (window != null) window.append(text);
      }
      fireSessionReadEvent(text);
      lastRead = System.currentTimeMillis();
    }

    synchronized (this) {
      if (!"".equals(read.get("prompt")) && window != null) {
        window.updatePrompt(cleanText(read.get("prompt") + ""));
      }
    }
  }
예제 #3
0
  /* call this if the console client is referencing a metasploit console with tab completion */
  public void setMetasploitConsole() {
    window.addActionForKey(
        "ctrl pressed Z",
        new AbstractAction() {
          public void actionPerformed(ActionEvent ev) {
            sendString("background\n");
          }
        });

    new TabCompletion(window, connection, session, "console.tabs");
  }
예제 #4
0
 protected void setupListener() {
   synchronized (this) {
     if (window != null) {
       window
           .getInput()
           .addActionListener(
               new ActionListener() {
                 public void actionPerformed(ActionEvent ev) {
                   final String text = window.getInput().getText() + "\n";
                   window.getInput().setText("");
                   sendString(text);
                 }
               });
     }
   }
 }