Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2011
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 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 mainc {
  6.         private static Scanner scan = new Scanner(System.in);
  7.         private static Pattern ex = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
  8.         private static Matcher match;
  9.         static Writer output;
  10.         static int loop = 0;
  11.         public static void main(String[] args) throws IOException{
  12.             System.out.println("Nmap log parser - Specify file location!");
  13.             String filen = scan.next();
  14.             File file = new File(filen);
  15.             FileInputStream fis = new FileInputStream(file);
  16.             BufferedInputStream bis = new BufferedInputStream(fis);
  17.             DataInputStream dis = new DataInputStream(bis);
  18.             output = new BufferedWriter(new FileWriter("nparsed"));
  19.             while(dis.available()!=0){
  20.             String it = dis.readLine();
  21.             match = ex.matcher(it);
  22.             while (match.find() ){
  23.                  System.out.println( match.group() );
  24.                  output.write(match.group()+"\n");
  25.                  loop++;
  26.             }
  27.             }
  28.             output.close();
  29.             System.out.println("Done parsing the Nmap log.\n"+loop+" ips total.");
  30.         }
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement