Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package co.uk.norres;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.util.Vector;
- /**
- * LB35 Turniers | lift-on 2.11.2019 | for MikkoSyrjala0N TurnySyrjalaN
- *
- * by SHANNAN Syrjala, the corsetcoder ;)
- */
- public class Main {
- protected Vector<Job> jobs = new Vector<Job>();
- protected void addJob(Job job) {
- synchronized (jobs) {
- jobs.addElement(job);
- jobs.notify();
- }
- }
- protected Job getNextJob() {
- while (jobs.size() <= 0) {
- synchronized (jobs) {
- try {
- jobs.wait();
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- }
- synchronized (jobs) {
- Job job = jobs.elementAt(0);
- jobs.removeElementAt(0);
- return job;
- }
- }
- protected interface Job {
- public void proceed();
- public String getAddress();
- public void setAddress(String s);
- }
- public class JobImpl implements Job {
- private String ipAddress;
- public void proceed() {
- }
- public String getAddress() {
- return this.ipAddress;
- }
- public void setAddress(String s) {
- this.ipAddress = s;
- }
- }
- private class Worker implements Runnable {
- protected int id;
- public void begin(int id) {
- this.id = id;
- Thread t = new Thread(this);
- t.start();
- }
- public void run() {
- while (true) {
- Job job = getNextJob();
- //LB35Log("<- PROCEED" + new java.util.Date() + ": lb35 address/lift-on " + job.getAddress());
- job.proceed();
- }
- }
- }
- private static void LB35Log(String msg) {
- System.out.println("" + msg);
- }
- public static void main(String[] args) throws IOException {
- Main m = new Main();
- m.doit();
- }
- private void doit() {
- //doitImpl(192,168,0,0,
- // -2,-2,10,222);
- doitImpl(192,168,0,0,
- -2,-2,152,236);
- //doitImpl(10,0,0,0,
- // -2,-2,9,1); // , -1
- /*
- doitImpl(172,16,0,0,
- -2,-1,12,9);
- doitImpl(0,0,0,0,
- -2,-1,12,8);
- */
- }
- private void doitImpl(int a0, int b0, int c0, int d0,
- int a00, int b00, int c00, int d00) {
- for (int i = 0; i < 60; i++) { //21
- Worker w = new Worker();
- w.begin((i + 1));
- }
- boolean a0b = true;
- boolean b0b = true;
- boolean c0b = true;
- boolean d0b = true;
- if (a00 > -1) {
- a0b = false;
- }
- if (b00 > -1) {
- b0b = false;
- }
- if (c00 > -1) {
- c0b = false;
- }
- if (d00 > -1) {
- d0b = false;
- }
- int limitA = 255;
- if (a00 == -2) {
- limitA = a0;
- }
- int limitB = 255;
- if (b00 == -2) {
- limitB = b0;
- }
- for (int a = a0; a <= limitA; a++) {
- if (!a0b) {
- a0b = true;
- a = a00;
- }
- for (int b = b0; b <= limitB; b++) {
- if (!b0b) {
- b0b = true;
- b = b00;
- }
- for (int c = c0; c <= 255; c++) {
- if (!c0b) {
- c0b = true;
- c = c00;
- }
- for (int d = d0; d <= 255; d++) {
- if (!d0b) {
- d0b = true;
- d = d00;
- }
- final int fa = a;
- final int fb = b;
- final int fc = c;
- final int fd = d;
- String address = fa + "." + fb + "." + fc + "." + fd;
- //LB35Log(" -> NEW " + new java.util.Date() + ": lb35 address/lift-on " + address);
- Job job = new JobImpl() {
- @Override
- public void proceed() {
- try {
- impl(getAddress());
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- };
- job.setAddress(address);
- addJob(job);
- }
- }
- }
- }
- }
- private void impl(final String address) throws Exception {
- LB35Log("<- doin' witha os/2 ;) " + new java.util.Date() + ": lb35 address/lift-on " + address);
- String[] args = new String[2];
- args[0] = "/home/shannansyrjala/norres-app/doit.pl";
- args[1] = address;
- Process p = Runtime.getRuntime().exec(args);
- Thread th = new Thread() {
- public void run() {
- try {
- final InputStream is = p.getInputStream();
- final OutputStream os = p.getOutputStream();
- try {
- int n = -1;
- byte[] buffer = new byte[4096];
- ByteArrayOutputStream norobots_bytes = new ByteArrayOutputStream();
- while ((n = is.read(buffer, 0, buffer.length)) != -1) {
- norobots_bytes.write(buffer, 0, n);
- }
- LB35Log("" + new String(norobots_bytes.toByteArray(), "UTF-8"));
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- os.close();
- is.close();
- p.waitFor();
- LB35Log("<- DONE " + new java.util.Date() + ": lb35 address/lift-on " + address + "\n");
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- };
- th.start();
- try {
- p.waitFor();
- synchronized (th) {
- th.join();
- }
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment