Advertisement
Guest User

CPP Dload bot

a guest
Nov 9th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.53 KB | None | 0 0
  1. //Java bot, downloads files from CPP
  2. //edit the first two variables with your key and your path, read comments
  3. //Compile and run easily with Netbeans or whatever
  4.  
  5. package downloader;
  6.  
  7. import java.io.*;
  8. import java.net.*;
  9.  
  10. public class Main {
  11.  
  12.     //set i to your starting key, number ends with L
  13.     //set resultspath to your results folder, path ends with /
  14.     static long i = 4750806412L;
  15.     static String resultspath = "R:/pedesta/";
  16.  
  17.  
  18.     static FileOutputStream fes;
  19.     public static void daemon() throws MalformedURLException, FileNotFoundException, IOException {
  20.         BufferedInputStream in = null;
  21.  
  22.         byte data[] = new byte[1024];
  23.         String error = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>NoSuchKey";
  24.         int count = -1;
  25.  
  26.         int k = 0;
  27.         for( ; i < 9999999999L; i++ ){
  28.             System.out.println("now at "+i);
  29.            
  30.             try {
  31.                 in = new BufferedInputStream( new URL("http://www.cometpingpong.com/app/download/"+i+"/"+i+".txt").openStream() );
  32.                 count = in.read( data, 0, 1024 );
  33.             }catch( java.io.FileNotFoundException fnfe ){
  34.                 //fnfe.printStackTrace();
  35.                 fes.write( (i+",Didn't get Bytes 404?").getBytes() );
  36.                 continue;
  37.             }
  38.  
  39.             if( count == -1 ){
  40.                 System.out.println("404");
  41.                 fes.write( (i+",Didn't get Bytes 404?").getBytes() );
  42.                 continue;
  43.             }else{
  44.                 String s = new String(data);
  45.                 if( s.equals(error)){
  46.                     System.out.println("error");
  47.                     //fes.write( (i+",Error page retrieved.").getBytes() );
  48.                     continue;
  49.                 }
  50.             }
  51.  
  52.             System.out.println("********** HIT: "+i);
  53.             fes.write( (i+",HIT").getBytes() );
  54.  
  55.             // if file doesnt exists, then create it
  56.             File file = new File(resultspath+i+".txt");
  57.             if (!file.exists()) {
  58.                 file.createNewFile();
  59.             }
  60.  
  61.             FileOutputStream fos = new FileOutputStream(file.getAbsoluteFile());
  62.             while( (count = in.read(data,0,1024)) != -1 ){
  63.                 fos.write(data, 0, count);
  64.             }
  65.             fos.flush();
  66.             fos.close();
  67.  
  68.  
  69.         }
  70.  
  71.     }
  72.  
  73.     public static void main(String[] args) {
  74.  
  75.         try {
  76.             File errors = new File(resultspath+"errors.txt");
  77.             fes = new FileOutputStream(errors);
  78.            
  79.             while( i < 4999999999L ){
  80.                 try {
  81.                     daemon();
  82.                 }catch( MalformedURLException mue ){
  83.                     mue.printStackTrace();
  84.                     fes.write( (i+",Malformed URL").getBytes() );
  85.                 }catch( IOException ioe ){
  86.                     ioe.printStackTrace();
  87.                 }
  88.  
  89.                 try{
  90.                     Thread.sleep( 5000 );
  91.                 }catch( InterruptedException ie ){
  92.                     ie.printStackTrace();
  93.                 }
  94.             }
  95.  
  96.             fes.flush();
  97.             fes.close();
  98.  
  99.         }catch( IOException ioe ){
  100.             ioe.printStackTrace();
  101.         }
  102.     }
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement