Пример #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") + ""));
      }
    }
  }