Advertisement
shannansyrjala

G0D/Satan aftermath - CORSETCODER GLITTER

Nov 12th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.87 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 12.11.2019 | for MikkoSyrjala0N TurnySyrjalaN
  11. *
  12. * by SHANNAN Syrjala (at) lesbians (at) UNIX(TM) with D2LD0s UX
  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.         public String getAddress() {
  55.             return this.ipAddress;
  56.         }
  57.  
  58.         public void setAddress(String s) {
  59.             this.ipAddress = s;
  60.         }
  61.     }
  62.  
  63.     private class Worker implements Runnable {
  64.         protected int id;
  65.  
  66.         public void begin(int id) {
  67.             this.id = id;
  68.             Thread t = new Thread(this);
  69.             t.start();
  70.         }
  71.  
  72.         public void run() {
  73.             while (true) {
  74.                 //LB35Log(("worker[" + this.id + "]"));
  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.         if (args!= null && args.length > 0) {
  89.             m.doit(args[0]);
  90.         } else {
  91.             m.doit(null);
  92.         }
  93.     }
  94.  
  95.     private void doit(String mode) {
  96.         LB35Log("!!!! mode ["+mode+"]");
  97.        
  98.         if ((mode == null || mode.equalsIgnoreCase("")) || !(mode.equalsIgnoreCase("all") || mode.equalsIgnoreCase("127")
  99.             || mode.equalsIgnoreCase("all") || mode.equalsIgnoreCase("127") || mode.equalsIgnoreCase("192")
  100.             || mode.equalsIgnoreCase("10") || mode.equalsIgnoreCase("172") || mode.equalsIgnoreCase("0"))) {
  101.             throw new IllegalStateException("invalid mode");
  102.         }
  103.        
  104.         for (int i = 0; i < 100; i++) {
  105.             Worker w = new Worker();
  106.             w.begin((i + 1));
  107.         }
  108.            
  109.         if (mode.equalsIgnoreCase("127") || mode.equalsIgnoreCase("all")) {
  110.             doitImpl2(127,0,0,2,
  111.                       -2,-2,0,1);
  112.         } if (mode.equalsIgnoreCase("192") || mode.equalsIgnoreCase("all")) {
  113.             doitImpl(192,168,0,0,
  114.                      -2,-2,0,0);
  115.         } if (mode.equalsIgnoreCase("10") || mode.equalsIgnoreCase("all")) {
  116.             doitImpl(10,0,1,0,
  117.                     -2,-2,1,0);
  118.         } if (mode.equalsIgnoreCase("172") || mode.equalsIgnoreCase("all")) {
  119.             doitImpl(172,16,0,0,
  120.                      -2,-2,0,0);
  121.         } if (mode.equalsIgnoreCase("0") || mode.equalsIgnoreCase("all")) {
  122.             doitImpl(0,0,0,0,
  123.                     -2,-2,0,0);
  124.         }
  125.     }
  126.  
  127.     private void doitImpl2(int a0, int b0, int c0, int d0,
  128.         int a00, int b00, int c00, int d00) {
  129.         final int fa = a0;
  130.         final int fb = b0;
  131.         final int fc = c0;
  132.         final int fd = d0;
  133.         String address = fa + "." + fb + "." + fc + "." + fd;
  134.          
  135.         for (int i = 0; i < 10; i++) {
  136.             Job job = new JobImpl() {
  137.                 @Override
  138.                 public void proceed() {
  139.                     try {
  140.                         while (true) {
  141.                             impl(getAddress(),false);
  142.                             impl(getAddress(),false);
  143.                         }
  144.                     } catch (Throwable t) {
  145.                         t.printStackTrace();
  146.                     }  
  147.                 }
  148.             };
  149.            
  150.             job.setAddress(address);
  151.             addJob(job);
  152.         }
  153.  
  154.  
  155.         for (int i = 0; i < 10; i++) {
  156.             Job job = new JobImpl() {
  157.                 @Override
  158.                 public void proceed() {
  159.                     try {
  160.                         while (true) {
  161.                             impl("127.0.0.1", false);
  162.                             impl("127.0.0.1", false);  
  163.                         }
  164.                     } catch (Throwable t) {
  165.                         t.printStackTrace();
  166.                     }  
  167.                 }
  168.             };
  169.            
  170.             job.setAddress(address);
  171.             addJob(job);
  172.         }
  173.    
  174.         for (int i = 0; i < 10; i++) {
  175.             Job job = new JobImpl() {
  176.                 @Override
  177.                 public void proceed() {
  178.                     try {
  179.                         while (true) {
  180.                             impl(getAddress(),true);
  181.                             impl(getAddress(),true);
  182.                         }
  183.                     } catch (Throwable t) {
  184.                         t.printStackTrace();
  185.                     }  
  186.                 }
  187.             };
  188.            
  189.             job.setAddress(address);
  190.             addJob(job);
  191.         }
  192.                          
  193.         for (int i = 0; i < 10; i++) {
  194.             Job job = new JobImpl() {
  195.                 @Override
  196.                 public void proceed() {
  197.                     try {
  198.                         while (true) {
  199.                             impl("127.0.0.1", true);
  200.                             impl("127.0.0.1", true);
  201.                         }
  202.                     } catch (Throwable t) {
  203.                         t.printStackTrace();
  204.                     }  
  205.                 }
  206.             };
  207.            
  208.             job.setAddress(address);
  209.             addJob(job);
  210.         }
  211.     }
  212.    
  213.     private void doitImpl(int a0, int b0, int c0, int d0,
  214.     int a00, int b00, int c00, int d00) {
  215.         boolean a0b = true;
  216.         boolean b0b = true;
  217.         boolean c0b = true;
  218.         boolean d0b = true;
  219.  
  220.         if (a00 > -1) {
  221.             a0b = false;
  222.         }
  223.         if (b00 > -1) {
  224.             b0b = false;
  225.         }
  226.         if (c00 > -1) {
  227.             c0b = false;
  228.         }
  229.         if (d00 > -1) {
  230.             d0b = false;
  231.         }
  232.  
  233.         int limitA = 255;
  234.         if (a00 == -2) {
  235.             limitA = a0;
  236.         }
  237.         int limitB = 255;
  238.         if (b00 == -2) {
  239.             limitB = b0;
  240.         }
  241.  
  242.         for (int a = a0; a <= limitA;  a++) {
  243.             if (!a0b) {
  244.                 a0b = true;
  245.                 a = a00;
  246.             }
  247.  
  248.             for (int b = b0; b <= limitB; b++) {
  249.                 if (!b0b) {
  250.                     b0b = true;
  251.                     b = b00;
  252.                 }
  253.        
  254.                 for (int c = c0; c <= 255; c++) {
  255.                     if (!c0b) {
  256.                         c0b = true;
  257.                         c = c00;
  258.                     }
  259.  
  260.                     for (int d = d0; d <= 255; d++) {
  261.                         if (!d0b) {
  262.                             d0b = true;
  263.                             d = d00;
  264.                         }
  265.  
  266.                         final int fa = a;
  267.                         final int fb = b;
  268.                         final int fc = c;
  269.                         final int fd = d;
  270.                         String address = fa + "." + fb + "." + fc + "." + fd;
  271.  
  272.                         //LB35Log("   -> NEW " + new java.util.Date() + ": lb35 address/lift-on " + address);
  273.                         Job job = new JobImpl() {
  274.                             @Override
  275.                             public void proceed() {
  276.                                 try {
  277.                                     impl(getAddress(), false);
  278.                                     impl(getAddress(), false);
  279.                                 } catch (Throwable t) {
  280.                                     t.printStackTrace();
  281.                                 }
  282.                             }
  283.                         };
  284.            
  285.                         job.setAddress(address);
  286.                         addJob(job);
  287.                        
  288.                         Job job2 = new JobImpl() {
  289.                             @Override
  290.                             public void proceed() {
  291.                                 try {                                    
  292.                                     impl(getAddress(), true);
  293.                                     impl(getAddress(), true);
  294.                                 } catch (Throwable t) {
  295.                                     t.printStackTrace();
  296.                                 }
  297.                             }
  298.                         };
  299.            
  300.                         job2.setAddress(address);
  301.                         addJob(job2);
  302.                     }
  303.                 }
  304.  
  305.             }
  306.         }
  307.     }
  308.  
  309.     private void impl(final String address, boolean personal) throws Exception {
  310.         LB35Log("-> doin' [\033[1;31m" + address + "\033[0m] [\033[0;34m]" + new java.util.Date() + "\033[0m]");
  311.  
  312.         String[] args = new String[2];
  313.         if (!personal) {
  314.             args[0] = "/Users/shannansyrjala/norres-app/doit.pl";
  315.         } else {
  316.             args[0] = "/Users/shannansyrjala/norres-app/doit2.pl";
  317.         }
  318.         args[1] = address;
  319.         Process p = Runtime.getRuntime().exec(args);
  320.  
  321.         Thread th = new Thread() {
  322.             public void run() {
  323.                 try {
  324.                     final InputStream is = p.getInputStream();
  325.                     final OutputStream os = p.getOutputStream();
  326.  
  327.                     try {
  328.                         int n = -1;
  329.                         byte[] buffer = new byte[4096];
  330.                         ByteArrayOutputStream norobots_bytes = new ByteArrayOutputStream();
  331.  
  332.                         while ((n = is.read(buffer, 0, buffer.length)) != -1) {
  333.                             norobots_bytes.write(buffer, 0, n);
  334.                         }
  335.  
  336.                         LB35Log("" + new String(norobots_bytes.toByteArray(), "UTF-8"));
  337.                     } catch (Exception ex) {
  338.                         ex.printStackTrace();
  339.                     } finally {
  340.                         os.close();
  341.                         is.close();
  342.                         p.waitFor();
  343.                        
  344.                         LB35Log("<- DONE  [\033[1;31m" + address + "\033[0m] [\033[0;34m]" + new java.util.Date() + "\033[0m]");
  345.                     }
  346.                 } catch (Throwable t) {
  347.                     t.printStackTrace();
  348.  
  349.                 }
  350.             }
  351.         };
  352.         th.start();
  353.  
  354.         try {
  355.             p.waitFor();
  356.             synchronized (th) {
  357.                 th.join();
  358.             }
  359.         } catch (Throwable t) {
  360.             t.printStackTrace();
  361.         }
  362.     }
  363. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement