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(); } }
private Map readResponse() throws Exception { try { return (Map) (connection.execute(readCommand, new Object[] {session})); } catch (java.net.SocketException sex) { /* this definitely means we were disconnected */ return null; } catch (NullPointerException nex) { /* this probably means we were disconnected, which means it's a good time to quietly kill this thread */ return null; } }