Package ass3.brute

Examples of ass3.brute.Cracker


import ass3.program.core.Chatter;

public class Console {

  public static void main(String[] args) {
    Chatter chatter = new Chatter();
  }
View Full Code Here


  public MainFrame() {
    super();
    // Data Init
    chatFrames = new HashMap<String, ChatFrame>();
    chatter = new Chatter();
    chatter.addListener(this);

    // UI Init
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(new Dimension(300, 200));
View Full Code Here

  }

  public ContextKey getContextKey() {
    try {
      if (null == ck) {
        ck = new ContextKey(
            InetAddress.getLocalHost().getHostAddress(), this.ip);
      }
      return ck;
    } catch (UnknownHostException e) {
      throw new RuntimeException(e);
View Full Code Here

    }
    clearLock(clazz);
  }

  public void sendText(String message) {
    ContextKey ck = getContextKey();
    switch (clientState.getCurrentState()) {
    case INIT:
      // Allow the user to indicate bit-length
      send(new PublicKeyRequest(ck.getA(), ck.getB(),
          ConfigLoader.loadInt("key", "ELGAMAL_BITLENGTH")));
      waitForResponse(PublicKeyResponse.class);
      sendText(message);
      break;
    case PUBLIC_KEY_RECEIVED:
      // Allow user to indicate shared key
      send(new ExchSharedKeyRequest(ck.getA(), ck.getB(), ConfigLoader
          .load("key", "AES_KEY").getBytes()));
      waitForResponse(ExchSharedKeyResponse.class);
      sendText(message);
      break;
    case SHARED_KEY_EXCHANGED:
      send(new SendTextRequest(ck.getA(), ck.getB(), message));
      waitForResponse(SendTextResponse.class);
      // Check self state to determine whether need to resend
      if (!(clientState.getCurrentState() == CState.SHARED_KEY_EXCHANGED)) {
        // Error encountered, Resend
        sendText(message);
View Full Code Here

    super();
  }

  public Message(String from, String to) {
    super();
    this.ck = new ContextKey(from, to);
  }
View Full Code Here

      waitForResponse(PublicKeyResponse.class);
      sendText(message);
      break;
    case PUBLIC_KEY_RECEIVED:
      // Allow user to indicate shared key
      send(new ExchSharedKeyRequest(ck.getA(), ck.getB(), ConfigLoader
          .load("key", "AES_KEY").getBytes()));
      waitForResponse(ExchSharedKeyResponse.class);
      sendText(message);
      break;
    case SHARED_KEY_EXCHANGED:
View Full Code Here

    parent.getChatter().send(target, text);
  }

  @Override
  public void messageReceived(MessageEvent event) {
    Message msg = event.getContent();
    if (msg instanceof SendTextRequest && msg.getFrom().equals(this.target)) {
      // Receive a message
      SendTextRequest str = (SendTextRequest) msg;
      final String text = str.getText();
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
View Full Code Here

   * This method will be invoked by multiple ChatClient threads. Thus should
   * be synchronized
   */
  @Override
  public synchronized void messageReceived(MessageEvent event) {
    Message message = event.getContent();
    if (message instanceof SendTextRequest) {
      SendTextRequest st = (SendTextRequest) message;
      String target = st.getFrom();
      if (!chatFrames.containsKey(target)) {
        new ChatFrame(target, this);
View Full Code Here

                && socket.getInputStream().available() == 0) {
              Thread.sleep(500);
            }
            if (socket.isClosed())
              break;
            Message message = (Message) new ObjectInputStream(
                socket.getInputStream()).readObject();
            // Update the IP info carried by the message
            if (message instanceof Request) {
              message.getCk()
                  .setA(ChatClient.getRemoteIp(socket));
            }
            if (message instanceof Response) {
              // Do nothing cause reponse get info from request
            }
            if (logger.isDebugEnabled()) {
              logger.debug(MessageFormat.format(
                  "Received message {0}:{1}", message
                      .getClass().getName(), message));
            }
            listener.messageReceived(new ServerMessageEvent(
                ChatServer.this, message));
          } catch (SocketException e) {
View Full Code Here

  public void sendText(String message) {
    ContextKey ck = getContextKey();
    switch (clientState.getCurrentState()) {
    case INIT:
      // Allow the user to indicate bit-length
      send(new PublicKeyRequest(ck.getA(), ck.getB(),
          ConfigLoader.loadInt("key", "ELGAMAL_BITLENGTH")));
      waitForResponse(PublicKeyResponse.class);
      sendText(message);
      break;
    case PUBLIC_KEY_RECEIVED:
View Full Code Here

TOP

Related Classes of ass3.brute.Cracker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.