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

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


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


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[C#] VirusTotal Scanner 0.1
« en: 27 Junio 2014, 15:41 pm »

Mi primer programa en C# , un simple scanner del servicio VirusTotal.

Una imagen :



El codigo :

Form1.cs

Código
  1. // VirusTotal Scanner 0.1
  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 virustotalscanner
  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.            openFileDialog1.ShowDialog();
  26.            if (File.Exists(openFileDialog1.FileName))
  27.            {
  28.                textBox1.Text = openFileDialog1.FileName;
  29.            }
  30.        }
  31.  
  32.        private void button2_Click(object sender, EventArgs e)
  33.        {
  34.  
  35.            DH_Tools tools = new DH_Tools();
  36.  
  37.            if (File.Exists(textBox1.Text))
  38.            {
  39.  
  40.                string md5 = tools.md5file(textBox1.Text);
  41.  
  42.                listView1.Items.Clear();
  43.                richTextBox1.Clear();
  44.  
  45.                string apikey = "07d6f7d301eb1ca58931a396643b91e4c98f830dcaf52aa646f034c876689064"; // API Key
  46.                toolStripStatusLabel1.Text = "[+] Scanning ...";
  47.                this.Refresh();
  48.  
  49.                string code = tools.tomar("http://www.virustotal.com/vtapi/v2/file/report", "resource=" + md5 + "&apikey=" + apikey);
  50.                code = code.Replace("{\"scans\":", "");
  51.  
  52.                string anti = "";
  53.                string reanti = "";
  54.  
  55.                Match regex = Regex.Match(code, "\"(.*?)\": {\"detected\": (.*?), \"version\": (.*?), \"result\": (.*?), \"update\": (.*?)}", RegexOptions.IgnoreCase);
  56.  
  57.                while (regex.Success)
  58.                {
  59.                    anti = regex.Groups[1].Value;
  60.                    reanti = regex.Groups[4].Value;
  61.                    reanti = reanti.Replace("\"", "");
  62.  
  63.                    ListViewItem item = new ListViewItem();
  64.                    if (reanti == "null")
  65.                    {
  66.                        item.ForeColor = Color.Cyan;
  67.                        reanti = "Clean";
  68.                    }
  69.                    else
  70.                    {
  71.                        item.ForeColor = Color.Red;
  72.                    }
  73.  
  74.                    item.Text = anti;
  75.                    item.SubItems.Add(reanti);
  76.  
  77.                    listView1.Items.Add(item);
  78.  
  79.                    regex = regex.NextMatch();
  80.                }
  81.  
  82.                regex = Regex.Match(code, "\"scan_id\": \"(.*?)\"", RegexOptions.IgnoreCase);
  83.                if (regex.Success)
  84.                {
  85.                    richTextBox1.AppendText("[+] Scan_ID : " + regex.Groups[1].Value + Environment.NewLine);
  86.                }
  87.                else
  88.                {
  89.                    MessageBox.Show("Not Found");
  90.                }
  91.  
  92.                regex = Regex.Match(code, "\"scan_date\": \"(.*?)\"", RegexOptions.IgnoreCase);
  93.                if (regex.Success)
  94.                {
  95.                    richTextBox1.AppendText("[+] Scan_Date : " + regex.Groups[1].Value + Environment.NewLine);
  96.                }
  97.  
  98.                regex = Regex.Match(code, "\"permalink\": \"(.*?)\"", RegexOptions.IgnoreCase);
  99.                if (regex.Success)
  100.                {
  101.                    richTextBox1.AppendText("[+] PermaLink : " + regex.Groups[1].Value + Environment.NewLine);
  102.                }
  103.  
  104.                regex = Regex.Match(code, "\"verbose_msg\": \"(.*?)\", \"total\": (.*?), \"positives\": (.*?),", RegexOptions.IgnoreCase);
  105.                if (regex.Success)
  106.                {
  107.                    richTextBox1.AppendText("[+] Founds : " + regex.Groups[3].Value + "/" + regex.Groups[2].Value + Environment.NewLine);
  108.                }
  109.  
  110.                toolStripStatusLabel1.Text = "[+] Finished";
  111.                this.Refresh();
  112.  
  113.  
  114.            }
  115.            else
  116.            {
  117.                MessageBox.Show("File not found");
  118.            }
  119.  
  120.  
  121.        }
  122.    }
  123. }
  124.  
  125. // The End ?
  126.  

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 virustotalscanner
  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

kub0x
Enlightenment Seeker
Moderador
***
Desconectado Desconectado

Mensajes: 1.486


S3C M4NI4C


Ver Perfil
Re: [C#] VirusTotal Scanner 0.1
« Respuesta #1 en: 27 Junio 2014, 16:30 pm »

Buenas tardes Doddy,

Gracias por compartirlo, a todo esto, te leo desde hace mucho tiempo y sé que sueles publicar muchas tools básicas en lenguajes de scripting. Me refiero a que siempre publicas algo nuevo y dejas de lado lo anterior, ¿no se te ha ocurrido hacer una suite donde tengas todas las tools? Yo me la descargaría si pulieras y le añadieras más funcionalidad a este code ;)

Un saludo y esperemos volverte a ver por aquí.


En línea

Viejos siempre viejos,
Ellos tienen el poder,
Y la juventud,
¡En el ataúd! Criaturas Al poder.

Visita mi perfil en ResearchGate

BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
Re: [C#] VirusTotal Scanner 0.1
« Respuesta #2 en: 27 Junio 2014, 17:17 pm »

Ya eh hecho una suite donde pongo todas mis tools de perl en un solo programa , se llama Project ParanoicScan.
En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.807



Ver Perfil
Re: [C#] VirusTotal Scanner 0.1
« Respuesta #3 en: 28 Junio 2014, 03:32 am »

Doddy, permiteme decirte que siempre has utilizado unos contrastes de colores demasiado "altos" para la vista, y yo siempre he respetado los gustos de los demás, pero es que esa GUI es la que más me ha jodido los ojos de todas las que hiciste xD, te lo digo desde el aprecio q sabes q te tengo.

Un saludo!
En línea

BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
Re: [C#] VirusTotal Scanner 0.1
« Respuesta #4 en: 28 Junio 2014, 03:54 am »

no hay problema electro ya me lo dijeron en otros foros , el diseño es un asco tengo que dejar los colores oscuros y raros de una vez xD.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
WTF!? Es posible!?(Virustotal) « 1 2 »
Seguridad
CAR3S? 15 9,711 Último mensaje 23 Octubre 2011, 18:36 pm
por 2Fac3R
[Perl] VirusTotal Scanner 0.1
Scripting
BigBear 4 2,996 Último mensaje 17 Mayo 2013, 18:43 pm
por BigBear
[Delphi] VirusTotal Scanner 0.1
Programación General
BigBear 0 2,030 Último mensaje 1 Noviembre 2013, 16:51 pm
por BigBear
VirusTotal es seguro ?
Seguridad
xpuns 2 3,623 Último mensaje 18 Noviembre 2015, 00:57 am
por boy-ka
alternativa a virustotal
Análisis y Diseño de Malware
Flamer 3 3,006 Último mensaje 21 Noviembre 2018, 22:51 pm
por rub'n
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines