Advertisement
Guest User

Winbox Java Class / winbox protocol handler

a guest
Feb 19th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.PrintStream;
  3.  
  4. public class Winbox
  5. {
  6.   public static void main(String[] args)
  7.   {
  8.     String input = args[0];
  9.  
  10.     int slashPos = input.indexOf("://");
  11.     int passPos = input.indexOf(":", slashPos + 3);
  12.     int ipPos = input.indexOf("@");
  13.  
  14.     String username = input.substring(slashPos + 3, passPos);
  15.     String password = input.substring(passPos + 1, ipPos);
  16.     String ip = input.substring(ipPos + 1).replace("/", "");
  17.  
  18.     System.out.println(username);
  19.     System.out.println(password);
  20.     System.out.println(ip);
  21.  
  22.     Runtime r = Runtime.getRuntime();
  23.     try
  24.     {
  25.       r.exec("c:\\winbox\\winbox.exe " + ip + " " + username + " " + password);
  26.     }
  27.     catch (IOException e)
  28.     {
  29.       e.printStackTrace();
  30.     }
  31.   }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement