1 // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.kpdus.com/jad.html
3 // Decompiler options: packimports(3) fieldsfirst nonlb space
7 import Acme.Crypto.DesCipher;
10 import java.util.Arrays;
11 import javax.swing.JFrame;
12 import javax.swing.JOptionPane;
14 public class McsTcpConnection {
16 private DataInputStream socketInput;
17 private DataOutputStream socketOutput;
18 private boolean detectedPPP;
19 private int localPort;
20 private InetAddress localAddress;
22 private boolean connected;
23 private boolean encrypt;
24 public DesCipher cipher1;
25 public DesCipher cipher2;
26 private boolean debug;
28 public McsTcpConnection(String s, int i, boolean flag, String s1) {
40 connection = new Socket(s, i);
41 connection.setTcpNoDelay(true);
42 connection.setReceiveBufferSize(0x20000);
43 NetworkInterface networkinterface = NetworkInterface.getByInetAddress(connection.getLocalAddress());
44 if (networkinterface.getDisplayName().indexOf("PPP") != -1 || networkinterface.getDisplayName().indexOf("ppp") != -1)
46 localPort = connection.getLocalPort();
47 localAddress = connection.getLocalAddress();
48 java.io.InputStream inputstream = connection.getInputStream();
49 java.io.OutputStream outputstream = connection.getOutputStream();
50 System.out.println("Connected via socket: " + connection);
51 socketInput = new DataInputStream(new BufferedInputStream(inputstream));
52 socketOutput = new DataOutputStream(new BufferedOutputStream(outputstream));
55 byte abyte0[] = new byte[8];
57 34, 17, 31, 76, 113, 30, 91, 115
59 for (int j = 0; j < 8; j++) {
60 abyte0[j] = (byte)s1.toCharArray()[j];
61 abyte1[j] = (byte)(abyte1[j] ^ (byte)s1.toCharArray()[j]);
65 System.out.println("mcsTcpConnection: accessCode = " + s1);
66 cipher1 = new DesCipher(abyte0);
67 cipher2 = new DesCipher(abyte1);
70 catch (UnknownHostException unknownhostexception) {
72 System.err.println(unknownhostexception);
73 JOptionPane.showMessageDialog(new JFrame(), "Unknown host: " + s, "Remote Console Connection Error", 0);
75 catch (ConnectException connectexception) {
77 System.err.println(connectexception);
78 JOptionPane.showMessageDialog(new JFrame(), "Unable to connect to to " + s + ":" + i + ".", "Remote Console Connection Error", 0);
80 catch (IOException ioexception) {
82 System.err.println(ioexception);
83 JOptionPane.showMessageDialog(new JFrame(), "Connection to " + s + " lost.", "Remote Console Connection Error", 0);
87 boolean getDetectedPPP() {
91 DataInputStream getSocketInput() {
99 InetAddress getLocalAddress() {
103 public synchronized void sendMessage(int ai[], boolean flag) throws IOException {
105 int l = ai.length * 4;
106 byte abyte0[] = new byte[l];
108 for (int i = 0; i < ai.length; i++) {
110 abyte0[k] = (byte)((ai[i] & 0xff000000) >> 24);
111 abyte0[k + 1] = (byte)((ai[i] & 0xff0000) >> 16);
112 abyte0[k + 2] = (byte)((ai[i] & 0xff00) >> 8);
113 abyte0[k + 3] = (byte)(ai[i] & 0xff);
118 int j1 = (l + i1) / 8;
119 byte abyte1[] = new byte[j1 * 8];
120 System.arraycopy(abyte0, 0, abyte1, 0, l);
122 abyte1[abyte1.length - 1] = (byte)i1;
124 Arrays.fill(abyte1, abyte1.length - i1, abyte1.length - 2, (byte)0);
127 socketOutput.write(encrypt(abyte1, abyte1.length), 0, abyte1.length);
129 socketOutput.flush();
131 catch (IOException ioexception1) {
137 for (int j = 0; j < ai.length; j++)
138 socketOutput.writeInt(ai[j]);
141 socketOutput.flush();
143 catch (IOException ioexception) {
150 public synchronized void sendMessage(int ai[]) throws IOException {
151 sendMessage(ai, true);
154 public void close() {
157 if (connection != null) {
162 catch (IOException ioexception) {
163 System.err.println("Socket already closed.");
167 public boolean connected() {
171 public boolean videoEncrypted() {
175 public byte[] decrypt(byte abyte0[], int i, int j) {
176 for (int k = j; k < i + j; k += 8) {
177 cipher1.decrypt(abyte0, k, abyte0, k);
178 cipher2.encrypt(abyte0, k, abyte0, k);
179 cipher1.decrypt(abyte0, k, abyte0, k);
185 public byte[] encrypt(byte abyte0[], int i) {
186 for (int j = 0; j < i; j += 8) {
187 cipher1.encrypt(abyte0, j, abyte0, j);
188 cipher2.decrypt(abyte0, j, abyte0, j);
189 cipher1.encrypt(abyte0, j, abyte0, j);