Advertisement
shannansyrjala

G0D/Satan aftermath HALLELUJA o' mine - PART #2

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