GenuineSounds

DNSniffy

Jun 4th, 2014
348
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.27 KB | None | 0 0
  1. package com.genuinevm.sniffy;
  2.  
  3. import java.net.*;
  4. import java.util.*;
  5.  
  6. public class Sniffy {
  7.  
  8.     boolean debug = false;
  9.     List<String> urlList = new ArrayList<>();
  10.     SortedMap<String, List<String>> map = (
  11.         Collections.synchronizedSortedMap(
  12.             new TreeMap<String, List<String>>(
  13.                 (k1, k2) -> {
  14.                     String[] str1 = k1.split("\\.");
  15.                     String[] str2 = k2.split("\\.");
  16.                     if (str1.length != 4)
  17.                         throw new NumberFormatException();
  18.                     int[] is1 = {
  19.                         Integer.parseInt(str1[0], 10),
  20.                         Integer.parseInt(str1[1], 10),
  21.                         Integer.parseInt(str1[2], 10),
  22.                         Integer.parseInt(str1[3], 10)
  23.                     };
  24.                     int[] is2 = {
  25.                         Integer.parseInt(str2[0], 10),
  26.                         Integer.parseInt(str2[1], 10),
  27.                         Integer.parseInt(str2[2], 10),
  28.                         Integer.parseInt(str2[3], 10)
  29.                     };
  30.                     for (int i = 0; i < 4; i++) {
  31.                         int i1 = is1[i];
  32.                         int i2 = is2[i];
  33.                         if (i1 == i2)
  34.                             continue;
  35.                         if (i1 < i2)
  36.                             return -1;
  37.                         else
  38.                             return 1;
  39.                     }
  40.                     return 0;
  41.                 }
  42.             )
  43.         )
  44.     );
  45.  
  46.     Sniffy() {
  47.         urlList.add("steampowered.com");
  48.         urlList.add("valvesoftware.com");
  49.         urlList.add("store.steampowered.com");
  50.         urlList.add("cdn.store.steampowered.com");
  51.         urlList.add("media.steampowered.com");
  52.         urlList.add("storefront.steampowered.com");
  53.         urlList.add("cdn.steamcommunity.com");
  54.         urlList.add("support.steampowered.com");
  55.         urlList.add("translation.steampowered.com");
  56.         urlList.add("store.valvesoftware.com");
  57.         urlList.add("source.valvesoftware.com");
  58.         urlList.add("steamcommunity.com");
  59.         urlList.add("api.steampowered.com");
  60.         urlList.add("cafe.steampowered.com");
  61.         urlList.add("client-download.steampowered.com");
  62.         for (int i = 0; i < 100; i++) {
  63.             urlList.add("media" + i + ".steampowered.com");
  64.             urlList.add("cdn" + i + ".store.steampowered.com");
  65.             urlList.add("cdn" + i + ".steamcommunity.com");
  66.             urlList.add("cloud-" + i + ".steampowered.com");
  67.             urlList.add("content" + i + ".steampowered.com");
  68.         }
  69.         for (int i = 0; i < 500; i++) {
  70.             urlList.add("valve" + Integer.toString(i, 10) + ".cs.steampowered.com");
  71.         }
  72.     }
  73.  
  74.     void run() {
  75.         System.out.println("# Generated by DNSniffy");
  76.         urlList.stream().parallel().forEach(this::getIP);
  77.         map.forEach(this::output);
  78.     }
  79.  
  80.     void getIP(String s) {
  81.         try {
  82.             InetAddress address = InetAddress.getByName(new URL("http://" + s).getHost());
  83.             String key = address.getHostAddress();
  84.             synchronized (map) {
  85.                 map.putIfAbsent(key, new ArrayList<>());
  86.                 map.get(key).add(s);
  87.                 if (s.replaceAll("[^.]", "").length() <= 1)
  88.                     map.get(key).add("www." + s);
  89.             }
  90.         }
  91.         catch (Exception e) {
  92.             if (debug)
  93.                 System.out.println("# ERROR: " + s);
  94.         }
  95.     }
  96.  
  97.     void output(String k, List<String> v) {
  98.         Collections.sort(v, (s1, s2) -> s1.compareToIgnoreCase(s2));
  99.         String line = "";
  100.         for (int i = 0; i < v.size(); i++) {
  101.             String tmp = v.get(i);
  102.             line += buffer(tmp, " ", ((i * 36) - line.length() + tmp.length()), true);
  103.         }
  104.         System.out.println(buffer(k, " ", 18, false) + line);
  105.     }
  106.  
  107.     String buffer(String input, String buffer, int max, boolean leading) {
  108.         while (input.length() < max) {
  109.             if (input.length() >= max)
  110.                 break;
  111.             if (leading)
  112.                 input = buffer + input;
  113.             else
  114.                 input = input + buffer;
  115.         }
  116.         return input;
  117.     }
  118. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment