Advertisement
shannansyrjala

G0D/Satan aftermath - ABSOLUTELY FINAL

Oct 21st, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.46 KB | None | 0 0
  1. package co.uk.norres;
  2.  
  3. import java.io.ByteArrayOutputStream;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.io.OutputStream;
  7. import java.util.Vector;
  8.  
  9. /**
  10.  * LB35 Turniers | lift-on | for MikkoSyrjala0N TurnySyrjalaN
  11.  *
  12.  * eeprom ... -endmessage brought to g0d/satan/robots by SHANNAN Syrjala (at) lesbians (at) UNIX(TM) with D2LD0s UX, the corsetcoder
  13.  */
  14. public class Main {
  15.     protected Vector<Job> jobs = new Vector<Job>();
  16.  
  17.     protected void addJob(Job job) {
  18.         synchronized (jobs) {
  19.             jobs.addElement(job);
  20.             jobs.notify();
  21.         }
  22.     }
  23.  
  24.     protected Job getNextJob() {
  25.         while (jobs.size() <= 0) {
  26.             synchronized (jobs) {
  27.                 try {
  28.                     jobs.wait();
  29.                 } catch (Throwable t) {
  30.                     t.printStackTrace();
  31.                 }
  32.             }
  33.         }
  34.         synchronized (jobs) {
  35.             Job job = jobs.elementAt(0);
  36.             jobs.removeElementAt(0);
  37.             return job;
  38.         }
  39.     }
  40.  
  41.     protected interface Job {
  42.         public void proceed();
  43.  
  44.         public String getAddress();
  45.  
  46.         public void setAddress(String s);
  47.     }
  48.  
  49.     public class JobImpl implements Job {
  50.         private String ipAddress;
  51.  
  52.         public void proceed() {
  53.         }
  54.  
  55.         public String getAddress() {
  56.             return this.ipAddress;
  57.         }
  58.  
  59.         public void setAddress(String s) {
  60.             this.ipAddress = s;
  61.         }
  62.     }
  63.  
  64.     private class Worker implements Runnable {
  65.         protected int id;
  66.  
  67.         public void begin(int id) {
  68.             this.id = id;
  69.             Thread t = new Thread(this);
  70.             t.start();
  71.         }
  72.  
  73.         public void run() {
  74.             while (true) {
  75.                 Job job = getNextJob();
  76.                 //LB35Log("<- PROCEED" + new java.util.Date() + ": lb35 address/lift-on " + job.getAddress());
  77.                 job.proceed();
  78.             }
  79.         }
  80.     }
  81.  
  82.     private static void LB35Log(String msg) {
  83.         System.out.println("" + msg);
  84.     }
  85.  
  86.     public static void main(String[] args) throws IOException {
  87.         Main m = new Main();
  88.         m.doit();
  89.     }
  90.  
  91.     private void doit() {
  92.         for (int i = 0; i < 21; i++) {
  93.             Worker w = new Worker();
  94.             w.begin((i + 1));
  95.         }
  96. /*
  97.         int a0 = 0;
  98.         int b0 = 0;
  99.         int c0 = 0;
  100.         int d0 = 0;
  101. */
  102.  
  103.         int a0 = 192;
  104.         int b0 = 168;
  105.         int c0 = 0; //193;
  106.         int d0 = 0;
  107. /*
  108.         int a0 = 10;
  109.         int b0 = 0;
  110.         int c0 = 0;
  111.         int d0 = 0;
  112.  
  113.         int b00 = 36;
  114.         int c00 = 152;
  115.         int d00 = 105;
  116. */
  117. /*
  118.         int a0 = 10;
  119.         int b0 = 0;
  120.         int c0 = 0;
  121.         int d0 = 0;
  122.  
  123.         int b00 = 3;
  124.         int c00 = 199;
  125.         int d00 = 33;
  126. */
  127. /*
  128.         int a0 = 172;
  129.         int b0 = 16;
  130.         int c0 = 0;
  131.         int d0 = 0;
  132. */
  133.  
  134.         boolean a0b = true;
  135.         boolean b0b = true;
  136.         boolean c0b = true;
  137.         boolean d0b = true;
  138.  
  139.         for (int a = a0; a <= a0;  a++) {
  140.             if (!a0b) {
  141.                 a0b = true;
  142.                 a = a0;
  143.             }
  144.  
  145.             for (int b = b0; b <= b0; b++) {
  146.                 if (!b0b) {
  147.                     b0b = true;
  148.                     b = b0;
  149.                 }
  150.                 for (int c = c0; c <= 255; c++) {
  151.                     if (!c0b) {
  152.                         c0b = true;
  153.                         c = c0;
  154.                     }
  155.  
  156.                     for (int d = d0; d <= 255; d++) {
  157.                         if (!d0b) {
  158.                             d0b = true;
  159.                             d = d0;
  160.                         }
  161.                         final int fa = a;
  162.                         final int fb = b;
  163.                         final int fc = c;
  164.                         final int fd = d;
  165.  
  166.                         String address = fa + "." + fb + "." + fc + "." + fd;
  167.                         //LB35Log("   -> NEW " + new java.util.Date() + ": lb35 address/lift-on " + address);
  168.  
  169.                         Job job = new JobImpl() {
  170.                             @Override
  171.                             public void proceed() {
  172.                                 try {
  173.                                     impl(getAddress());
  174.                                     impl(getAddress()); // aren't those robots so clever ;)
  175.                                     impl(getAddress()); // POLICY? ;)
  176.                                 } catch (Throwable t) {
  177.                                     t.printStackTrace();
  178.                                 }
  179.                             }
  180.                         };
  181.                         job.setAddress(address);
  182.                         addJob(job);
  183.                     }
  184.                 }
  185.             }
  186.         }
  187.     }
  188.  
  189.     private void impl(final String address) throws Exception {
  190.         LB35Log("<- doin' witha os/2 ;) " + new java.util.Date() + ": lb35 address/lift-on " + address);
  191.  
  192.         String[] args = new String[2];
  193.         args[0] = "/home/shannansyrjala/norres-app/doit.pl";
  194.         args[1] = address;
  195.         Process p = Runtime.getRuntime().exec(args);
  196.  
  197.         Thread th = new Thread() {
  198.             public void run() {
  199.                 try {
  200.                     final InputStream is = p.getInputStream();
  201.                     final OutputStream os = p.getOutputStream();
  202.  
  203.                     try {
  204.                         int n = -1;
  205.                         byte[] buffer = new byte[4096];
  206.                         ByteArrayOutputStream norobots_bytes = new ByteArrayOutputStream();
  207.  
  208.                         while ((n = is.read(buffer, 0, buffer.length)) != -1) {
  209.                             norobots_bytes.write(buffer, 0, n);
  210.                         }
  211.  
  212.                         LB35Log("" + new String(norobots_bytes.toByteArray(), "UTF-8"));
  213.                     } catch (Exception ex) {
  214.                         ex.printStackTrace();
  215.                     }
  216.  
  217.                     os.close();
  218.                     is.close();
  219.  
  220.                     p.waitFor();
  221.  
  222.                     LB35Log("<- DONE " + new java.util.Date() + ": lb35 address/lift-on " + address + "\n");
  223.                 } catch (Throwable t) {
  224.                     t.printStackTrace();
  225.  
  226.                 }
  227.             }
  228.         };
  229.         th.start();
  230.  
  231.         try {
  232.             p.waitFor();
  233.             synchronized (th) {
  234.                 th.join();
  235.             }
  236.         } catch (Throwable t) {
  237.             t.printStackTrace();
  238.         }
  239.     }
  240. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement