Android Open Source - CipherChat Debug Crypto Client






From Project

Back to project page CipherChat.

License

The source code is released under:

MIT License

If you think the Android project CipherChat listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.desperate.debug;
/*from  ww w .  j  a v  a  2s  . c o  m*/
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.security.KeyStore;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManagerFactory;

public class DebugCryptoClient {
  final static String serverIP = "192.168.1.64";
  final static int portNumber = 1337;

  public static void main(String[] args) {
    try {
      // Setup truststore
      KeyStore trustStore = KeyStore.getInstance("JKS");
      TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
      InputStream trustStoreStream = new FileInputStream("contribot.jks");
      trustStore.load(trustStoreStream, "123456".toCharArray());
      trustManagerFactory.init(trustStore);

      System.out.println("Loaded truststore.");

      // Setup keystore, same as truststore
      KeyStore keyStore = KeyStore.getInstance("JKS");
      KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
      InputStream keyStoreStream = new FileInputStream("contribot.jks");
      keyStore.load(keyStoreStream, "123456".toCharArray());
      keyManagerFactory.init(keyStore, "123456".toCharArray());

      System.out.println("Loaded keystore.");

      // Setup the SSL context to use the truststore and keystore
      SSLContext ssl_ctx = SSLContext.getInstance("TLS");
      ssl_ctx.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), null);

      System.out.println("Setup SSL context");

      // Create socket factory
      SSLSocketFactory socketFactory = (SSLSocketFactory) ssl_ctx.getSocketFactory();

      System.out.println("Got SSL socket factory");

      // Finally create socket, which is in MainActivity class
      SSLSocket sslSocket = (SSLSocket) socketFactory.createSocket(serverIP, portNumber);
      // ((SSLSocket) sslSocket).startHandshake();

      System.out.println("Connected SSL socket");

      // This is just a prototype
      PrintWriter out = new PrintWriter(sslSocket.getOutputStream(), true);

      // Send through socket
      out.println("I'm pretending to be the Android App.");

      out.println("Another message from the Android App.");

      out.println("bye");

      sslSocket.close();

      System.out.println("Sent messages, Exited cleanly");
      System.exit(0);

    } catch (Exception e) {
      e.printStackTrace();
    }

  }
}




Java Source Code List

com.desperate.AdminConsole.java
com.desperate.ClientHandler.java
com.desperate.CryptoServer.java
com.desperate.UserDatabase.java
com.desperate.User.java
com.desperate.common.Message.java
com.desperate.common.NoncePacket.java
com.desperate.common.SessionKeyRequestInfo.java
com.desperate.common.TestCipherSerializable.java
com.desperate.common.Utilities.java
com.desperate.common.messages.ChatMessage.java
com.desperate.common.messages.IPMessage.java
com.desperate.common.messages.LoginMessage.java
com.desperate.common.messages.LogoutMessage.java
com.desperate.common.messages.RegisterMessage.java
com.desperate.common.messages.SessionKeyRequestMessage.java
com.desperate.common.messages.StartChatMessage.java
com.desperate.common.messages.UserListMessage.java
com.desperate.common.replies.CheckSessionMessage.java
com.desperate.common.replies.IPReplyMessage.java
com.desperate.common.replies.LoginReplyMessage.java
com.desperate.common.replies.LogoutReplyMessage.java
com.desperate.common.replies.NeedhamSchroederSuccessReply.java
com.desperate.common.replies.RegisterReplyMessage.java
com.desperate.common.replies.ReplyMessage.java
com.desperate.common.replies.SessionKeyReplyMessage.java
com.desperate.common.replies.StartChatReply.java
com.desperate.common.replies.UserListReplyMessage.java
com.desperate.debug.DebugClient.java
com.desperate.debug.DebugCryptoClient.java
com.desperate.debug.PlainServer.java
com.ist.cipherchat.gui.ChatActivity.java
com.ist.cipherchat.gui.ChooseServerActivity.java
com.ist.cipherchat.gui.Contacts.java
com.ist.cipherchat.gui.Origin.java
com.ist.cipherchat.networking.ChatActivityRunnable.java
com.ist.cipherchat.networking.ChatInRunnable.java
com.ist.cipherchat.networking.ChatOutHandler.java
com.ist.cipherchat.networking.Core.java
com.ist.cipherchat.networking.Globals.java
com.ist.cipherchat.networking.OutputSocketHandler.java
com.ist.cipherchat.networking.PhoneServerSocketHandler.java
com.ist.cipherchat.networking.ThreadComm.java