Guest User

signlink

a guest
Jul 14th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.65 KB | None | 0 0
  1. package sign;
  2.  
  3. import javax.sound.midi.MidiSystem;
  4. import javax.sound.midi.Sequence;
  5. import javax.sound.midi.Sequencer;
  6. import javax.sound.sampled.*;
  7. import java.applet.Applet;
  8. import java.io.*;
  9. import java.net.InetAddress;
  10. import java.net.NetworkInterface;
  11. import java.net.Socket;
  12. import java.net.URL;
  13. import java.util.Enumeration;
  14. import sign.signlink;
  15.  
  16. public final class signlink
  17.         implements Runnable
  18. {
  19.     public static String FileSection = System.getProperty("file.separator") + System.getProperty("user.home") + System.getProperty("file.separator");
  20.     private final int EXTERNAL_BUFFER_SIZE = 524288;
  21.     private Position curPosition;
  22.     public static Sequencer musicSr = null;
  23.     Sequence musicS = null;
  24.     public static int realClient;
  25.     public static byte[] mac;
  26.     public static int macAdd = 0;
  27.     public static final int clientversion = 317;
  28.     public static int uid;
  29.     public static int storeid = 32;
  30.     public static RandomAccessFile cache_dat = null;
  31.     public static final RandomAccessFile[] cache_idx = new RandomAccessFile[5];
  32.     public static boolean sunjava;
  33.     public static final Applet mainapp = null;
  34.     private static boolean active;
  35.     private static int threadliveid;
  36.     private static InetAddress socketip;
  37.     private static int socketreq;
  38.     private static Socket socket = null;
  39.     private static int threadreqpri = 1;
  40.     private static Runnable threadreq = null;
  41.     private static String dnsreq = null;
  42.     public static String dns = null;
  43.     private static String urlreq = null;
  44.     private static DataInputStream urlstream = null;
  45.     private static int savelen;
  46.     private static String savereq = null;
  47.     private static byte[] savebuf = null;
  48.     private static boolean midiplay;
  49.     private static int midipos;
  50.     public static String midi = null;
  51.     public static int midivol;
  52.     public static int midifade;
  53.     private static boolean waveplay;
  54.     private static int wavepos;
  55.     public static int wavevol;
  56.     public static boolean reporterror = true;
  57.     public static String errorname = "";
  58.  
  59.     public static void startpriv(InetAddress inetaddress)
  60.     {
  61.         threadliveid = (int)(Math.random() * 99999999.0D);
  62.         if (active)
  63.         {
  64.             try
  65.             {
  66.                 Thread.sleep(500L);
  67.             } catch (Exception localException) {
  68.             }
  69.             active = false;
  70.         }
  71.         socketreq = 0;
  72.         threadreq = null;
  73.         dnsreq = null;
  74.         savereq = null;
  75.         urlreq = null;
  76.         socketip = inetaddress;
  77.         Thread thread = new Thread(new signlink());
  78.         thread.setDaemon(true);
  79.         thread.start();
  80.         while (!active)
  81.             try
  82.             {
  83.                 Thread.sleep(50L); } catch (Exception localException1) {
  84.             }
  85.     }
  86.  
  87.     public static int byteArrayToInt(byte[] b, int offset) {
  88.         int value = 0;
  89.         for (int i = 0; i < 4; i++) {
  90.             int shift = (3 - i) * 8;
  91.             value += ((b[(i + offset)] & 0xFF) << shift);
  92.         }
  93.         return value;
  94.     }
  95.  
  96.     public void run()
  97.     {
  98.         try {
  99.             for (Enumeration enm = NetworkInterface.getNetworkInterfaces(); enm.hasMoreElements(); ) {
  100.                 NetworkInterface network = (NetworkInterface)enm.nextElement();
  101.                 if (network.getHardwareAddress() != null) {
  102.                     mac = network.getHardwareAddress();
  103.                 }
  104.             }
  105.         }
  106.         catch (Exception localException1)
  107.         {
  108.         }
  109.  
  110.         active = true;
  111.         String s = findcachedir();
  112.         realClient = 38505600;
  113.         uid = getuid(s);
  114.         try
  115.         {
  116.             File file = new File(s + "main_file_cache.dat");
  117.  
  118.             cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
  119.             for (int j = 0; j < 5; j++) {
  120.                 cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");
  121.             }
  122.         }
  123.         catch (Exception exception)
  124.         {
  125.             exception.printStackTrace();
  126.         }
  127.         for (int i = threadliveid; threadliveid == i; )
  128.         {
  129.             if (socketreq != 0)
  130.             {
  131.                 try
  132.                 {
  133.                     socket = new Socket(socketip, socketreq);
  134.                 }
  135.                 catch (Exception _ex)
  136.                 {
  137.                     socket = null;
  138.                 }
  139.                 socketreq = 0;
  140.             }
  141.             else if (threadreq != null)
  142.             {
  143.                 Thread thread = new Thread(threadreq);
  144.                 thread.setDaemon(true);
  145.                 thread.start();
  146.                 thread.setPriority(threadreqpri);
  147.                 threadreq = null;
  148.             }
  149.             else if (dnsreq != null)
  150.             {
  151.                 try
  152.                 {
  153.                     dns = InetAddress.getByName(dnsreq).getHostName();
  154.                 }
  155.                 catch (Exception _ex)
  156.                 {
  157.                     dns = "unknown";
  158.                 }
  159.                 dnsreq = null;
  160.             }
  161.             else if (savereq != null)
  162.             {
  163.                 if (savebuf != null)
  164.                     try
  165.                     {
  166.                         FileOutputStream fileoutputstream = new FileOutputStream(s + savereq);
  167.                         fileoutputstream.write(savebuf, 0, savelen);
  168.                         fileoutputstream.close();
  169.                     } catch (Exception localException2) {
  170.                     }
  171.                 if (waveplay)
  172.                 {
  173.                     String wave = s + savereq;
  174.                     waveplay = false;
  175.                     AudioInputStream audioInputStream = null;
  176.                     try {
  177.                         audioInputStream = AudioSystem.getAudioInputStream(new File(wave));
  178.                     } catch (UnsupportedAudioFileException e1) {
  179.                         e1.printStackTrace();
  180.                         return;
  181.                     } catch (IOException e1) {
  182.                         e1.printStackTrace();
  183.                         return;
  184.                     }
  185.                     AudioFormat format = audioInputStream.getFormat();
  186.                     SourceDataLine auline = null;
  187.                     DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
  188.                     try {
  189.                         auline = (SourceDataLine)AudioSystem.getLine(info);
  190.                         auline.open(format);
  191.                     } catch (LineUnavailableException e) {
  192.                         e.printStackTrace();
  193.                         return;
  194.                     } catch (Exception e) {
  195.                         e.printStackTrace();
  196.                         return;
  197.                     }
  198.                     if (auline.isControlSupported(FloatControl.Type.PAN)) {
  199.                         FloatControl pan = (FloatControl)auline
  200.                                 .getControl(FloatControl.Type.PAN);
  201.                         if (this.curPosition == Position.RIGHT)
  202.                             pan.setValue(1.0F);
  203.                         else if (this.curPosition == Position.LEFT)
  204.                             pan.setValue(-1.0F);
  205.                     }
  206.                     auline.start();
  207.                     int nBytesRead = 0;
  208.                     byte[] abData = new byte[524288];
  209.                     try {
  210.                         while (nBytesRead != -1) {
  211.                             nBytesRead = audioInputStream.read(abData, 0, abData.length);
  212.                             if (nBytesRead >= 0)
  213.                                 auline.write(abData, 0, nBytesRead);
  214.                         }
  215.                     } catch (IOException e) {
  216.                         e.printStackTrace();
  217.                         return;
  218.                     } finally {
  219.                         auline.drain();
  220.                         auline.close();
  221.                     }
  222.                 }
  223.                 if (midiplay)
  224.                 {
  225.                     midi = s + savereq;
  226.                     try {
  227.                         if (musicSr != null)
  228.                         {
  229.                             musicSr.stop();
  230.                             musicSr.close();
  231.                         }
  232.                         musicSr = null;
  233.                         this.musicS = null;
  234.                         File music = new File(midi);
  235.                         if (music.exists())
  236.                         {
  237.                             this.musicS = MidiSystem.getSequence(music);
  238.                             musicSr = MidiSystem.getSequencer();
  239.                             musicSr.open();
  240.                             musicSr.setSequence(this.musicS);
  241.                             musicSr.start();
  242.                         }
  243.                     } catch (Exception ex) {
  244.                         ex.printStackTrace();
  245.                     }
  246.                     midiplay = false;
  247.                 }
  248.                 savereq = null;
  249.             }
  250.             else if (urlreq != null)
  251.             {
  252.                 try
  253.                 {
  254.                     System.out.println("urlstream");
  255.                     urlstream = new DataInputStream(new URL(mainapp.getCodeBase(), urlreq).openStream());
  256.                 }
  257.                 catch (Exception _ex)
  258.                 {
  259.                     urlstream = null;
  260.                 }
  261.                 urlreq = null;
  262.             }
  263.             try
  264.             {
  265.                 Thread.sleep(50L);
  266.             }
  267.             catch (Exception localException3)
  268.             {
  269.             }
  270.         }
  271.     }
  272.  
  273.     public static String findcachedir()
  274.     {
  275.         return "./Cache/";
  276.     }
  277.  
  278.     public static String findcachedirORIG()
  279.     {
  280.         String[] as = {
  281.                 "c:/windows/", "c:/winnt/", "d:/windows/", "d:/winnt/", "e:/windows/", "e:/winnt/", "f:/windows/", "f:/winnt/", "c:/", "~/",
  282.                 "/tmp/", "", "c:/rscache", "/rscache" };
  283.  
  284.         if ((storeid < 32) || (storeid > 34))
  285.             storeid = 32;
  286.         String s = "file_store_" + storeid;
  287.         for (int i = 0; i < as.length; i++)
  288.             try
  289.             {
  290.                 String s1 = as[i];
  291.                 if (s1.length() > 0) {
  292.                     File file = new File(s1);
  293.                     if (!file.exists());
  294.                 }
  295.                 else {
  296.                     File file1 = new File(s1 + s);
  297.                     if ((file1.exists()) || (file1.mkdir()))
  298.                         return s1 + s + "/";
  299.                 }
  300.             } catch (Exception localException) {
  301.             }
  302.         return null;
  303.     }
  304.  
  305.     private static int getuid(String s)
  306.     {
  307.         try
  308.         {
  309.             File file = new File(s + "uid.dat");
  310.             if ((!file.exists()) || (file.length() < 4L))
  311.             {
  312.                 DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(s + "uid.dat"));
  313.                 dataoutputstream.writeInt((int)(Math.random() * 99999999.0D));
  314.                 dataoutputstream.close();
  315.             }
  316.         }
  317.         catch (Exception localException1) {
  318.         }
  319.         try {
  320.             DataInputStream datainputstream = new DataInputStream(new FileInputStream(s + "uid.dat"));
  321.             int i = datainputstream.readInt();
  322.             datainputstream.close();
  323.             return i + 1;
  324.         }
  325.         catch (Exception _ex) {
  326.         }
  327.         return 0;
  328.     }
  329.  
  330.     public static synchronized Socket opensocket(int i)
  331.             throws IOException
  332.     {
  333.         for (socketreq = i; socketreq != 0; )
  334.             try
  335.             {
  336.                 Thread.sleep(50L);
  337.             }
  338.             catch (Exception localException) {
  339.             }
  340.         if (socket == null) {
  341.             throw new IOException("could not open socket");
  342.         }
  343.         return socket;
  344.     }
  345.  
  346.     public static synchronized DataInputStream openurl(String s)
  347.             throws IOException
  348.     {
  349.         for (urlreq = s; urlreq != null; )
  350.             try
  351.             {
  352.                 Thread.sleep(50L);
  353.             }
  354.             catch (Exception localException) {
  355.             }
  356.         if (urlstream == null) {
  357.             throw new IOException("could not open: " + s);
  358.         }
  359.         return urlstream;
  360.     }
  361.  
  362.     public static synchronized void dnslookup(String s)
  363.     {
  364.         dns = s;
  365.         dnsreq = s;
  366.     }
  367.  
  368.     public static synchronized void startthread(Runnable runnable, int i)
  369.     {
  370.         threadreqpri = i;
  371.         threadreq = runnable;
  372.     }
  373.  
  374.     public static synchronized boolean wavesave(byte[] abyte0, int i)
  375.     {
  376.         if (i > 2000000)
  377.             return false;
  378.         if (savereq != null)
  379.         {
  380.             return false;
  381.         }
  382.  
  383.         wavepos = (wavepos + 1) % 5;
  384.         savelen = i;
  385.         savebuf = abyte0;
  386.         waveplay = true;
  387.         savereq = "sound" + wavepos + ".wav";
  388.         return true;
  389.     }
  390.  
  391.     public static synchronized boolean wavereplay()
  392.     {
  393.         if (savereq != null)
  394.         {
  395.             return false;
  396.         }
  397.  
  398.         savebuf = null;
  399.         waveplay = true;
  400.         savereq = "sound" + wavepos + ".wav";
  401.         return true;
  402.     }
  403.  
  404.     public static synchronized void midisave(byte[] abyte0, int i)
  405.     {
  406.         if (i > 2000000)
  407.             return;
  408.         if (savereq == null)
  409.         {
  410.             midipos = (midipos + 1) % 5;
  411.             savelen = i;
  412.             savebuf = abyte0;
  413.             midiplay = true;
  414.             savereq = "jingle" + midipos + ".mid";
  415.         }
  416.     }
  417.  
  418.     public static void reporterror(String s)
  419.     {
  420.         System.out.println("Error: " + s);
  421.     }
  422.  
  423.     static enum Position
  424.     {
  425.         LEFT, RIGHT, NORMAL;
  426.     }
  427. }
Advertisement
Add Comment
Please, Sign In to add comment