⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection.java

📁 一个木马程序源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* *   File:  Connection.java * *   Version 1.02 v1a *   Copyright 1998, 1999 by Hush Communications Corporation, BWI */package hushcode;import java.applet.*;import java.net.*;import java.io.*;import java.awt.*;import java.util.*;import hushcode.HushSHA1;import hushcode.BlowfishCipher;import hushcode.HushApplet;import hushcode.Conversions;import hushcode.ElGamalCipher;import hushcode.HushRandom;import hushcode.ByteQueue;class Connection{ /************************************************************ *  The class variables and the methods that return them  ************************************************************//** * The following variables and methods deal with the user's folderlist.   * The folderlist is obtained by calling the method getFolders(). */  /* The number of folders used by the user   */  private int numberOfFolders;  int numberOfFolders() {return numberOfFolders;}      /* An array containing the names of the user's folders   * in the order they were received from the server   */  private String[] folderNameArray;  String folderName(int x) {return folderNameArray[x];}  /* An array containing the numbers of messages in each folder   * in the order they were received from the server   */  private int[] numberOfMessagesArray;  int numberOfMessages(int x)     {return numberOfMessagesArray[x];}  /* An array containing the numbers of unread messages in each folder   * in the order they were received from the server    */  private int[] numberOfUnreadMessagesArray;  int numberOfUnreadMessages(int x)     {return numberOfUnreadMessagesArray[x];}/** * The following variables and methods deal with the currently open  * folder.  A folder is opened by calling the method openFolder(String foldername) */  /* The name of the currently open folder   */  private String folderName;  String folderName() {return folderName;}   /* The number of messages in the currently open folder   */  private int numberOfMessages;  int numberOfMessages() {return numberOfMessages;}   /* The number of unread messages in the currently open folder   */  private int numberOfUnreadMessages;  int numberOfUnreadMessages() {return numberOfUnreadMessages;}    /* An array containing the messageIDs of messages in the currently    * open folder. messageIDs are assigned in the order messages are     * received from the server.  ?? Do we need this ??   */  private int[] messageIDArray;  int messageID(int x) {return messageIDArray[x];}    /* An array containing the exact sizes in octets of message in the   * currently open folder.  Ordered by messageID.   */  private int[] messageSizeArray;  int messageSize(int x) {return messageSizeArray[x];}  /* An array containing the subjects of the messages in the currently    * open folder.  Ordered by messageID.   */  private String[] subjectArray;  String subject(int x) {return subjectArray[x];}   /* An array containing the from addresses of the messages in the currently    * open folder.  Ordered by messageID.   */  private String[] fromArray;  String from(int x) {return fromArray[x];}  /* An array containing the to addresses of the messages in the currently    * open folder.  Ordered by messageID.   */  private String[] toArray;  String to(int x) {return toArray[x];}   /* An array containing the dates of the messages in the currently    * open folder.  Ordered by messageID.   */  private String[] dateArray;  String date(int x) {return dateArray[x];}   /* An array of type boolean indicating whether or not each message   * in the currently open folder has been read. Ordered by messageID.   */   private boolean[] readArray;  boolean read(int x) {return readArray[x];}  /** * The following variables and methods deal with the current   * message.  The current message is selected by calling * the method getMessage(String messageID). */   /* The messageID of the current message.   */   private int messageID;  int messageID() {return messageID;}  /* The date of the current message.   */   private String date;  String date() {return date;}  /* The subject field of the current message   */  private String subject;  String subject() {return subject;}  /* The to field of the current message   */  private String to;  String to() {return to;}  /* The from field of the current message   */  private String from;  String from() {return from;}  /* The reply-to field of the current message   */  private String replyTo;  String replyTo() {return replyTo;}    /* The cc field of the current message   */  private String cc;  String cc() {return cc;}   /* The bcc field of the current message   */  private String bcc;  String bcc() {return bcc;}   /* The full header of the current message   */  private String header;  String header() {return header;}  /* The body of the current message (unencrypted if the message was secure)   */  private String body;    String body() {return body;}  /* The body of the current message (encrypted if the message was secure)   */  private String actualbody;  String actualbody() {return actualbody;}  /*  If true the message has been rewritten   *  to the server, so the folderlist needs to be reloaded   */  private boolean wasRewritten;  boolean wasRewritten() {return wasRewritten;}  /*  This method wipes the entire message from memory   */  void wipeMessage()  {    date = null;    subject = null;    to = null;    from = null;    replyTo = null;    cc = null;    bcc = null;    header = null;    actualbody = null;    body = "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------"+           "-----------------------------------------------------------";    body = null;  }/** * The following variables and methods deal with the addressbook   * message.  The addressbook is obtained by calling the method * getAddresses(). */  /* The number of addresses in the address book   */  private int numberOfAddresses;  int numberOfAddresses() {return numberOfAddresses;}  /* An array of nicknames for the entries in the addressbook     */  private String[] nicknameArray;  String nickname(int x) {return nicknameArray[x];}  /* An array of fullnames for the entries in the addressbook   */  private String[] fullnameArray;  String fullname(int x) {return fullnameArray[x];}    /* An array of email addresses for the entries in the addressbook   */  private String[] addressesArray;  String addresses(int x) {return addressesArray[x];}  /* An array of public key fingerprints   */  private String[] fingerprintsArray;  String fingerprints(int x) {return fingerprintsArray[x];}/** * The following variables and methods deal with information   * about the users account and current session. */  /* The server's address   */  private String serverAddress;  /* The port the server listens for connections on   */  private int serverPort = 21;  /* The socket used to communicate with the server   */  private Socket s;     /* The service's domain.  Usually hushmail.com   */  private String domain;  String domain() {return domain;}  /* The username   */  private String username;     String username() {return username;}  /* The users email address   */  private String emailAddress;  String emailAddress() {return emailAddress;}    /* Half of a hash of the passPhrase;   */  private byte[] halfPassphraseHash;  void setPassphrase(String passedPassphrase)   {    byte[] passphraseHash = new HushSHA1().SHA1Hash(passedPassphrase);    halfPassphraseHash=new byte[passphraseHash.length/2];    System.arraycopy(passphraseHash,0,halfPassphraseHash,0,halfPassphraseHash.length);    passphraseHash = null;    passCipher = new BlowfishCipher();    passCipher.setKey(passedPassphrase.getBytes());    passedPassphrase = "                                            " +                       "                                            " +                       "                                            " +                       "                                            " +                       "                                            " ;    passedPassphrase=null;  }  /*  The user's public key fingerprint   */  private String fingerprint = "";  String fingerprint() {return fingerprint;}  /* The cipher with the key as user's passphrase   */  private BlowfishCipher passCipher;  void killPassCipher() {passCipher=null;}  /* The pseudo stream cipher for communication between applet and server   */  private BlowfishCipher blowfishPipe;   /* The sessionID.  64 bytes used as a unique identifier by the server to ensure   * a user cannot open multiple sessions, and that no one can break into the middle   * of a session.   */  private byte[] sessionIDBytes;  /* The user's encrypted public key   */  private byte[] encPrivKey;  /* A random number stream for encryption   */  private HushRandom randStream;   /* The applet using this instance of Connection   */  private HushApplet hushApplet;   /* A count of the tasks currently requiring use of the socket.   * Allows the socket to close when not needed.   */  private int socketRequests;  /* An output stream to the socket   */  BufferedOutputStream out;  /* An input stream from the socket.   */  BufferedInputStream eIn;  /* An input stream from a decrypted String which is used as a buffer   * to store data from eIn after it has been decrypted with blowfishPipe   */  DataInputStream in;  /* A boolean flag that indicates if the socket connection has been used yet.   * This ensures the session will only be initialized by method use() once   */  private boolean initialUse;  private String spaces="                               ";/************************************************************ *  Actions ************************************************************/    Connection(String passedUsername, String passedSessionID, String passedSessionKey, HushApplet a) //Constructor  {    /**     * This is the class constructor     */    username = passedUsername.toLowerCase();    /* Convert sessionID hex string to an array of bytes     */    sessionIDBytes = Conversions.hexStringToBytes(passedSessionID);      /* Convert sessionKey hex string to an array of bytes     */    byte[] sessionKeyBytes = Conversions.hexStringToBytes(passedSessionKey);    /* Instantiate cipher with sessionKey     */    blowfishPipe = new BlowfishCipher();    blowfishPipe.setKey(sessionKeyBytes);    hushApplet = a;    serverAddress = hushApplet.getCodeBase().getHost();    domain = "hushmail.com";    emailAddress = username+"@"+domain;    /* Since this session has just been started, no tasks are using the socket yet     */    socketRequests = 0;    /* The socket has not yet been used for communication     */    initialUse = true;    randStream = new HushRandom(new HushSHA1().SHA1Hash(Conversions.longToBytes(new Date().getTime())));  }    void getFolders() throws IOException  {     /**    *  Retrieves information on the folders stored on the server    *       numberOfFolders is set to the number of folders the     *           user has.    *       folderNameArray contains the names of the folders.    *        numberOfMessagesArray contains the numbers of messages    *          in each folder     *        numberOfUnreadMessagesArray contains the numbers of     *          unread messages in each folder     */        encryptAndWrite("LISTFOLDERS\n");    readAndDecrypt();    if (!in.readLine().equals("OK")) throw new IOException();    numberOfFolders = Integer.parseInt(in.readLine());    folderNameArray = new String[numberOfFolders];    numberOfMessagesArray = new int[numberOfFolders];    numberOfUnreadMessagesArray = new int[numberOfFolders];    for (int x=0;x<numberOfFolders;x++)         {      folderNameArray[x] = in.readLine();      numberOfMessagesArray[x] = Integer.parseInt(in.readLine());       numberOfUnreadMessagesArray[x]= Integer.parseInt(in.readLine());    }  }  void deleteFolder(String passedFolderName) throws IOException  {   /**    *  Indicates to the server that the folder with name    *  passedFolderName should be deleted    */     encryptAndWrite("DELETEFOLDER\n"+passedFolderName.trim()+"\n");    readAndDecrypt();    if (!in.readLine().equals("OK")) throw new IOException();   } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -