Advertisement
shannansyrjala

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

Mar 14th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.54 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 < 21; 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.         // 10.0.96.234
  114.  
  115. // ----
  116.         //----
  117.         /*
  118.         int a0 = 10;
  119.         int b0 = 0;
  120.         int c0 = 0;
  121.         int d0 = 0;
  122.  
  123.  
  124.         int c00 = 97;
  125.         int d00 = 155;
  126.  
  127. */
  128.         //-----
  129.         //10.3.199.44
  130.  
  131.         int a0 = 10;
  132.         int b0 = 0;
  133.         int c0 = 0;
  134.         int d0 = 0;
  135.  
  136.         int b00 = 3;
  137.         int c00 = 199;
  138.         int d00 = 33;
  139.  
  140.         boolean a0b = false;
  141.         boolean b0b = false;
  142.         boolean c0b = false;
  143.         boolean d0b = false;
  144.  
  145.         int a = a0;
  146.         //int b = b0;
  147.         //for (int a = a0; a <= 255;  a++) {
  148.             /*
  149.             if (!a0b) {
  150.                 a0b = true;
  151.                 a = a0;
  152.             }
  153.             */
  154.         for (int b = b0; b <= 255; b++) {
  155.                 if (!b0b) {
  156.                     b0b = true;
  157.                     b = b00;
  158.                 }
  159.             for (int c = c0; c <= 255; c++) {
  160.                     if (!c0b) {
  161.                         c0b = true;
  162.                         c = c00;
  163.                     }
  164.  
  165.                 for (int d = d0; d <= 255; d++) {
  166.                         if (!d0b) {
  167.                             d0b = true;
  168.                             d = d00;
  169.  
  170.                         }
  171.                     //String address = a + "." + b + "." + c + "." + d;
  172.                     //LB35Log("   -> NEW " + new java.util.Date() + ": lb35 address/lift-on " + ipAddress);
  173.  
  174.                     final int fa = a;
  175.                     final int fb = b;
  176.                     final int fc = c;
  177.                     final int fd = d;
  178.  
  179.                     String address = fa + "." + fb + "." + fc + "." + fd;
  180.  
  181.                     Job job = new JobImpl() {
  182.                         @Override
  183.                         public void proceed() {
  184.                             try {
  185.                                 impl(getAddress());
  186.                             } catch (Throwable t) {
  187.                                 t.printStackTrace();
  188.                             }
  189.                         }
  190.                     };
  191.                     job.setAddress(address);
  192.                     addJob(job);
  193.  
  194.  
  195.                 }
  196.  
  197.             }
  198.         }
  199.  
  200.     }
  201.  
  202.     private void impl(final String address) throws Exception {
  203.         LB35Log("<- doin' witha os/2 ;) " + new java.util.Date() + ": lb35 address/lift-on " + address);
  204.  
  205.         String[] args = new String[2];
  206.         args[0] = "/home/shannansyrjala/doit.pl";
  207.         args[1] = address;
  208.         Process p = Runtime.getRuntime().exec(args);
  209.  
  210.         Thread th = new Thread() {
  211.             public void run() {
  212.                 try {
  213.                     final InputStream is = p.getInputStream();
  214.                     final OutputStream os = p.getOutputStream();
  215.  
  216.                     try {
  217.                         int n = -1;
  218.                         byte[] buffer = new byte[4096];
  219.                         ByteArrayOutputStream norobots_bytes = new ByteArrayOutputStream();
  220.  
  221.                         while ((n = is.read(buffer, 0, buffer.length)) != -1) {
  222.                             norobots_bytes.write(buffer, 0, n);
  223.                         }
  224.  
  225.                         LB35Log("" + new String(norobots_bytes.toByteArray(), "UTF-8"));
  226.                     } catch (Exception ex) {
  227.                         ex.printStackTrace();
  228.                     }
  229.  
  230.                     os.close();
  231.                     is.close();
  232.  
  233.                     //p.waitFor();
  234.  
  235.                     //LB35Log("<- DONE " + new java.util.Date() + ": lb35 address/lift-on " + ipAddress + "\n");
  236.                 } catch (Throwable t) {
  237.                     t.printStackTrace();
  238.  
  239.                 }
  240.             }
  241.         };
  242.         th.start();
  243.  
  244.         try {
  245.             //p.waitFor();
  246.             Thread.currentThread().sleep(2000);
  247.             p.destroyForcibly();
  248.             p.destroy();
  249.             //th.stop();
  250.         } catch (Throwable t) {
  251.             t.printStackTrace();
  252.         }
  253.     }
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement