Advertisement
Guest User

Untitled

a guest
Feb 1st, 2011
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.79 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Date;
  3. import java.net.*;
  4. import java.util.Scanner;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7.  
  8. public class honey{
  9.                    
  10.     public static void main(String[] args) throws IOException, InterruptedException{
  11.      
  12.         //Declaring
  13.  
  14.       String userInput,logf,alert,loop,inputLine,outputLine,service,custom,whois,sent1,sent2,sent3,reci = null;
  15.       ServerSocket serverSocket = null;
  16.       PrintWriter out = null;
  17.       String port = "1433";
  18.       Socket clientSocket = null;
  19.       Date date = new Date();
  20.       String inp = null, outp;
  21.       int attempt = 0;
  22.       int banner = 0;
  23.      
  24.       String cmd = "whois ";
  25.      Pattern ex = Pattern.compile("\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}");
  26.      Matcher match;
  27.      
  28.       //Scanning for input and creating the log
  29.         System.out.println("# #                  ##         \n# # ### ##  ### # #   #  ## ### \n### # # # # ##  ###   # # # #   \n# # ### # # ###   # # # ### #  \n# #             ###  #          \nCreated By: Pathogen\n");
  30.         Scanner scan = new Scanner(System.in);
  31.         System.out.println("Choose port to listen on (1-1024 require root)");
  32.         port = scan.next();
  33.         int prt = Integer.parseInt(port.trim());
  34.         System.out.println("Specify log filename.");
  35.         logf = scan.next();
  36.         System.out.println("How many connection attempts would you like to allow?");
  37.         loop = scan.next();
  38.         int lop = Integer.parseInt(loop.trim());
  39.         System.out.println("What banner would you like to display to the intruder?\n(1)Gmail\n(2)Proxy\n(3)Custom Message");
  40.         service = scan.next();
  41.         banner = Integer.parseInt(service.trim());
  42.         File dir = new File(logf);
  43.         BufferedWriter fout = new BufferedWriter(new FileWriter(dir));
  44.         //opening socket
  45.        
  46.             try{
  47.         System.out.println("Trying to open socket");
  48.         serverSocket = new ServerSocket(prt);
  49.             }
  50.         catch (IOException e){
  51.         System.out.println("Could not listen on port " + prt + ", please try a different one.");
  52.         port = scan.next();
  53.         prt = Integer.parseInt(port.trim());
  54.         serverSocket = new ServerSocket(prt);
  55.         }catch (Exception e){
  56.             System.out.println("Could not listen on port "+ prt + "\nClosing client.");
  57.         }
  58.    
  59.         if (banner == 1){
  60.          while(lop >= 0){
  61.         InetAddress in3t =  serverSocket.getInetAddress();
  62.              System.out.println("Scan watch is now listening on port " + prt  + "\nTime began - " + date +"\nLog directory - " + dir.getCanonicalPath() + "\nOption chosen: Gmailer" );
  63.              fout.write("Scan watch is now listening on port " + prt  + "\nTime began - " + date +"\nLog directory - " + dir.getCanonicalPath() + "\nOption chosen: Gmailer");
  64.              try{
  65.         clientSocket = serverSocket.accept();
  66.        
  67.        //Set stream reader and wrighter for sockets--------------------------------------
  68.        
  69.         PrintWriter out1 = new PrintWriter(
  70.                 clientSocket.getOutputStream(), true);
  71.         BufferedReader in1 = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
  72.          InetAddress inet = clientSocket.getInetAddress();    
  73.         String host = inet.getCanonicalHostName();
  74.         String hostp = inet.getHostAddress();
  75.         System.out.println(hostp);
  76.         alert = "\nConnection attempt by: " + host + "\n" + clientSocket + " \nTime detected - " + date + "\n";
  77.         System.out.println(alert);
  78.         fout.write(alert);
  79.         //Get client info
  80.          inet = clientSocket.getInetAddress();
  81.      Runtime run = Runtime.getRuntime();
  82.      Process pro = run.exec(cmd + hostp);
  83.      pro.waitFor();
  84.         BufferedReader buff = new BufferedReader(new InputStreamReader(pro.getInputStream()));
  85.     String line = "";
  86.     while((line = buff.readLine())!= null){
  87.         System.out.println(line);
  88.     }
  89.         System.out.println(alert);                                                       
  90.         out1.println("Welcome to the Anonymous Gmailer.\n Enter your login credentials to continue on.\n Username");
  91.         inp =  in1.readLine();
  92.         System.out.println("Username: " + inp);
  93.         fout.write("Username: " + inp);
  94.         fout.newLine();
  95.         out1.println(" Password");
  96.         inp = in1.readLine();
  97.         System.out.println("Password: " + inp + "\n\n");
  98.         fout.write("Password: " + inp + "\n\n");
  99.         fout.newLine();
  100.         out1.println("Invalid username or password, try again.");
  101.         inp =  in1.readLine();
  102.         System.out.println("Username: " + inp);
  103.         fout.write("Username: " + inp);
  104.         fout.newLine();
  105.         out1.println(" Password");
  106.         inp = in1.readLine();
  107.         System.out.println("Password: " + inp + "\n\n");
  108.         fout.write("Password: " + inp + "\n\n");
  109.         out1.println("Invalid username or password, try again.");
  110.         inp =  in1.readLine();
  111.     System.out.println("Username: " + inp);
  112.     fout.write("Username: " + inp);
  113.     fout.newLine();
  114.     out1.println(" Password");
  115.     inp = in1.readLine();
  116.     System.out.println("Password: " + inp + "\n\n");
  117.     fout.write("Username: " + inp + "\n\n");
  118.         outp = "202 Error! Invalid Credentials.\nConnection closed by foriegn host";
  119.         out1.println(outp);
  120.         System.out.println("Connection attempt #"+ attempt);
  121.         attempt = attempt + 1;
  122.        
  123.         }catch (IOException i){
  124.             attempt = (attempt + 1);
  125.             System.out.println("\nWARNING  - You may be getting scanned\nAttempt #" + attempt);
  126.             fout.write("\nWARNING  - You may be getting scanned\nAttempt #" + attempt);
  127.         } if (lop == 0){
  128.                    System.out.println("Socket Status: Closed");
  129.                    System.out.println("Connection limit reached.");
  130.                    clientSocket.close();
  131.                   serverSocket.close();
  132.         }
  133.        
  134.         }}
  135.          else if (banner == 2)
  136.         {
  137.                       while(lop >= 0)
  138.         {             System.out.println("Scan watch is now listening on port " + port + "\nTime began - " + date +"\nLog dir - " + dir.getCanonicalPath() + "\nOption chosen: Proxy" );
  139.                       fout.write("Scan watch is now listening on port " + port + "\nTime began - " + date +"\nLog dir - " + dir.getCanonicalPath() + "\nOption chosen: Proxy");
  140.         try
  141.         {                   serverSocket.close();
  142.                             serverSocket = new ServerSocket(prt);
  143.                             clientSocket = serverSocket.accept();
  144.                         //----------------------------------------
  145.                         // Proxy Banner  
  146.                         //----------------------------------------    
  147.                             PrintWriter out11 = new PrintWriter(clientSocket.getOutputStream(), true);
  148.                             BufferedReader in11 = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
  149.                             InetAddress inet = clientSocket.getInetAddress();
  150.                                String hostp = inet.getCanonicalHostName();
  151.                              Runtime run = Runtime.getRuntime();
  152.                             out11.println("########################################################\n#Welcome to the Enterprize Edition of Proxmark Proxies #\n########################################################\n");
  153.                             alert = "\nConnection attempt by: "+ hostp +"\n"+ clientSocket + " \nTime detected - " + date;
  154.                     System.out.println(alert);
  155.                     System.out.println("\nIntruders input\n_______________");
  156.                     fout.write("\nIntruders input\n_______________\n");
  157.                     fout.newLine();
  158.                     fout.write(alert);
  159.                     int run1 = 1;
  160.                     while(run1 == 1){
  161.                         if(clientSocket.isConnected()){
  162.                             try{
  163.                     inp = in11.readLine();
  164.                     System.out.println(inp);
  165.                     fout.write(inp);
  166.                     fout.newLine();
  167.                     }catch (Exception ee){
  168.  
  169.                                 lop = lop - 1;
  170.                                 System.out.println("\nWARNING - You may be getting scanned\nAttempt #" + attempt);
  171.                                 clientSocket.close();
  172.                                 serverSocket.close();
  173.                                 run1 = 0;
  174.                             }
  175.                         if(inp == null){
  176.                             run1 = 0;
  177.                         }}}
  178.                     System.out.println(inet.getHostName());
  179.                     String in3t = inet.getHostAddress();
  180.                  Process pro = run.exec(cmd + in3t);
  181.                  pro.waitFor();
  182.                     BufferedReader buff = new BufferedReader(new InputStreamReader(pro.getInputStream()));
  183.                 String line = "";
  184.                 lop = lop - 1;
  185.                 attempt = attempt + 1;
  186.                     while((line = buff.readLine())!= null){
  187.                     System.out.println(line);
  188.                     fout.write(line + "\n");
  189.                     }
  190.                     if(lop == 0){
  191.                        System.out.println("Socket Status: Closed");
  192.                        System.out.println("Connection limit reached.");
  193.                        clientSocket.close();
  194.                       serverSocket.close();
  195.                       }}finally{
  196.                          System.out.println("Connection attemp #" + attempt);
  197.                       }}}
  198.        
  199.         // Custom=======================================================================================================
  200.                       if (banner == 3){
  201.                           System.out.println("Fixing bugs and optimizing code, check the blog for an update - www.hakhub.blogspot.com");
  202.                          }
  203.           //write alert to a logfile and closes the socket
  204.         serverSocket.close();
  205.     System.out.println("\nClosing sockets and saving " + logf + " to " + dir.getCanonicalPath());
  206.     System.exit(1);
  207.     fout.close();
  208.    
  209.        
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement