Guest User

Untitled

a guest
May 3rd, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5. public class ips {
  6.         private static Pattern ex = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
  7.         private static Matcher match;
  8.         static Writer output;
  9.         static int loop = 0;
  10.         public static void main(String[] args) throws IOException{
  11.             String filen = args[0];
  12.             File file = new File(filen);
  13.             FileInputStream fis = new FileInputStream(file);
  14.             BufferedInputStream bis = new BufferedInputStream(fis);
  15.             DataInputStream dis = new DataInputStream(bis);
  16.             output = new BufferedWriter(new FileWriter("ips"));
  17.             while(dis.available()!=0){
  18.             String it = dis.readLine();
  19.             match = ex.matcher(it);
  20.             while (match.find() ){
  21.                  System.out.println( match.group() );
  22.                  output.write(match.group()+"\n");
  23.                  loop++;
  24.             }
  25.             }
  26.             output.close();
  27.             System.out.println("Done parsing the Nmap log.\n"+loop+" ips total.");
  28.         }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment