Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ifs;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Random;
- public class IFS {
- private static final int THREADS = 10;
- private static class MyRunnable implements Runnable {
- private static final String STR_MESSAGE = "(%d) %s";
- private static final String STR_SUCCESS = "(%d) %d/%d=%f %s";
- private final int mThreadId;
- private int mSuccess = 0;
- private int mTotal = 0;
- public MyRunnable(int id){
- mThreadId = id;
- }
- @Override
- public void run() {
- final Random random = new Random();
- boolean found = false;
- while (true) {
- String chars = "1234567890QWERTYUIOPASDFGHJKLZXCVBNM";
- String s = generateString(random, chars, 6);
- final String url = "http://files.icq.net/files/get?fileId="+ s;
- try {
- found = false;
- URL u = new URL(url);
- mTotal++;
- URLConnection uc = u.openConnection();
- uc.connect();
- uc.getContent();
- found = true;
- mSuccess++;
- } catch (MalformedURLException e) {
- System.out.println(String.format(STR_MESSAGE, mThreadId, e.getMessage()));
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- System.out.println(String.format(STR_MESSAGE, mThreadId, e.getMessage()));
- }
- if(found){
- final double p = mSuccess / mTotal;
- System.out.println(String.format(STR_SUCCESS, mThreadId, mSuccess, mTotal, p, url));
- }
- }
- }
- }
- /**
- * @param args
- */
- public static void main(String[] args) {
- System.out.println("ICQ Files Scanner 0.1");
- for(int i=0; i<THREADS; i++){
- new Thread(new MyRunnable(i)).start();
- }
- }
- public static String generateString(Random rng, String characters,
- int length) {
- char[] text = new char[length];
- for (int i = 0; i < length; i++) {
- text[i] = characters.charAt(rng.nextInt(characters.length()));
- }
- return new String(text);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement